xsimlab.index(dims, global_name=None, groups=None, description='', attrs=None, encoding=None)

Create a variable aimed at indexing data.

The process class in which this variable is declared should set its value (i.e., intent=’out’) with an index object or an index-compatible object. For example, xarray may accept 1-d arrays, pandas.Index, pandas.MultiIndex, etc.

As a simple example, index variable(s) should be used for setting coordinate labels along the dimension(s) of a cartesian grid.

  • dims (str or tuple or list, optional) – Dimension label(s) of the variable. A string or a 1-length tuple corresponds to a 1-d variable and a n-length tuple corresponds to a n-d variable. A list of str or tuple items may also be provided if the variable accepts different numbers of dimensions. Note that an index variable does not accept scalar values.

  • global_name (str, optional) – Name that may be used to retrieve this variable from other processes in a model with global_ref() (model-wise implicit reference). This name must be unique among all global names found in a model.

  • groups (str or list, optional) – Variable group(s).

  • description (str, optional) – Short description of the variable.

  • attrs (dict, optional) – Dictionnary of additional metadata (e.g., standard_name, units, math_symbol…).

  • encoding (dict, optional) – Dictionary specifying how to encode this variable’s data into a serialized format (i.e., as a zarr dataset). Currently used keys include ‘dtype’, ‘compressor’, ‘fill_value’, ‘order’, ‘filters’ and ‘object_codec’. See zarr.creation.create() for details about these options. Other keys are ignored.

See also