-
Notifications
You must be signed in to change notification settings - Fork 41
Tree-aware dataset handling/selection #254
Comments
|
Thanks for your comments! I also thought about the restructuring of the datatree similar to your point 3 and think it would be a nice addition. For this particular case I like 1 a bit more because it also allows for data trees with different depths. |
I have been thinking about adding similar functions for a while, thanks to both of you for laying out your ideas clearly! In fact your two-level-combinatoric tree structure @observingClouds is the same thing @jbusecke and I discussed in #186.
I agree this could be useful, but it's a shortcut for the more obvious
I can also see this being useful, but I'm not totally sure what exact behavior you're after from your description. Does it return
@dcherian I think this suggestion of taking input in symbolic form might solve the ambuigities @jbusecke and I discussed in #186. The main questions I would have is what to do with nodes that don't have exactly 2 levels, i.e. @observingClouds your |
Actually the simplest "searching" utility would be use glob, not regex. Added in #267. |
Raise and error! there's an implied minimum depth necessary to do this? |
Right, but what if some nodes have this depth and others don't? I'm thinking of something heterogenous like:
Actually I guess in this particular case the user would just need to apply the operation to the Thinking aloud more, @jbusecke 's CMIP6 case would look like:
which after
which seems fine |
deeper than the symbolic depth is fine AFAICT. |
Is it? If I have You could imagine maybe supporting something like EDIT: Or maybe you call the method EDIT2: Or maybe use a flag: |
Personally i'd just expect |
Well I personally would have expected the opposite 🤣
I think this could be a good solution:
|
Another idea: use preceding slashes to distinguish the two cases, i.e. This has all the advatages of the the previous suggestion, but is more filesystem-like, doesn't require an extra kwarg, and allows moving nodes from root to leaves (e.g. |
I would suggest |
Here's my list of helper utilities: https://github.com/dcherian/dcpy/blob/master/dcpy/datatree.py I found them all quite useful, but obviously there's little error checking :) and it does assume trees with a nicely balanced structure,. |
Thanks @dcherian !
I think I get it now - that does seem potentially useful!
What's the input type for
I suspect you might be talking about a concept I've been referring to as a "hollow tree". I'll raise a separate issue for that. |
it expects a list of node names : e.g. |
closed in favor of pydata/xarray#9346 |
I'm looking for a good way to apply a function to a subset of nodes that share some common characteristics encoded in the subtree path.
Imagine the following data tree
To apply a function to all
control
or allplus4K
nodes is straight forward by just selecting the specific subtree, e.g.dt['control']
. However, in case alllowRes
dataset should be manipulated this becomes more elaborative and I wonder what the best approach would be.dt['control/lowRes','plus4K/lowRes']
is not yet implemented and would also be complex for large data treesdt['*/lowRes']
could be one idea to make the subtree selection more straight forward, where*
is a wildcarddt.search(regex)
could make this even more generalCurrently, I use the @map_over_subtree decorator, which also has some limitations as the function does not know its tree origin (as noted in the code) and it needs to be inferred from the dataset itself, which is sometimes possible (here the length of the dataset) but does not need to be always the case.
I do not know how the tree information could be passed through the decorator, but maybe it is okay if the
DatasetView
class has an additional property (e.g._path
) that could be filled withdt.path
during the call of DatasetView._from_node()?. This would lead toand would allow for tree-aware manipulation of the datasets.
What do you think? Happy to open a PR if this makes sense.
The text was updated successfully, but these errors were encountered: