xcdat.get_dim_coords#
- xcdat.get_dim_coords(obj, axis)[source]#
Gets the dimension coordinates for an axis.
This function uses
cf_xarray
to 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
obj
is anxr.Dataset,
, this function can return a single dimension coordinate variable as anxr.DataArray
or multiple dimension coordinate variables in anxr Dataset
. Ifobj
is anxr.DataArray
, this function should return a single dimension coordinate variable as anxr.DataArray
.- Parameters:
obj (
Union[xr.Dataset
,xr.DataArray]
) – The Dataset or DataArray object.axis (
CFAxisKey
) – The CF axis key (“X”, “Y”, “T”, “Z”).
- Returns:
Union[xr.Dataset
,xr.DataArray]
– A Dataset of dimension coordinate variables or a DataArray for the single dimension coordinate variable.- Raises:
ValueError – If the
obj
is anxr.DataArray
and 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