cf-xarray
cf-xarray copied to clipboard
should guess_coord_axis optionally create a variable for unindexed coordinates
da = xr.DataArray(np.ones(2,3), dims=("x", "y"))
This kind of dataarray exists in CMIP datasets. x,y
have absolutely no data (no values, no attrs) associated with them, and so guess_coord_axis
does not do anything.
We could have .cf.guess_coord_axis(add_indexes=True)
that effectively does
da["x"] = np.arange(da.sizes["x"])
da["y"] = np.arange(da.sizes["y"])
# now do the guessing
This will assign axis='X'
and axis='Y'
appropriately. I think this would be an OK opt-in feature, though we need a better name than add_indexes
.
I think such an option is a good idea to maximize the utility of cf-xarray for dealing with messy CMIP data. I suppose there needs to be a check of whether the index arrays exist already. Thanks for considering this!