Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archived GOES datasets not loading. AttributeError: 'area' object has no attribute 'crs' #2111

Closed
plecraw opened this issue May 23, 2022 · 2 comments · Fixed by #2219
Closed

Comments

@plecraw
Copy link

plecraw commented May 23, 2022

Hello all,
I am trying to read in high resolution archival nc files all the way back to GOES 8 in 1995. Unfortunately, satpy errors at scn.load while reading native resolution GOES nc files downloaded from NOAA CLASS. (Goes 8, 9, and 12 tested).

Specifically, this fails on:

  • native resolution GOES-12 *BAND_01 nc files
  • native resolution GOES-08 *BAND_01 nc files

While it works with:

  • 16km resolution GOES-09 *BAND_01 nc files
  • 16km resolution GOES-12 *BAND_01 nc files
  • full resolution GOES-16 *BAND_01_02_03 nc files

My code:

import satpy
from satpy import Scene
from glob import glob
import xarray

filenames = glob('goes12.2005.240.144514.BAND_01*')
scn = Scene(filenames=filenames)

scn.load(['00_7']) #Error occurs during scn.load

new_scn = scn.resample('worldeqc30km',resampler='nearest',fill_value=0)
new_scn.save_dataset('00_7',filename='Goes12testwork'+'.png')

I expect satpy to load the scene and allow me to continue with the resampling procedure.

Here is the resulting error code with debug_on()

[DEBUG: 2022-05-23 15:46:35 : satpy.readers.yaml_reader] Reading ('C:\\Python39\\Lib\\site-packages\\satpy\\etc\\readers\\goes-imager_nc.yaml',)
C:\Python39\lib\site-packages\satpy\readers\seviri_base.py:453: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not 
modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  ('GsicsCalMode', np.bool),
C:\Python39\lib\site-packages\satpy\readers\seviri_base.py:454: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not 
modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  ('GsicsCalValidity', np.bool),
[DEBUG: 2022-05-23 15:46:35 : satpy.readers.yaml_reader] Assigning to goes-imager_nc: ['goes12.2005.240.144514.BAND_01.nc']
[DEBUG: 2022-05-23 15:46:35 : satpy.composites.config_loader] Looking for composites config file goes_imager.yaml
[DEBUG: 2022-05-23 15:46:35 : satpy.composites.config_loader] Looking for composites config file visir.yaml
[DEBUG: 2022-05-23 15:46:35 : satpy.readers.goes_imager_nc] Reading dataset longitude_00_7
[DEBUG: 2022-05-23 15:46:35 : satpy.readers.goes_imager_nc] Computing earth mask
[DEBUG: 2022-05-23 15:46:35 : satpy.readers.goes_imager_nc] Computing nadir pixel
[DEBUG: 2022-05-23 15:46:39 : satpy.readers.goes_imager_nc] Computing yaw flip flag
[DEBUG: 2022-05-23 15:46:40 : satpy.readers.goes_imager_nc] Computing area definition
Traceback (most recent call last):
  File "e:\OneDrive - Personal\OneDrive\Projects\WESS\Python\WalkerResampler.py", line 23, in <module>   
    scn.load(['00_7'])
  File "C:\Python39\lib\site-packages\satpy\scene.py", line 1275, in load
    self._read_datasets_from_storage(**kwargs)
  File "C:\Python39\lib\site-packages\satpy\scene.py", line 1298, in _read_datasets_from_storage
    return self._read_dataset_nodes_from_storage(nodes, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\scene.py", line 1304, in _read_dataset_nodes_from_storage    
    loaded_datasets = self._load_datasets_by_readers(reader_datasets, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\scene.py", line 1329, in _load_datasets_by_readers
    new_datasets = reader_instance.load(ds_ids, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\readers\yaml_reader.py", line 963, in load
    ds = self._load_dataset_with_area(dsid, coords, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\readers\yaml_reader.py", line 851, in _load_dataset_with_area
    ds = self._load_dataset_data(file_handlers, dsid, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\readers\yaml_reader.py", line 723, in _load_dataset_data     
    proj = self._load_dataset(dsid, ds_info, file_handlers, **kwargs)
  File "C:\Python39\lib\site-packages\satpy\readers\yaml_reader.py", line 699, in _load_dataset
    projectable = fh.get_dataset(dsid, ds_info)
  File "C:\Python39\lib\site-packages\satpy\readers\goes_imager_nc.py", line 1020, in get_dataset
    data = data.where(self.meta['earth_mask'])
  File "C:\Python39\lib\site-packages\satpy\readers\goes_imager_nc.py", line 787, in meta
    area_def_uni = self._get_area_def_uniform_sampling(
  File "C:\Python39\lib\site-packages\satpy\readers\goes_imager_nc.py", line 704, in _get_area_def_uniform_sampling
    xmax, ymax = get_geostationary_angle_extent(
  File "C:\Python39\lib\site-packages\satpy\readers\utils.py", line 90, in get_geostationary_angle_extent
    a, b = _get_geostationary_semi_axes(geos_area)
  File "C:\Python39\lib\site-packages\satpy\readers\utils.py", line 84, in _get_geostationary_semi_axes
    return proj4_radius_parameters(geos_area.crs)
AttributeError: 'area' object has no attribute 'crs'

Environment Info:

  • OS: Windows 10 & 11
  • Satpy Version: 0.36.0
  • PyResample Version: 1.22.3

Relevant Readers:

  • Readers: goes-imager_nc: ok

Note that neither cartopy nor geoviews are installed.

Additional context
A friend and I may have tracked down a potential bug in line 705 of readers\goes_imager_nc.py:

xmax, ymax = get_geostationary_angle_extent(
                namedtuple('area', ['proj_dict'])(proj_dict))

When geos_area is later created using this namedtuple, it tries to reference a 'crs' attribute which, in the area definition just before, is not initially defined.

proj_dict = {'a': EQUATOR_RADIUS,
             'b': POLE_RADIUS,
             'lon_0': lon0,
             'h': ALTITUDE,
             'proj': 'geos',
             'units': 'm'}

I'm not sure how much help this is, but it may help point you in the right direction.

Thanks in advance for the help.

@djhoese
Copy link
Member

djhoese commented May 23, 2022

So it looks like this is a case not caught by the tests and definitely a bug. Looks like @sfinkens added this reader and this hacky bit of code that creates a nametuple. Pyresample (and therefore satpy) is slowly moving away from using PROJ.4 dictionaries wherever possible. Recently (within the last year) I updated uses of proj_dict in Satpy to use .crs on AreaDefinition objects including this _get_geostationary_semi_axes function, but I must have missed this usage of proj_dict in the reader since it isn't a normal attribute access and isn't covered in the tests.

Maybe @sfinkens has some ideas for how to fix this.

@sfinkens
Copy link
Member

Sorry for taking to long to reply. Indeed that looks hacky! I'll assign it to me and look into it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants