Skip to content

Commit

Permalink
Move SZA dtype determination one level up
Browse files Browse the repository at this point in the history
  • Loading branch information
pnuu committed Nov 21, 2023
1 parent e40fb6c commit 4c7b330
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions satpy/modifiers/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _get_reflectance_as_dataarray(self, projectables, optional_datasets):
da_nir = _nir.data
da_tb11 = _tb11.data
da_tb13_4 = self._get_tb13_4_from_optionals(optional_datasets)
da_sun_zenith = self._get_sun_zenith_from_provided_data(projectables, optional_datasets)
da_sun_zenith = self._get_sun_zenith_from_provided_data(_nir, optional_datasets, _nir.dtype)

logger.info("Getting reflective part of %s", _nir.attrs["name"])
reflectance = self._get_reflectance_as_dask(da_nir, da_tb11, da_tb13_4, da_sun_zenith, _nir.attrs)
Expand All @@ -95,7 +95,7 @@ def _get_tb13_4_from_optionals(optional_datasets):
return tb13_4

@staticmethod
def _get_sun_zenith_from_provided_data(projectables, optional_datasets):
def _get_sun_zenith_from_provided_data(_nir, optional_datasets, dtype):
"""Get the sunz from available data or compute it if unavailable."""
sun_zenith = None

Expand All @@ -106,8 +106,7 @@ def _get_sun_zenith_from_provided_data(projectables, optional_datasets):
if sun_zenith is None:
if sun_zenith_angle is None:
raise ImportError("Module pyorbital.astronomy needed to compute sun zenith angles.")
_nir = projectables[0]
lons, lats = _nir.attrs["area"].get_lonlats(chunks=_nir.data.chunks, dtype=_nir.dtype)
lons, lats = _nir.attrs["area"].get_lonlats(chunks=_nir.data.chunks, dtype=dtype)
sun_zenith = sun_zenith_angle(_nir.attrs["start_time"], lons, lats)
return sun_zenith

Expand Down

0 comments on commit 4c7b330

Please sign in to comment.