xoa.meta.MetaSpecs.format_dataset

xoa.meta.MetaSpecs.format_dataset#

MetaSpecs.format_dataset(ds, meta_names=None, copy=True, format_coords=True, standardize=True, rename=True, rename_dims=True, specialize=False, attrs=True, replace_attrs=False, rename_args=None)[source]#

Format a whole dataset

Parameters:
  • ds (xarray.Dataset)

  • meta_names (dict, None) – Dict of names as keys and generic meta names as values. If not provided, meta names are guessed with match().

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

    • str: one of these locations

    • None or “any”: any

    • False or ‘””: no location

  • rename (bool) – Rename arrays

  • add_loc_to_name (bool) – Add loc to the name

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

  • standardize (bool)

  • rename_dim (bool) – For a 1D array, rename the dimension if it has the same name as the array. Note that it is set to False, if rename is False.

  • attrs (bool, dict of 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?

  • rename_args (dict, None) – Dictionay to collect args to rename

Returns:

xarray.DataArray, str, None – The formatted array or copy of it. The meta name, given or matching, if rename if False; and None if not matching.