dsbuilder.template_util module

Utilities for creating template xarray datasets

class dsbuilder.template_util.TemplateUtil

Bases: object

Class to create template xarray datasets

static add_metadata(ds, metadata)

Adds metadata to dataset

Parameters
  • ds (Dataset) – dataset

  • metadata (Dict) – dictionary of dataset metadata

Return type

Dataset

Returns

dataset with updated metadata

static add_variables(ds, variables_dict, dim_sizes_dict)

Adds defined variables dataset

Parameters
  • ds (Dataset) – dataset

  • variables_dict (Dict[str, Dict]) – dictionary defining variables, see the variables definition section of the user guide for more information.

  • dim_sizes_dict (Dict[str, int]) – entry per dataset dimension with value of size as int

Return type

Dataset

Returns

dataset with defined variables

dsbuilder.template_util.create_template_dataset(variables_dict, dim_sizes_dict, metadata=None)

Returns template dataset

Parameters
  • variables_dict (Dict[str, Dict]) – dictionary defining variables, as defined below.

  • dim_sizes_dict (Dict[str, int]) – dataset dimension sizes

  • metadata (Optional[Dict]) – dictionary of dataset metadata

Return type

Dataset

Returns

template dataset

For the variables_dict each key/value pair defines one variable, where the key is the variable name and the value is a dictionary with the following entries:

  • "dtype" (np.typecodes/str) - variable data type, either a numpy data type or special value "flag" for flag variable

  • "dim" (list) - list of variable dimension names

  • "attributes" (dict) - (optional) variable attributes

  • "encoding" (dict) - (optional) variable encoding.

For more information on the required form of these entries, see the variables definition section of the user guide.