fre.cmor.cmor_config module

CMOR YAML Configuration Generator

This module powers the fre cmor config command, generating a CMOR YAML configuration file that fre cmor yaml can consume. It scans a post-processing directory tree for available components and time-series data, cross-references found variables against MIP tables, and produces the structured YAML needed for CMORization.

Functions

  • cmor_config_subtool(...)

Note

This module was derived from quick_script.py prototyping work.

fre.cmor.cmor_config.cmor_config_subtool(pp_dir: str, mip_tables_dir: str, mip_era: str, exp_config: str, output_yaml: str, output_dir: str, varlist_dir: str, freq: str = 'monthly', chunk: str = '5yr', grid: str = 'g99', overwrite: bool = False, calendar_type: str = 'noleap')

Generate a CMOR YAML configuration file from a post-processing directory tree.

Scans pp_dir for pp-component directories, cross-references found variables against MIP tables, writes per-component variable lists, and emits a structured YAML that fre cmor yaml can later consume.

Parameters:
  • pp_dir (str) – Root post-processing directory containing per-component subdirectories.

  • mip_tables_dir (str) – Directory containing MIP table JSON files.

  • mip_era (str) – MIP era identifier, e.g. ‘cmip6’ or ‘cmip7’.

  • exp_config (str) – Path to JSON experiment/input configuration file expected by CMOR.

  • output_yaml (str) – Path to write the output CMOR YAML configuration.

  • output_dir (str) – Root output directory for CMORized data.

  • varlist_dir (str) – Directory in which per-component variable list JSON files are written.

  • freq (str) – Temporal frequency string, e.g. ‘monthly’, ‘daily’. Default ‘monthly’.

  • chunk (str) – Time chunk string, e.g. ‘5yr’, ‘10yr’. Default ‘5yr’.

  • grid (str) – Grid label anchor name, e.g. ‘g99’, ‘gn’. Default ‘g99’.

  • overwrite (bool) – If True, overwrite existing variable list files. Default False.

  • calendar_type (str) – Calendar type string, e.g. ‘noleap’, ‘360_day’. Default ‘noleap’.

Raises:
  • FileNotFoundError – If pp_dir or mip_tables_dir do not exist.

  • ValueError – If no MIP tables are found after filtering.

Returns:

Path to the written output YAML file.

Return type:

str