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 by cf_xarray.

If obj is an xr.Dataset,, this function can return a single dimension coordinate variable as an xr.DataArray or multiple dimension coordinate variables in an xr Dataset. If obj is an xr.DataArray, this function should return a single dimension coordinate variable as an xr.DataArray.

  • obj (Union[xr.Dataset, xr.DataArray]) – The Dataset or DataArray object.

  • axis (CFAxisKey) – The CF axis key (“X”, “Y”, “T”, “Z”).


Union[xr.Dataset, xr.DataArray] – A Dataset of dimension coordinate variables or a DataArray for the single dimension coordinate variable.

  • ValueError – If the obj is an xr.DataArray and more than one dimension is mapped to the same axis.

  • KeyError – If no dimension coordinate variables were found for the axis.


Multidimensional coordinates are ignored.