-
Notifications
You must be signed in to change notification settings - Fork 3
Description
xarray doesn't automatically handle coordinates with names that are different to the dimension they index. xarray doesn't handle multi-dimensional coordinates well. A convention has sufficient information to update a dataset to set the coordinates. We should add a new method that does just this:
ds = emsarray.open_dataset(...)
ds = ds.ems.set_coords()Questions:
Should this happen automatically? Difficult, as there is no hook to mutate a dataset on open if it was opened through plain xarray instead. This would make the behaviour inconsistent depending on where the dataset came from, requiring code to call this again anyway to guarantee coordinates were set.
As Dataset.set_coord() returns a new dataset, the new dataset wouldn't have an associated Convention. Boo. Can we copy the convention, or share it between datasets, or...? Downsides of not reusing the convention are mostly performance (needing to recalculate polygons, detect coordinate variables, etc), and loosing any Convention customisations (e.g. providing initial arguments to the Convention to supply a topology helper).
Which coordinates should be used? Time, depth, horizontal coordinates at a minimum.
Perhaps the method should be Convention.all_coordinates() and Convention.append_coordinates()? Dataset.set_coords() will remove any unlisted coordinates (I think? need to verify) so we probably want to extend any coordinates present on the dataset.