-
Notifications
You must be signed in to change notification settings - Fork 298
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
Refactor SZA and cos(SZA) generation to reduce duplicate computations #1910
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1910 +/- ##
==========================================
+ Coverage 93.39% 93.43% +0.03%
==========================================
Files 273 275 +2
Lines 40622 40742 +120
==========================================
+ Hits 37940 38067 +127
+ Misses 2682 2675 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I should note that this PR reduced the overall memory usage of the AHI and ABI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, with the refactoring. I see there is quite some comment code, maybe it should be removed. Also, it feels like most of the wrapping could be done as a decorator, an be done in pyorbital.
"Why leave the commented code?" Because I made this PR after 10 hours of working on this as a "hack" that then turned into an actual PR. I'll clean it up today. |
Thanks |
@mraspaud You mean do |
Oh you mean make a decorator in pyorbital that handles dask inputs with map_blocks or if passed numpy arrays then calls it directly. Right? |
@mraspaud I think I've addressed all your concerns except for moving some of this dask support to pyorbital. Pyorbital doesn't currently have any dask or xarray support as far as I know. |
yes |
Obviously that has to be done in a separate PR (on pyorbital) but would you be OK with this being merged as-is and then working on pyorbital later? |
That's ok, let's hope we have the time to fix pyorbital soon. Do we have an issue for that? otherwise it might be good to create one now, so that we don't forget this too easily |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just one clarification to docstring.
@mraspaud An issue has been created: pytroll/pyorbital#88 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is another step towards better performance regarding #1902. I haven't figured everything out yet, but this PR does seem to help a little bit. There is a small amount of duplicate logic between satpy and pyorbital regarding the
sun_zenith_angle
function which was justnp.rad2deg(np.arccos(cos_zen))
. As pointed out in #1902, I noticed that cos(SZA) calculations for the sunz corrector modifier were not being shared with the rayleigh correction which also needs to calculate SZA. This PR refactors the relevant functions and wraps parts in map_blocks to allow dask to reuse calculations when possible.