xcdat.get_dim_coords#
- xcdat.get_dim_coords(obj, axis)[source]#
Gets the dimension coordinates for an axis.
This function uses
cf_xarrayto attempt to map the axis to its dimension coordinates by interpreting the CF axis and coordinate names found in the coordinate attributes. Refer to [1] for a list of CF axis and coordinate names that can be interpreted bycf_xarray.If
objis anxr.Dataset,, this function can return a single dimension coordinate variable as anxr.DataArrayor multiple dimension coordinate variables in anxr Dataset. Ifobjis anxr.DataArray, this function should return a single dimension coordinate variable as anxr.DataArray.- Parameters:
obj (
xr.Dataset | xr.DataArray) – The Dataset or DataArray object.axis (
CFAxisKey) – The CF axis key (“X”, “Y”, “T”, “Z”).
- Returns:
xr.Dataset | xr.DataArray– A Dataset of dimension coordinate variables or a DataArray for the single dimension coordinate variable.- Raises:
ValueError – If the
objis anxr.DataArrayand more than one dimension is mapped to the same axis.KeyError – If no dimension coordinate variables were found for the
axis.
Notes
Multidimensional coordinates are ignored.
References