Comments (5)
Continuing from related discussion in https://discourse.pangeo.io/t/xarray-and-collections-of-forecasts/3054/6
It would also be helpful to have it on .sel
for my usage.
I haven't dug around in the guts of datatree enough to understand how it's mapping functions to each group, but would it be possible to add a missing_dims
kwarg at the mapping level? Then use it to decide if to catch KeyError
s from the underlying dataset methods or not?
If I'm understanding things right, Datatree
uses a mixin (MappedDatasetMethodsMixin
) to manage mapping methods to datasets. Could map_over_subtree
pick missing_dims
off the kwargs?
from datatree.
Hi @abkfenris !
datatree.mapping
is where the guts of the mapping occurs. The mixin just steals certain methods from xarray.Dataset
and wraps them with map_over_subtree
. The mapping code is basically just this:
def map_over_subtree(func, dt, *args, **kwargs):
new_tree = ...
for node in dt.subtree
result_ds = func(node.ds, *args, **kwargs)
new_tree[node.path] = result_ds
but generalised to potentially map over multiple trees simultaneously (e.g. for binary operations like __add__
), with error checking, and usable as a decorator.
would it be possible to add a missing_dims kwarg at the mapping level?
We could, but missing_dims
wouldn't make sense for every function we might map - that's the challenge here. That's why I suggested we might want to add something to map_over_subtree
that allows you to ignore any KeyError
? Or another approach would be to modify .sel
upstream.
from datatree.
I wonder if ignoring KeyError
might be too broad and could catch more than intended (I'm thinking Dask or fsspec KeyError
s bubbling up). Might be worth exploring getting more tightly defined errors upstream.
from datatree.
from datatree.
See pydata/xarray#8949 for a much more thought-out solution to this problem
from datatree.
Related Issues (20)
- Tree linkage + dataset in one object nonideal for UI tree view HOT 6
- v0.0.14 not on pypi HOT 1
- setting node name breaks tree linkage HOT 7
- When creating a DataTree from a Dataset with path-like variable, subgroups are expected to be created HOT 7
- Actually you're right, I don't know if the docs currently mention anywhere that assigning to `.ds` is allowed!
- Typing: `DataTree[Unknown]`
- `drop_vars` issue?
- Creating DataTree from DataArrays
- Opening a datatree from S3 bucket HOT 1
- Typing issue: Pylance complains with DataTree inequalities HOT 1
- open_datatree() keeps the hdf file open preventing writes HOT 1
- open_datatree() from zarr creates issues with `kwargs` HOT 4
- `open_datatree` performance HOT 2
- decision analysis in datatree?
- Collapse by default the "Attributes" section in rich display
- Add an `attrs` keyword argument to the constructor: `DataTree(attrs={})`
- Describe a DataTree: adidng visualization and summarization capabilities
- Rich display width is broken HOT 4
- Auto-plotting capabilities
- Loosing attributes with .chunk and .pad
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatree.