act.utils.convert_2d_to_1d

act.utils.convert_2d_to_1d(ds, parse=None, variables=None, keep_name_if_one=False, use_dim_value_in_name=False, dim_labels=None)[source]

Function to convert a single 2D variable into multiple 1D variables using the second dimension in the new variable name.

Parameters:
  • ds (xarray.dataset) – Object containing 2D variable to be converted

  • parse (str or None) – Coordinate dimension name to parse along. If set to None will guess the non-time dimension is the parse dimension.

  • variables (str or list of str) – Variable name or names to parse. If not provided will attempt to parse all two dimensional variables with the parse coordinate dimension.

  • keep_name_if_one (boolean) – Option to not modify the variable name if the coordinate dimension has only one value. Essentially converting a 2D (i.e. (100,1) variable into a 1D variable (i.e. (100)).

  • use_dim_value_in_name (boolean) – Option to use value from the coordinate dimension in new variable name instead of indexing number. Will use the value prepended to the units of the dimension.

  • dim_labels (str or list of str) – Allows for use of custom label to append to end of variable names

Returns:

  • A new object copied from input object with the multi-dimensional

  • variable split into multiple single-dimensional variables.

Example

# This will get the name of the coordinate dimension so it does not need to # be hard coded. >>> parse_dim = (list(set(list(ds.dims)) - set([‘time’])))[0]

# Now use the parse_dim name to parse the variable and return new object. >>> new_ds = convert_2d_to_1d(ds, parse=parse_dim)