Discrete Sampling Geometries#
cf_xarray
supports identifying variables by the cf_role
attribute.
ds = xr.Dataset(
{"temp": ("x", np.arange(10))},
coords={"cast": ("x", np.arange(10), {"cf_role": "profile_id"})}
)
ds.cf
Discrete Sampling Geometry:
CF Roles: profile_id: ['cast']
Coordinates:
CF Axes: X, Y, Z, T: n/a
CF Coordinates: longitude, latitude, vertical, time: n/a
Cell Measures: area, volume: n/a
Standard Names: n/a
Bounds: n/a
Grid Mappings: n/a
Data Variables:
Cell Measures: area, volume: n/a
Standard Names: n/a
Bounds: n/a
Grid Mappings: n/a
Access "cast"
using it’s cf_role
ds.cf["profile_id"]
<xarray.DataArray 'cast' (x: 10)> 0 1 2 3 4 5 6 7 8 9 Dimensions without coordinates: x Attributes: cf_role: profile_id
Find all cf_role
variables using Dataset.cf.cf_roles
and DataArray.cf.cf_roles
ds.cf.cf_roles
{'profile_id': ['cast']}