Open blaylockbk opened 1 year ago
Hi Brian, thanks for reporting this. Unfortunately I think this simply isn't implemented yet.
If you're interested in the details: Currently DataTree.coords
returns a DatasetCoordinates
object here. The DatasetCoordinates
class is defined in xarray here, and points back to a Dataset
object, whose contents it is able to alter. However in datatree the dataset object pointed back to is created via DataTree.to_dataset()
, which (purposefully) creates a new Dataset
object that is unconnected to the DataTree. This issue is thus somewhat related to the discussion in https://github.com/xarray-contrib/datatree/issues/80.
At some point I will try to make this work (so thanks again for raising this issue so I don't forget!), but probably not particularly soon. In the meantime I suggest using .assign_coords
/.set_coords
or just manually altering the underlying dataset and re-assigning it via .ds
.
Thanks for the details. I'll use assign_coords in the meantime. Thanks again for datatree, it has made opening some hdf5 files much easier.
I opened an HDF5 file with datatree and tried to add a new coordinate...
There are still no coordinates...![image](https://user-images.githubusercontent.com/6249613/234958505-d7a099a1-22f1-43fb-9464-42800977656e.png)
And when I do
dt.GROUPNAME.coords
, I get an errorBut if I convert it to a Dataset, then assigning coords works as expected...
And the value of
a.coords
isThis is possibly some user error, but I was expecting to see the same behavior as a xarray.dataset.