Skip to content

Fix dtype promotion in mersi2_l1b reader #2976

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

Merged
merged 6 commits into from
Nov 12, 2024
Merged

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Nov 11, 2024

With Numpy 2 the dtype of read data fir mersi2_l1b reader changed from float32 to float64. The fix was simple, but I'm not entirely sure the changes in the tests reflect the actual data.

The memory usage for my test composites went from 14 GB down to 10 GB.

  • Tests added

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.10%. Comparing base (4a8d8ff) to head (fd2cec6).
Report is 264 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2976   +/-   ##
=======================================
  Coverage   96.10%   96.10%           
=======================================
  Files         377      377           
  Lines       55134    55147   +13     
=======================================
+ Hits        52984    52997   +13     
  Misses       2150     2150           
Flag Coverage Δ
behaviourtests 3.94% <0.00%> (-0.01%) ⬇️
unittests 96.19% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Nov 11, 2024

Pull Request Test Coverage Report for Build 11792626537

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 96.207%

Totals Coverage Status
Change from base Build 11745130714: 0.0%
Covered Lines: 53241
Relevant Lines: 55340

💛 - Coveralls

@@ -512,6 +523,9 @@ def test_all_resolutions(self):
_test_multi_resolutions(available_datasets, self.ir_250_bands, resolution, ir_num_results)

res = reader.load(self.bands_1000 + self.bands_250)
for i in res:
assert res[i].dtype == np.float32
Copy link
Member

Choose a reason for hiding this comment

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

Need to compute the dask array for this too, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, I already had that ready on my work laptop but didn't push it. Added in 85f85af

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

I think angles data should remain in float64, otherwise looks good.

Comment on lines +212 to +213
"Slope": np.array([.01] * 1, dtype=np.float32),
"Intercept": np.array([0.] * 1, dtype=np.float32),
Copy link
Member

Choose a reason for hiding this comment

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

Angles should remain in float64 right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually the SensorZenith data are H5T_STD_I16LE in the files. Slope and intercept are float32. Fixed in
fd2cec6

Btw, why is this also in the _get_1km_data(), while in the data it is not in the channel data files?

Copy link
Member

Choose a reason for hiding this comment

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

I have no idea...

@@ -237,7 +248,7 @@ def _get_geo_data(num_scans, rows_per_scan, num_cols, prefix):
xr.DataArray(
da.ones((num_scans * rows_per_scan, num_cols), chunks=1024),
attrs={
"Slope": np.array([1.] * 1), "Intercept": np.array([0.] * 1),
"Slope": np.array([1.] * 1, dtype=np.float32), "Intercept": np.array([0.] * 1, dtype=np.float32),
Copy link
Member

Choose a reason for hiding this comment

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

Angles should remain in float64 right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Longitude and its intercept and slope seem to be float64. Fixed in 3bb6db5

@@ -246,7 +257,7 @@ def _get_geo_data(num_scans, rows_per_scan, num_cols, prefix):
xr.DataArray(
da.ones((num_scans * rows_per_scan, num_cols), chunks=1024),
attrs={
"Slope": np.array([1.] * 1), "Intercept": np.array([0.] * 1),
"Slope": np.array([1.] * 1, dtype=np.float32), "Intercept": np.array([0.] * 1, dtype=np.float32),
Copy link
Member

Choose a reason for hiding this comment

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

Angles should remain in float64 right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Latitude and its intercept and slope seem to be float64. Fixed in 3bb6db5

@@ -255,7 +266,7 @@ def _get_geo_data(num_scans, rows_per_scan, num_cols, prefix):
xr.DataArray(
da.ones((num_scans * rows_per_scan, num_cols), chunks=1024),
attrs={
"Slope": np.array([.01] * 1), "Intercept": np.array([0.] * 1),
"Slope": np.array([.01] * 1, dtype=np.float32), "Intercept": np.array([0.] * 1, dtype=np.float32),
Copy link
Member

Choose a reason for hiding this comment

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

Angles should remain in float64 right?

Copy link
Member Author

@pnuu pnuu Nov 12, 2024

Choose a reason for hiding this comment

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

Actually the SensorZenith data are H5T_STD_I16LE in the files. Slope and intercept are float32. Fixed in 3bb6db5

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

LGTM!

@pnuu pnuu merged commit a68c801 into pytroll:main Nov 12, 2024
18 checks passed
@pnuu pnuu deleted the bugfix-mersi-dtype branch November 12, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants