-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix writing of DataTree subgroups to zarr or netCDF #9677
base: main
Are you sure you want to change the base?
Conversation
Consider a DataTree with a group, e.g., `tree = DataTree.from_dict({'/': ... '/child': ...})` If we write `tree['/child']` to disk, the result should have groups relative to `'/child'`, so writing and reading from the same path restores the same object. In addition, coordinates defined at the root should be written to disk instead of being omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Too slow for the v2024.10.0 release but this is important so we should release again very soon.
As discussed in the last xarray meeting, this defaults to write_inherited_coords=True, which has a little more overhead but means you always get coordinates when opening a sub-group.
@@ -1609,6 +1610,11 @@ def to_netcdf( | |||
group : str, optional | |||
Path to the netCDF4 group in the given file to open as the root group | |||
of the ``DataTree``. Currently, specifying a group is not supported. | |||
write_inherited_coords : bool, default: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens at read-time? Do we normalize and remove duplicated coords by default? If so, I think we should change so that does not happen by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens at read-time? Do we normalize and remove duplicated coords by default?
Yes, this is what happens.
If so, I think we should change so that does not happen by default.
Can you clarify what you mean here?
Consider a DataTree with a group, e.g.,
tree = DataTree.from_dict({'/': ... '/child': ...})
If we write
tree['/child']
to disk, the result should have groups relative to'/child'
, so writing and reading from the same path restores the same object.In addition, coordinates defined at the root should be written to disk instead of being omitted.