Sometimes you might want to map one of the xarray top-level functions (especially xr.concat
or xr.merge
) over DataTree
objects.
Whilst this could potentially be done manually, we could also imagine generalizing top-level functions to handle this out of the box.
Describe the solution you'd likeFor this to work
xr.concat([dt1, dt2], concat_dim='time')
returning a single DataTree
, with xr.concat
applied to sets of datasets in corresponding nodes.
We could instead not change xarray's top-level functions but still ensure that its relatively easy to achieve using map_over_subtree
, i.e.
concat_datatrees = datatree.map_over_subtree(xr.concat) dt_concatenated = concat_datatrees([dt1, dt2], dim='time')
This would still require generalizing map_over_subtree
to understand iterables of DataTree
objects though (see zarr-developers/VirtualiZarr#84 (comment)).
Finally we could just not support this at all, in which case the only way for users to concatenate contents of datatrees node-wise is via something like
ds_concatenated = xr.concat([mytree[node].ds for subtree in mytree], dim="time")
but called for every node in the tree.
Additional contextSee zarr-developers/VirtualiZarr#84 (comment) for an example of wanting to do this in VirtualiZarr
(cc @jonas-spaeth).
This was actually already something we partly discussed in the datatree design meeting (#8747), but I forgot what the conclusion was (do you remember @keewis @flamingbear @owenlittlejohns?).
Checklistapply_ufunc
- Support DataTree in apply_ufunc #9789concat
- Support DataTree in xarray.concat #9778merge
- Support DataTree in xarray.merge #9790align
- Support DataTree in xarray.align #9791broadcast
combine_by_coords
combine_nested
map_blocks
jonas-spaeth, melonora, norlandrhagen, danielfromearth and thgeorgiou
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4