pytroll / satpy

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

0.52.0 breaks `seviri_l2_grib`-reader with 'EUML2GribFileHandler' object has no attribute '_ssp_lon' #2942

Closed fwfichtner closed 4 weeks ago

fwfichtner commented 1 month ago

Describe the bug 0.52.0 breaks seviri_l2_grib-reader

To Reproduce

# Your code here
scene = satpy.Scene(reader='seviri_l2_grib', filenames=files)

Expected behavior To not crash.

Actual results

Traceback (most recent call last):
  File "/Users/username/PycharmProjects/data-engineering-exchange/MTG_FCI_L1/open_and_read.py", line 23, in <module>
    scene = satpy.Scene(reader='seviri_l2_grib', filenames=files)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/scene.py", line 155, in __init__
    self._readers = self._create_reader_instances(filenames=filenames,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/scene.py", line 176, in _create_reader_instances
    return load_readers(filenames=filenames,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/__init__.py", line 572, in load_readers
    reader_instance.create_storage_items(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 617, in create_storage_items
    return self.create_filehandlers(files, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 629, in create_filehandlers
    filehandlers = self._new_filehandlers_for_filetype(filetype_info,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 612, in _new_filehandlers_for_filetype
    return list(filtered_iter)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 596, in filter_fh_by_metadata
    filehandler.metadata["end_time"] = filehandler.end_time
                                       ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/geo/lib/python3.11/site-packages/satpy/readers/eum_l2_grib.py", line 81, in end_time
    delta = SEVIRI_REPEAT_CYCLE_DURATION_RSS if self._ssp_lon == 9.5 else SEVIRI_REPEAT_CYCLE_DURATION
                                                ^^^^^^^^^^^^^
AttributeError: 'EUML2GribFileHandler' object has no attribute '_ssp_lon'

Environment Info:

Additional context Add any other context about the problem here.

strandgren commented 1 month ago

Thanks for reporting this and sorry for breaking the reader. This bug was introduced by https://github.com/pytroll/satpy/pull/2717 which adds support for the FCI L2 CLM GRIB product. As part of the PR, the SEVIRI end_time property was improved in order to identify if the data is from Full Earth Scanning (FES) with a temporal resolution of 15 mins or Rapid Scanning Service (RSS) with a temporal resolution of 5 mins. Before the reader always assumed 15 min temporal resolution, which was incorrect for RSS data.

However, the new solution meant that the end_time property was only available after loading a dataset and its metadata and not after Scene initialization and this was not properly captured by the unit test.

https://github.com/pytroll/satpy/pull/2943 should fix this bug.