Closed keewis closed 10 months ago
s the dataset just not complying to the CF conventions
It's the other way, this is where Xarray's data model is too simple to keep up, parrticularly the restriction that we cannot add arbitrary new dimensions to a DataArray. I proposed relaxing this for Indexes, but not in general.
s should we change the way ds.cf[axis] and ds.cf[[axis]] work (for example, make ds.cf[axis] return a Dataset and ds.cf[[axis]] a DataArray, or the other way around)?
No. An old version of cf-xarray did this and I removed it quite quickly. We really want type-stability on the return value, and we want to match Xarray's behaviour.
In any case, If we returned a Dataset
with x
and position
, how would you know which was X
? You could use cf.axes["X"][0]
I guess, but that's too wordy.
> for k1 in coords:
--> 846 da.coords[k1] = ds.variables[k1]
I think we should check dimensions here before assignment, and silently drop positions
. It'd be nice to add a logger
integration so that we can record such things.
For a dataset similar to this:
getting a single coordinate by axis fails:
which makes sense, because
position_flag
has a different dimension thanx
(usingds.cf[["X"]]
works as expected because that ignores the ancillary variables).Am I doing something wrong, is the dataset just not complying to the CF conventions (I don't know enough to be able to tell), or should we change the way
ds.cf[axis]
andds.cf[[axis]]
work (for example, makeds.cf[axis]
return aDataset
andds.cf[[axis]]
aDataArray
, or the other way around)?