Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

egouden
Copy link
Contributor

@egouden egouden commented Jan 28, 2025

The WMO conventions define two types of data variables for the sweep object:

  • dataset variables, with dimension of time and range (e.g. DBZH, RR, quality1, ...)
  • metadata variables, typically a scalar (e.g. sweep_number, sweep_mode, polarization_mode, ...)

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.

Copy link
Collaborator

@kmuehlbauer kmuehlbauer left a 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."""
Copy link
Collaborator

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):
Copy link
Collaborator

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?

Copy link
Contributor Author

@egouden egouden Jan 28, 2025

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.

@egouden egouden force-pushed the select_dataset_variables branch from b17b74e to 471b791 Compare January 28, 2025 12:37
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.60%. Comparing base (830d86b) to head (0027f67).
Report is 4 commits behind head on main.

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              
Flag Coverage Δ
notebooktests 78.69% <17.39%> (-0.28%) ⬇️
unittests 93.18% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@egouden egouden force-pushed the select_dataset_variables branch 6 times, most recently from 36ef51f to 5c22f44 Compare January 28, 2025 15:34
@egouden egouden marked this pull request as draft January 29, 2025 11:32
@egouden egouden force-pushed the select_dataset_variables branch 2 times, most recently from f6a5f44 to 3efa0a4 Compare January 29, 2025 14:21
@egouden egouden marked this pull request as ready for review January 29, 2025 14:24
@egouden
Copy link
Contributor Author

egouden commented Jan 29, 2025

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
@egouden egouden force-pushed the select_dataset_variables branch from 3efa0a4 to 0027f67 Compare February 6, 2025 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants