fre.yamltools.helpers module

this holds functions widely used across various parts of fre/yamltools

fre.yamltools.helpers.clean_yaml(yml_dict)

Clean the yaml; remove unnecessary sections in final combined yaml.

Parameters:

yml_dict (dict) – dictionary of YAML content

Returns:

cleaned dictionary of YAML content

Return type:

dict

..note:: Keys (along with associated values) that are removed from the combined YAML file include

those that are no longer necessary for parsing of information (post-yaml-combination)

fre.yamltools.helpers.experiment_check(mainyaml_dir, experiment, loaded_yaml)

Check that the experiment given is an experiment listed in the model yaml. Extract experiment specific information and file paths.

Parameters:
  • mainyaml_dir (str) – Model YAML file

  • experiment (str) – Post-processing experiment name

  • loaded_yml (dict) – dictionary of YAML content

Raises:
  • NameError – if the experiment name passed is not in the list of experiments in the model YAML configuration

  • ValueError

    • if no experiment YAML path was defined in the model YAML

    • if the experiment YAML does not exist

    • if incorrect analysis YAML paths were given or analysis YAML path does not exist

Returns:

  • ey_path: array of pp YAML paths associated with the experiment being

    post-processed

  • ay_path: array of analysis YAML paths associated with the experiment being

    post-processed

Return type:

array

fre.yamltools.helpers.output_yaml(cleaned_yaml, output)

Write out the combined yaml dictionary info to a file if –output is specified

Parameters:
  • cleaned_yaml (dict) – dictionary of combined YAML content

  • output (str) – name of output file

fre.yamltools.helpers.validate_yaml(yaml, schema_path)

Validate yaml information

Parameters:
  • yaml (dict) – dictionary of combined YAML content

  • schema_path (str) – path to the json configuration file located in gfdl_msd_schemas used to validate the YAML configuration

Raises:

ValueError – if the YAML dictionary is not valid after combining YAML information

Returns:

True if YAML validation is successful

Return type:

bool

fre.yamltools.helpers.yaml_load(yamlfile)

Load the yamlfile; deserializes YAML file into a usable python object

Parameters:

yamlfile (str) – Path to YAML configuration file

Returns:

dictionary of YAML content

Return type:

dict