Find the root and group name of a netCDF4/h5netcdf dataset.
(ds)
| 250 | |
| 251 | |
| 252 | def find_root_and_group(ds): |
| 253 | """Find the root and group name of a netCDF4/h5netcdf dataset.""" |
| 254 | hierarchy = () |
| 255 | while ds.parent is not None: |
| 256 | hierarchy = (ds.name.split("/")[-1],) + hierarchy |
| 257 | ds = ds.parent |
| 258 | group = "/" + "/".join(hierarchy) |
| 259 | return ds, group |
| 260 | |
| 261 | |
| 262 | def collect_ancestor_dimensions(group) -> dict[str, int]: |