Closed huard closed 11 months ago
Can you provide an example please
@dcherian An example would be
import cf_xarray
from cf_xarray import datasets
bnds_dim = datasets.vert.cf.get_bounds_dim_name('longitude')
which leads to the problem described above.
Just also encounterd this problem, seems that cfxarray recognizes the bounds coordinates, e.g., in datasets.vert
, as longitude/latitude coordinates since they have the units
attribute defined as `degress*`, e.g.,
from cf_xarray.datasets import vert
vert.cf
...
CF Coordinates: longitude: ['lon', 'lon_bnds']
latitude: ['lat', 'lat_bnds']
* time: ['time']
vertical: n/a
...
That's why the mapper with the longitude
key returns both values, hence the too many values to unpack
...
After dropping the units attribute, it works:
from cf_xarray.datasets import vert
# this works
vert.cf.get_bounds_dim_name('lon')
# using standard name fails
#vert.cf.get_bounds_dim_name('longitude')
# dropping the units attribute in the bounds works
vert_drop = vert.copy()
del vert_drop.lon_bnds.attrs['units']
vert_drop.cf.get_bounds_dim_name('longitude')
I wonder, if we could switch back to using the accessor itself, e.g., something like this?
crd = self._obj.cf[key]
bounds = self._obj.cf.get_bounds(key)
That would work, although i am still not sure, if those bounds should appear in the CF Coordinates print above?
I wonder, if we could switch back to using the accessor itself, e.g., something like this?
This ends up being a quadratic loop over variables. This bug stems from my removing that quadratic loop :)
Thanks !
This change in 0.8.1 seems problematic.
If the returned list has more than one item, it will raise a ValueError:
In my particular case, the returned value is
['lon_bounds', 'lon']
.