-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add cf conventions helper #31
base: main
Are you sure you want to change the base?
Conversation
x = axes.get("X", [None])[0] | ||
y = axes.get("Y", [None])[0] | ||
z = axes.get("Z", [None])[0] |
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 just feels wrong
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 that is quite ugly.
Alternatives are
x = da.axes["X"][0] if "X" in da.cf else None
or in _get_array
:
# if cf_xarray exists
return da.cf[key] # this falls back to usually xarray stuff if "key" is not interpretable using cf conventions
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.
Great! thank you for the suggestions
Codecov Report
@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 90.73% 91.36% +0.63%
==========================================
Files 8 9 +1
Lines 205 220 +15
==========================================
+ Hits 186 201 +15
Misses 19 19
Continue to review full report at Codecov.
|
cc'ing @dcherian as a cf-xarray pro |
Resolves #15
I feel this should be double-checked by someone more familiar with CF conventions and how that accessor works.
Also, this should be tested against more datasets
cc @rabernat, any feedback here? The premise is that the new function added here can attempt to use
cf_xarray
to get the XYZ coordinate array names when the user does not specify names.In future work, this can be used to address #19