xoa.cf.CFCoordSpecs.format_dataarray
- CFCoordSpecs.format_dataarray(da, cf_name=None, rename=True, specialize=False, loc=None, attrs=True, standardize=True, replace_attrs=False, copy=True)
Format a DataArray’s name and attributes
- Parameters:
da (xarray.DataArray) –
cf_name (str, None) – A generic CF name. If not provided, it 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 when their name is set?
add_loc_to_name (None, bool) – Add the loc to the name, overriding the specs.
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?
standardize (bool) –
specialize (bool) – Do not use the CF name for renaming, but the value of the “name” entry, which is generally a specialized one, like a name adopted by specialized dataset.
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.copy (bool) – Force a copy (not of the data) in any case?
- Returns:
xarray.DataArray, str, None – The formatted array or copy of it. The CF name, given or matching, if rename if False; and None if not matching.