xoa.cf.CFSpecs¶
- class xoa.cf.CFSpecs(cfg=None, default=True, user=True, name=None, cache=None)[source]¶
Manager for CF specifications
CF specifications are defined here an extension of a subset of CF conventions: known variables and coordinates are described through a generic name, a specialized name, alternates names, some properties and attributes like standard_name, long_name, axis.
Have a look to the default specifications and to the Naming conventions with xoa.cf section.
- Parameters
cfg (str, list, CFSpecs, dict) – A config file name or string or dict or CF Specs, or a list of them. It may contain the “data_vars”, “coords” and “sglocator” sections. When a list is provided, specs are merged with the firsts having priority over the lasts.
default (bool) – Load also the default internal specs
user (bool) – Load also the user specs stored in
USER_CF_FILEname (str, None) – Assign a shortcut name. It defaults the the [register] name option of the specs.
cache (bool) – Use in-memory cache system?
See also
CFCoordSpecs,CFVarSpecs,SGLocator, Naming conventions with xoa.cf, The default configuration- __init__(cfg=None, default=True, user=True, name=None, cache=None)[source]¶
Initialize self. See help(type(self)) for accurate signature.
Methods
auto_format(dsa, **kwargs)Rename variables and coordinates and fill their attributes
copy()decode(dsa, **kwargs)Auto format, infer coordinates and rename to generic names
encode(dsa, **kwargs)Same as
decode()but rename with the specialized namefill_attrs(dsa, **kwargs)Fill missing attributes of a xarray.Dataset or xarray.DataArray
format_coord(da[, name, loc, copy, …])Format a coordinate array
format_data_var(da[, name, rename, …])Format array name and attributes according to currents CF specs
format_dataset(ds[, loc, rename, …])Auto-format a whole xarray.Dataset
get(dsa, name[, get])A shortcut to
search()with an explicit nameget_axis(coord[, lower])Get the dimension type, either from axis attr or from match Cf coord
get_category(da)Guess if a datarray belongs to data_vars or coords
get_dim_type(dim[, da, lower])Get the type of a dimension
get_dim_types(da[, unknown, asdict])Get a tuple of the dimension types of an array
get_dims(da, dim_types[, allow_positional, …])Get the data array dimensions names from their type
get_loc(da)Get the staggered grid location from name and standard_name
get_location(da)Get the staggered grid location from name and standard_name
get_name()infer_coords(ds)Search for known coords and make sure they are set as coords
load_cfg([cfg, cache])Load a single or a list of configurations
match(da[, loc])Check if an array matches any data_var or coord specs
match_coord(da[, name, loc])Check if an array matches a given or any coord specs
match_data_var(da[, name, loc])Check if an array matches given or any data_var specs
parse_dims(dims, dsa)pprint(**kwargs)Pretty print the specs as dict using
pprint.pprint()search(dsa[, name, loc, get, single, …])Search for a dataarray with data_vars and/or coords
search_coord(dsa[, name, loc, get, single, …])Search for a coord that maches given or any specs
search_coord_from_dim(da, dim[, errors])Search a dataarray for a coordinate from a dimension name
search_data_var(dsa[, name, loc, get, …])Search for a data_var that maches given or any specs
search_dim(da[, dim_type, loc, errors])Search a dataarray for a dimension name according to its type
set_name(name)set_specs(category, name, **specs)Update or create specs for an item
set_specs_from_cfg(cfg)Update or create specs from a config
Attributes
List of cf specs categories
Specifications for coords
CFCoordSpecsSpecification for data_vars
CFVarSpecsDictionary copy of the specs
Dictionary of dims per dimension type within x, y, z, t and f
Name
SGLocatorinstance