xoa.cf.CFSpecs.search_dim

CFSpecs.search_dim(da, cf_arg=None, loc='any', errors='ignore')[source]

Search a dataarray/dataset for a dimension name according to its generic name or type

First, scan the dimension names. Then, look for coordinates: either it has an ‘axis’ attribute, or it a known CF coordinate.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset) – Coordinate or data array

  • cf_arg (str, {"x", "y", "z", "t", "f"}, None) – One-letter dimension type or generic CF dim name. When set to None, dmension type is inferred with get_axis() applied to obj

  • loc ("any", letter) – Staggered grid location

  • single (bool) – If True, return the first item found or None. If False, return a possible empty list of found items.

  • errors ({'ignore', 'warn', 'raise'}) –

    In case of errors

    • 'ignore': silently ignore

    • 'warn': emit a warning

    • 'raise': raise an exception

Returns:

str, dict, None – Dim name OR, dict with dim, type and cf_name keys if dim_type is None. None if nothing found.