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

Set dtype for get_lonlats() in NIR reflectance calculation #2642

Merged
merged 29 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
65d3551
Set dtype for get_lonlats() in NIR reflectance calculation
pnuu Nov 21, 2023
e40fb6c
Check that NIR dtype is passed to get_lonlats() call
pnuu Nov 21, 2023
4c7b330
Move SZA dtype determination one level up
pnuu Nov 21, 2023
b992edb
Rename _nir variable to nir
pnuu Nov 21, 2023
a0c2c23
Fix NIREmissive SZA calculation to use the same as NIRReflective
pnuu Nov 21, 2023
a7a0236
Add pykdtree as unstable dependency
pnuu Nov 21, 2023
1256104
Try building pykdtree with numpy 2 in ci.yaml
djhoese Nov 21, 2023
efe647f
More debugging for unstable in ci.yaml
djhoese Nov 21, 2023
05111af
Try removing pykdtree first in unstable CI
djhoese Nov 21, 2023
8a55d33
Build pyresample with numpy 2 in unstable CI
djhoese Nov 21, 2023
c6bb954
Add missing versioneer unstable CI dependency
djhoese Nov 21, 2023
5221564
Install versioneer in a different way
djhoese Nov 21, 2023
921ed0f
Refactor _get_reflectance/emissivity_as_dataarray
pnuu Nov 21, 2023
7874622
Merge branch 'preserve-nir-reflectance-dtype' of https://github.com/p…
pnuu Nov 21, 2023
05c1268
Try --no-build-isolation for all unstable deps
djhoese Nov 21, 2023
21de5b0
Add extension-helpers to unstable build dependencies
djhoese Nov 21, 2023
3a97a1a
Allow dependencies to be installed in unstable CI
djhoese Nov 21, 2023
0c53817
More unstable CI reworking
djhoese Nov 21, 2023
71e489e
Add shapely to unstable CI build
djhoese Nov 21, 2023
8b4e05d
Add trollimage to unstable dependencies
djhoese Nov 21, 2023
a58e9c9
Try adding pyhdf to unstable deps
djhoese Nov 21, 2023
08159ba
Try removing pyhdf from conda in unstable CI
djhoese Nov 21, 2023
4b165c4
Add netcdf4-python to unstable CI
djhoese Nov 21, 2023
f2cbbe5
Add h5py to unstable CI
djhoese Nov 21, 2023
fe67279
Add missing unstable deps
djhoese Nov 21, 2023
c9a861f
Install h5py in unstable CI without build isolation
djhoese Nov 21, 2023
88ae0a6
Use h5py cython branch for unstable CI
djhoese Nov 21, 2023
9efa3cb
Fix cython dev h5py install
djhoese Nov 21, 2023
d250a9d
Rename _tb11 variable to tb11
pnuu Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nitpicking here, but I would rename _nirto nir here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in b992edb

"""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)
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
2 changes: 1 addition & 1 deletion satpy/tests/test_modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_no_sunz_no_co2(self, calculator, apply_modifier_info, sza):

# due to copying of DataArrays, self.get_lonlats is not the same as the one that was called
# we must used the area from the final result DataArray
res.attrs["area"].get_lonlats.assert_called()
res.attrs["area"].get_lonlats.assert_called_with(chunks=((2,), (2,)), dtype=self.nir.dtype)
sza.assert_called_with(self.start_time, self.lons, self.lats)
self.refl_from_tbs.assert_called_with(self.da_sunz, self.nir.data, self.ir_.data, tb_ir_co2=None)
assert np.allclose(res.data, self.refl * 100).compute()
Expand Down
Loading