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

Can't load static image composite multiple times #2264

Closed
djhoese opened this issue Nov 9, 2022 · 1 comment · Fixed by #2292
Closed

Can't load static image composite multiple times #2264

djhoese opened this issue Nov 9, 2022 · 1 comment · Fixed by #2292

Comments

@djhoese
Copy link
Member

djhoese commented Nov 9, 2022

Releated to this (sort of), I've just discovered that reloading a composite that doesn't require any of the actual data from a sensor also fails:


# Example with SEVIRI, substitute whatever data you have
scn = Scene(['D:/sat_data/SEV/MSG3-SEVI-MSG15-0100-NA-20160326144242.057000000Z-NA.nat'], reader='seviri_l1b_native')
scn.load(["_night_background"])
print("LOADED")
scn.load(["_night_background"])
print("LOADED AGAIN")

Expected result: Prints both statements.

Actual result: Prints LOADED and raises this error before reaching second print.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [2], line 4
      2 scn.load(["_night_background"])
      3 print("LOADED")
----> 4 scn.load(["_night_background"])
      5 print("LOADED AGAIN")

File ~\PycharmProjects\satpy\satpy\scene.py:1346, in Scene.load(self, wishlist, calibration, resolution, polarization, level, generate, unload, **kwargs)
   1341 needed_datasets = (self._wishlist | dataset_keys) - set(self._datasets.keys())
   1342 query = DataQuery(calibration=calibration,
   1343                   polarization=polarization,
   1344                   resolution=resolution,
   1345                   level=level)
-> 1346 self._update_dependency_tree(needed_datasets, query)
   1348 self._wishlist |= needed_datasets
   1350 self._read_datasets_from_storage(**kwargs)

File ~\PycharmProjects\satpy\satpy\scene.py:1356, in Scene._update_dependency_tree(self, needed_datasets, query)
   1354 def _update_dependency_tree(self, needed_datasets, query):
   1355     try:
-> 1356         comps, mods = load_compositor_configs_for_sensors(self.sensor_names)
   1357         self._dependency_tree.update_compositors_and_modifiers(comps, mods)
   1358         self._dependency_tree.populate_with_keys(needed_datasets, query)

File ~\PycharmProjects\satpy\satpy\scene.py:170, in Scene.sensor_names(self)
    158 @property
    159 def sensor_names(self) -> set[str]:
    160     """Return sensor names for the data currently contained in this Scene.
    161 
    162     Sensor information is collected from data contained in the Scene
   (...)
    168 
    169     """
--> 170     contained_sensor_names = self._contained_sensor_names()
    171     reader_sensor_names = set([sensor for reader_instance in self._readers.values()
    172                                for sensor in reader_instance.sensor_names])
    173     return contained_sensor_names | reader_sensor_names

File ~\PycharmProjects\satpy\satpy\scene.py:185, in Scene._contained_sensor_names(self)
    183         sensor_names.update(data_arr.attrs["sensor"])
    184     else:
--> 185         raise TypeError("Unexpected type in sensor collection")
    186 return sensor_names

TypeError: Unexpected type in sensor collection

Originally posted by @simonrp84 in #2242 (comment)

@djhoese
Copy link
Member Author

djhoese commented Nov 21, 2022

This is actually worse than we originally thought. Any static composite doesn't allow you to load anything afterward:

In [1]: from satpy import Scene; from glob import glob

In [2]: scn = Scene(reader='abi_l1b', filenames=glob('/data/satellite/abi/20181127/*.nc'))

In [3]: scn.load(['_night_background'])
cannot convert float NaN to integer

In [4]: scn.load(['C01'])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [4], line 1
----> 1 scn.load(['C01'])

File ~/repos/git/satpy/satpy/scene.py:1350, in Scene.load(self, wishlist, calibration, resolution, polarization, level, modifiers, generate, unload, **kwargs)
   1344 needed_datasets = (self._wishlist | dataset_keys) - set(self._datasets.keys())
   1345 query = DataQuery(calibration=calibration,
   1346                   polarization=polarization,
   1347                   resolution=resolution,
   1348                   modifiers=modifiers,
   1349                   level=level)
-> 1350 self._update_dependency_tree(needed_datasets, query)
   1352 self._wishlist |= needed_datasets
   1354 self._read_datasets_from_storage(**kwargs)

File ~/repos/git/satpy/satpy/scene.py:1360, in Scene._update_dependency_tree(self, needed_datasets, query)
   1358 def _update_dependency_tree(self, needed_datasets, query):
   1359     try:
-> 1360         comps, mods = load_compositor_configs_for_sensors(self.sensor_names)
   1361         self._dependency_tree.update_compositors_and_modifiers(comps, mods)
   1362         self._dependency_tree.populate_with_keys(needed_datasets, query)

File ~/repos/git/satpy/satpy/scene.py:170, in Scene.sensor_names(self)
    158 @property
    159 def sensor_names(self) -> set[str]:
    160     """Return sensor names for the data currently contained in this Scene.
    161
    162     Sensor information is collected from data contained in the Scene
   (...)
    168
    169     """
--> 170     contained_sensor_names = self._contained_sensor_names()
    171     reader_sensor_names = set([sensor for reader_instance in self._readers.values()
    172                                for sensor in reader_instance.sensor_names])
    173     return contained_sensor_names | reader_sensor_names

File ~/repos/git/satpy/satpy/scene.py:185, in Scene._contained_sensor_names(self)
    183         sensor_names.update(data_arr.attrs["sensor"])
    184     else:
--> 185         raise TypeError("Unexpected type in sensor collection")
    186 return sensor_names

TypeError: Unexpected type in sensor collection

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.

1 participant