Repository navigation
fixes NDVI with target_band - #428
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #428 +/- ##
==========================================
+ Coverage 83.15% 83.36% +0.20%
==========================================
Files 39 39
Lines 2571 2597 +26
==========================================
+ Hits 2138 2165 +27
+ Misses 433 432 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| nd = xr.merge([data, nd]) | ||
|
|
||
| # add potentially missing coords from data to nd, so that xr.concat works | ||
| nd = _add_missing_coords(nd, data, band_dim) |
There was a problem hiding this comment.
There are 4 consecutive assignments to a variable called "nd" (which I assume is short for normalized difference), and it seems unlikely that all 4 are the normalized difference.
If you rewrite this as:
thing = _add_missing_coords(nd.expand_dims(band_dim).assign_coords({band_dim: [target_band]}), data, band_dim)
nd = xr.concat([data, thing], dim=band_dim)we can reduce that to 2 consecutive assignments, and the surrounding code still works.
(I don't know what "thing" should be called instead, but you probably know what it is and can name it properly since you're in the process of modifying this code.)
There was a problem hiding this comment.
Disagree. Normalized difference is first computed, then dims and coords are changed to match the original datacube to which it will be added.
Also, your proposed change limits readability.
|
Thanks for your quick review. I addressed your comments in my latest commits! |
|
|
||
| missing[name] = ( | ||
| dim, | ||
| np.full(target.sizes[dim], fill, dtype=reference.coords[name].dtype), |
There was a problem hiding this comment.
The fill values are created based on the type, so I assume the concrete values are never used. Can't this function use np.empty() instead to avoid the cost of having to fill an entire array with dummy values?
There was a problem hiding this comment.
the array is always of length 1. I therefore simplified this to np.array([fill])
There was a problem hiding this comment.
I disagree with the use use of np.empty(). The arbitrary random data in the resulting array may be misinterpreted by users or downstream openEO processes
There was a problem hiding this comment.
If it's an array of length 1 it doesn't take a lot of time to initialize the array.
I don't think the fill values are any less arbitrary, but I guess they're deterministic and that is a valuable trait in itself.
|
Thanks @jonas-hurst and @pjonsson for the contribution! |
|
@clausmichele, thanks for reviewing the pr. We would appreciate to use it. :) |
|
Thanks for the reminder @przell, I will do the release today. |
|
@przell @jonas-hurst release done! |
fixes #362