pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.06k stars 293 forks source link

'str' object has no attribute 'decode' during Sentinel-2 MSI processing #1436

Closed yukaribbba closed 3 years ago

yukaribbba commented 3 years ago

Describe the bug After I updated the conda env by conda update -c conda-forge --all, this occured. Looks like it happened in atm correction.

To Reproduce

#!/usr/bin/env python
from satpy import Scene, find_files_and_readers
files = find_files_and_readers(base_dir="/mnt/hgfs/Downloads/Sentinel-2/",
                               reader='msi_safe')
scn = Scene(filenames=files)
composite = 'true_color_marine_clean'
scn.load([composite])
scn.save_dataset(composite, filename='{name}_{start_time:%Y%m%d_%H%M%S}.tif', writer='geotiff', base_dir="/mnt/hgfs/Downloads/Sentinel-2/", num_threads=8, compress=None)

Expected behavior No error.

Actual results

/home/ll/anaconda3/lib/python3.8/site-packages/satpy/resample.py:150: UserWarning: Gradient search resampler not available, upgrade Pyresample. warnings.warn('Gradient search resampler not available, upgrade Pyresample.') /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/satpy/readers/msi_safe.py:199: RuntimeWarning: Mean of empty slice return np.nanmean(np.dstack(arrays), -1) /home/ll/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/ll/anaconda3/lib/python3.8/site-packages/satpy/readers/msi_safe.py:199: RuntimeWarning: Mean of empty slice return np.nanmean(np.dstack(arrays), -1) Traceback (most recent call last): File "/home/ll/Downloads/s2t.py", line 7, in scn.load([composite]) File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 984, in load keepables = self._generate_composites() File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 897, in _generate_composites return self._read_composites(nodes) File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 873, in _read_composites self._generate_composite(item, keepables) File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 813, in _generate_composite prereq_datasets = self._get_prereq_datasets( File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 763, in _get_prereq_datasets self._generate_composite(prereq_node, keepables) File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/scene.py", line 847, in _generate_composite composite = compositor(prereq_datasets, File "/home/ll/anaconda3/lib/python3.8/site-packages/satpy/composites/init.py", line 604, in call refl_cor_band = corrector.get_reflectance(sunz, satz, ssadiff, File "/home/ll/anaconda3/lib/python3.8/site-packages/pyspectral/rayleigh.py", line 248, in get_reflectance wvl = self.get_effective_wavelength(bandname) File "/home/ll/anaconda3/lib/python3.8/site-packages/pyspectral/rayleigh.py", line 187, in get_effective_wavelength rsr = RelativeSpectralResponse(self.platform_name, self.sensor) File "/home/ll/anaconda3/lib/python3.8/site-packages/pyspectral/rsr_reader.py", line 125, in init self.load() File "/home/ll/anaconda3/lib/python3.8/site-packages/pyspectral/rsr_reader.py", line 174, in load self.description = self.description.decode('utf-8') AttributeError: 'str' object has no attribute 'decode'

Environment Info:

Writers

cf: ok geotiff: ok mitiff: ok ninjotiff: cannot find module 'satpy.writers.ninjotiff' (No module named 'pyninjotiff') scmi: ok simple_image: ok

Extras

cartopy: No module named 'cartopy' geoviews: No module named 'geoviews'



**Additional context**
Add any other context about the problem here.
djhoese commented 3 years ago

This is an incompatibility between pyspectral and h5py 3.x. It is being worked on, but the short term solution would be to downgrade your version of h5py to <3. I think conda install "h5py<3" should work.

adybbroe commented 3 years ago

@yukaribbba Sorry about that. A PR is about to be merged in https://github.com/pytroll/pyspectral Until then follow the advise by @djhoese

yukaribbba commented 3 years ago

@djhoese @adybbroe Ok thank you.

mraspaud commented 3 years ago

@yukaribbba the new pyspectral is out now, if you want to try it out!

yukaribbba commented 3 years ago

@mraspaud Yep! The problem is solved by updating pyspectral to 0.10.2. Thanks!

mraspaud commented 3 years ago

perfect, thanks for checking. Closing.