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

Feature request: Create a Datatree instead of a Dataset when there are groups #64

Closed
bzah opened this issue Jan 4, 2024 · 2 comments · Fixed by #66
Closed

Feature request: Create a Datatree instead of a Dataset when there are groups #64

bzah opened this issue Jan 4, 2024 · 2 comments · Fixed by #66

Comments

@bzah
Copy link
Collaborator

bzah commented Jan 4, 2024

Feature request

When I open a ncml that contains groups and sub-groups, the result is flatten: each variable is added to a single "root" Dataset and the initial hierarchy is lost.
This behavior is different from xarray open_dataset() which will only open the root group (but not subgroups) and, given the group="/data" kwarg, would only open the group "/data".

It would be nice if we could keep the hierarchy in either a DataArray encoding property (like the parent group path of the variable) or, even better, to output a Datatree which would contain all groups and subgroups.

Or should we wait until datatree is merged into xarray before considering this feature ?

Ref

@huard
Copy link
Collaborator

huard commented Jan 8, 2024

My objective is for open_ncml to behave as much as possible as open_dataset.

I don't think I've ever used netCDF groups, so I'll defer to your judgement regarding implementation.

@bzah
Copy link
Collaborator Author

bzah commented Jan 10, 2024

My objective is for open_ncml to behave as much as possible as open_dataset.

Then we could add a group kwarg to open_ncml and only open the selected group, by default opening the root group just like open_dataset.

As I work with datasets with many layered groups, I would also be interested if we can keep the current behavior, maybe with a special flag argument all_group, default to False, which would order to open every group and add the paths in encoding or attrs of the DataArrays.

It might take a long time before Datatree is merged into xarray, hence the above proposal would be a satisfactory solution (for me) until it is merged.

  • I'm willing to work on this (not now, but soon).

@bzah bzah mentioned this issue Jan 16, 2024
2 tasks
@bzah bzah closed this as completed in #66 Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants