-
Notifications
You must be signed in to change notification settings - Fork 77
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
expose func arg and skip_na to compute_MVBS users #1269
expose func arg and skip_na to compute_MVBS users #1269
Conversation
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.
Hey @ctuguinay : Thanks for the investigation and changes! I was thinking through the use of func
and skipna
, and am thinking that we should probably avoid the confusion (which stemmed from the way xarray_reduce of using func
and skipna
at the same time.
For compute_MVBS
, since it is supposed to be a mean operation, we do not have to allow for other func
, but just need the skipna
parameter. The same for compute_raw_MVBS
. The place where we really need the func
is _groupby_x_along_channels
. So, I think we can have:
compute_MVBS
andcompute_raw_MVBS
will only haveskipna
as a parameter_groupby_x_along_channels
have bothfunc
andskipna
, and since it is under the hood, we can make surefunc="nanmean"
+skipna=True
orfunc="mean"
+skipna=False
are used with it.
The compute_NASC
computation comes to mind naturally, that we could allow the same skipna
argument, and under the hood use either func="nansum"
+skipna=True
or func="sum"
+ skipna=False
Thoughts?
Hey @leewujung, thanks for the review! I agree with you on the implementation details. I also think that not all combinations should be allowed (ie the combinations Would you also like me to make this same change of exposing |
Sounds good if you could add this for |
Hey @leewujung, I made the changes, but only the changes for I do have a few questions on the In But, I do also see the |
Oh right, you're right that it would still be mean/nanmean in the
For
|
Sounds good, thanks! |
This one is taking me a bit since I am getting some weird NaN values in the |
Yeah, and making the test data with smaller dimensions may help with figuring out what is going on. For example computing NASC using just 2 pings of data should give you some flexibility to look into where NaNs should be created and where it should not. |
Looking back at that compute MVBS test that I modified, I think I'll revert the change I made for that and have two separate tests (1 for compute MVBS and 1 for compute NASC) with smaller data arrays to do as you suggested above. The |
…maller subset of ds Sv
… same nan elements
@ctuguinay : I direct-pushed some changes to fix
|
# Already has 2 channels, so subset for only ping time and range sample | ||
subset_ds_Sv = ds_Sv.isel(ping_time=slice(0,2), range_sample=slice(0,2)) |
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.
I think having only 2 depth values makes the mock dataset too small for the test to actually check whether the number and location of NaN elements at the output of NASC or MVBS computation is correct. I think you can select 2 of the pings, with one of them having some NaN elements and the other doesn't, but retain all elements along echo_range
. This dataarray size should be manageable but would be a lot more realistic.
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.
I agree. I'll make these changes.
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.
@ctuguinay : see my comments for increasing the test data size along echo_range
. Thanks!
Co-authored-by: Wu-Jung Lee <[email protected]>
Co-authored-by: Wu-Jung Lee <[email protected]>
Co-authored-by: Wu-Jung Lee <[email protected]>
Co-authored-by: Wu-Jung Lee <[email protected]>
…add warning where coordinates have NaNs
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1269 +/- ##
===========================================
- Coverage 83.52% 64.54% -18.99%
===========================================
Files 64 14 -50
Lines 5686 925 -4761
===========================================
- Hits 4749 597 -4152
+ Misses 937 328 -609
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
PR for #1268
In addition, modified
test_compute_MVBS_values
to include a test for adding NaNs to theds_Sv
to illustrate how that would affect the computation ofcompute_MVBS
using bothfunc="nanmean"
andfunc="mean"
.