Repository navigation
Support DataTree - #2144
Support DataTree#2144
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Hey @aulemahal, Thanks for tackling this so fast! Really appreciated.
It may be nice to illustrate how one could than filter the DataTree to include only those leaves (nodes with datasets) that have the required dataset. |
|
Something like this would do the job and allow applying the datatree where possible. var = "air"
DT.filter(lambda ds: var in ds.data_vars) |
|
Note that currently, this PR does not address convert_units_to functionality. |
|
Started an attempt in #2152 |
|
@kobebryant432 thanks for your PR. However, after discussions with colleagues, I think I prefer the proposition I just pushed. I made It has the same constraint as the indicator : all nodes must have all required variables. However, I did not implement the empty-node skipping in |
|
@huard I had forgotten, but the decorator was not implemented in @Zeitsperre 2 more ambiguous input types 🔥 |
Pull Request Checklist:
number) and pull request (:pull:number) has been addedWhat kind of change does this PR introduce?
Support
xarray.Datatreeobjects in thedsargument of indicators. When receiving such an object, the indicator computation is mapped over the datasets of the tree.Passing a
Datatreeimplies setting theas_datasetoption to True.Does this PR introduce a breaking change?
No, it shouldn't.
xr.Datatreewas added recently, and xclim will not fail if it absent. However, I can't promise it will work with the old standalonexarray-datatreemodule!Other information:
This is missing some tests, but most importantly I have a dilemma here : what do we do when a node doesn't have the appropriate variables ?
A Datatree can have nodes with no data, I think it is quite common, depending on your structure. Currently, the code will skip any node that has no "data vars", returning the node untouched. However, any other node that doesn't have the required variables will trigger a failure with a
MissingVariableError.Alternatives would be to return an empty node or return the node untouched.
What does @kobebryant432 think of this question ?