-
Notifications
You must be signed in to change notification settings - Fork 295
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
Fix unnecessary Dask compute()
s in NDVIHybridGreen
compositor
#2623
Conversation
s in
NDVIHybridGreen` compositorcompute()
s in NDVIHybridGreen
compositor
Codecov Report
@@ Coverage Diff @@
## main #2623 +/- ##
=======================================
Coverage 95.18% 95.18%
=======================================
Files 354 354
Lines 51270 51280 +10
=======================================
+ Hits 48803 48813 +10
Misses 2467 2467
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Thanks @pnuu. Such a small change to make the code shorter, cleaner and much more efficient :D Nice addition to the tests as well! |
Pull Request Test Coverage Report for Build 6721469074
💛 - Coveralls |
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.
This looks good to me. One other check you could add is seeing if the computed numpy array from .values
or .data.compute()
has the same dtype as the DataArray. You could force the input data to be 32-bit floats and make sure it is np.float32
in the output since we rarely want data to be upcast to 64-bit. If the DataArray and the numpy array have different dtypes that's usually a sign that a map_blocks
is doing things against it's interface.
If that seems pointless here then feel free to merge.
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
Co-authored-by: David Hoese <david.hoese@ssec.wisc.edu>
The
NDVIHybridGreenCompositor
was usingda.where()
on aDataArray
to replace values outside limits causing unnecessary computations. This PR replaces these two calls with aDataArray.clip()
and adds checks in the tests that there is only one computation and only when it is requested.