xoa.cf.CFSpecs.format_data_var

CFSpecs.format_data_var(da, name=None, rename=True, specialize=False, attrs=True, replace_attrs=False, format_coords=True, coords=None, loc=None, standardize=True, copy=True, add_loc_to_name=None, coord_add_loc_to_name=None, rename_dims=True)[source]

Format array name and attributes according to currents CF specs

Parameters
  • da (xarray.DataArray) –

  • name (str, None) – CF name. If None, it is guessed.

  • loc (str, {"any", None}, {"", False}) –

    • str: one of these locations

    • None or “any”: any

    • False or ‘””: no location

  • rename (bool) – Not only format attribute, but also rename arrays, thus making a copies.

  • add_loc_to_name (bool) – Add loc to the name

  • coord_add_loc_to_name (bool) – Add loc to the coordinates name

  • specialize (bool) – Does not use the CF name for renaming, but the first name as listed in specs, which is generally a specialized one, like a name adopted by specialized dataset.

  • rename_dims – Also rename dimensions that are not coordinates

  • attrs (bool, dict) – If False, does not change attributes at all. If True, use Cf attributes. If a dict, use this dict.

  • replace_attrs (bool) – Replace existing attributes?

  • format_coords (bool) – Also format coords.

  • coords (dict, None) – Dict whose keys are coord names, and values are CF coord names. Used only if format_coords is True.

  • standardize (bool) –

  • copy (bool) – Make sure to work on a copy of the array. Note that a copy is always returned when rename is True.

Returns

xarray.DataArray – Formatted array