-
Notifications
You must be signed in to change notification settings - Fork 17
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: function to select dataset variables in sweep #257
base: main
Are you sure you want to change the base?
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.
Thanks @egouden! That would be a nice addition. We need to have a broader discussion on appropriate naming.
@@ -120,7 +120,7 @@ def get_crs(self): | |||
|
|||
@xr.register_dataset_accessor("xradar") | |||
class XradarDataSetAccessor(XradarAccessor): | |||
"""Adds a number of xradar specific methods to xarray.DataArray objects.""" | |||
"""Adds a number of xradar specific methods to xarray.Dataset objects.""" |
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.
Nice catch!
xradar/util.py
Outdated
@@ -648,3 +650,55 @@ def _map_over_sweeps(*args, **kwargs): | |||
return xr.map_over_datasets(functools.partial(_func, **kwargs), *args) | |||
|
|||
return _map_over_sweeps | |||
|
|||
|
|||
def dataset_vars(sweep): |
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'm worrying a bit about the naming. This is too close to the xarray nomenclature (Dataset.data_vars
). I do not have an ad-hoc suggestion, maybe prepending it with something suitable?
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.
The description and implementation have been significantly changed to improve clarity.
b17b74e
to
471b791
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #257 +/- ##
==========================================
+ Coverage 93.57% 93.60% +0.03%
==========================================
Files 26 26
Lines 5041 5065 +24
==========================================
+ Hits 4717 4741 +24
Misses 324 324
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
36ef51f
to
5c22f44
Compare
f6a5f44
to
3efa0a4
Compare
This solves #104. A possibly better solution in the future would be to separate "dataset" and "metadata" variables in two sub-groups of the sweep group. |
ADD: function to get dataset variables in sweep ADD: function to get metadata variables in sweep FIX: typo in accessors module: Dataarray -> Dataset
3efa0a4
to
0027f67
Compare
The WMO conventions define two types of data variables for the sweep object:
These variables can be accessed together by the data_vars property of the sweep object (xarray Dataset). However it is not possible to make the distinction between the two types of variables. Two new functions allow to access these variables separately.
It is possible to select dataset variables directly using sweep[list of variables]. But this results in the loss of the metadata. A new function allows to select dataset variables while keeping metadata variables.