Skip to content

Refactor MODIS readers to avoid extra dask tasks #3081

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 3 commits into from
Mar 21, 2025

Conversation

djhoese
Copy link
Member

@djhoese djhoese commented Mar 18, 2025

I was using the modis_l1b reader for debugging something dask related and got annoyed at how many tasks were in the task graph for simple reading functionality. This PR rewrites some of these things to avoid the repetitive tasks (scaling and fill value checks) and the confusing tasks (angle offsets for lonlat2xyz compatibility). I was tempted to also apply changes like this to all the calibration and uncertainty checks, but overall these changes don't affect performance much so I plan to leave these other changes for a future where I (or someone else) is annoyed by all the tasks being shown by dask.

Note: I did these while debugging other things so it is possible the code is not the cleanest and needs more cleanup, but the tests pass so I think that's a good start.

  • Closes #xxxx
  • Tests added
  • Fully documented
  • Add your name to AUTHORS.md if not there already

@djhoese djhoese added component:readers cleanup Code cleanup but otherwise no change in functionality labels Mar 18, 2025
@djhoese djhoese requested review from mraspaud and pnuu March 18, 2025 01:49
@djhoese djhoese self-assigned this Mar 18, 2025
@djhoese djhoese force-pushed the cleanup-modis-dask-tasks branch from 946c377 to 8e5ee94 Compare March 18, 2025 01:53
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

Attention: Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.15%. Comparing base (128bb9e) to head (94a57cf).
Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
satpy/readers/hdfeos_base.py 96.61% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3081   +/-   ##
=======================================
  Coverage   96.14%   96.15%           
=======================================
  Files         383      383           
  Lines       55798    55813   +15     
=======================================
+ Hits        53649    53666   +17     
+ Misses       2149     2147    -2     
Flag Coverage Δ
behaviourtests 3.88% <0.00%> (+<0.01%) ⬆️
unittests 96.24% <96.72%> (+<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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 have a suggestion for refactoring the interpolation function, but looks good otherwise

@@ -280,7 +280,8 @@ def calibrate_refl(array, attributes, index):
offset = np.float32(attributes["reflectance_offsets"][index])
scale = np.float32(attributes["reflectance_scales"][index])
# convert to reflectance and convert from 1 to %
array = (array - offset) * scale * 100
array = (array - offset)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
array = (array - offset)
array = array - offset

Copy link
Member Author

Choose a reason for hiding this comment

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

Crap. I just realized I never did this.

@coveralls
Copy link

coveralls commented Mar 18, 2025

Pull Request Test Coverage Report for Build 13972719479

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 59 of 61 (96.72%) changed or added relevant lines in 2 files are covered.
  • 23 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 96.258%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/readers/hdfeos_base.py 57 59 96.61%
Files with Coverage Reduction New Missed Lines %
satpy/writers/init.py 23 90.91%
Totals Coverage Status
Change from base Build 13645068765: 0.005%
Covered Lines: 53913
Relevant Lines: 56009

💛 - Coveralls

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

@mraspaud mraspaud merged commit d3dde6d into pytroll:main Mar 21, 2025
18 checks passed
@djhoese djhoese deleted the cleanup-modis-dask-tasks branch March 26, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code cleanup but otherwise no change in functionality component:readers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants