openairclim.utils.output_metadata
Functions relating to the OpenAirClim-specific output metadata.
- openairclim.utils.output_metadata.get_metadata(path: str | Path, full: bool = False, recursive: bool = False) dict[str, dict[str, Any]] | dict[str, str][source]
Return OpenAirClim metadata for a file or folder of output/figure files.
Useful for identifying which simulation an output netCDF file or figure belongs to, e.g. when you have a
config_hashbut can’t remember which run it came from.- Parameters:
- Returns:
If
full, maps filename -> metadata for every file found that carries OpenAirClim metadata. If notfull, maps filename ->config_hash.- Return type:
- openairclim.utils.output_metadata.main_get_metadata()[source]
Parse command-line arguments and print/save OpenAirClim metadata.
- openairclim.utils.output_metadata.main_write_config_from_netcdf()[source]
Parse command-line arguments and recover a config from an output file.
- openairclim.utils.output_metadata.read_metadata(path: str | Path) dict[str, Any] | None[source]
Read OpenAirClim metadata from a single output or figure file.
- openairclim.utils.output_metadata.write_config_from_netcdf(nc_path: str | Path, toml_path: str | Path, relative_to: str | Path | None = None) dict[source]
Recover the config embedded in an OpenAirClim output file as TOML.
Useful for replicating a previous simulation if you have the results netCDF file but not the config TOML file. Or, for viewing the config of a previous simulation in a human-readable way.
- Parameters:
nc_path (str or Path) – A netCDF output file written by OpenAirClim, whose global attrs include a
config_jsondump written bygen_sim_metadata().toml_path (str or Path) – Destination path for the recovered config.
relative_to (str or Path, optional) – If given, the config’s directory fields (inventories/background/responses/output/time dir, and inventories.base.dir) are rewritten relative to this directory, rather than being left as absolute files. See also
prepare_for_save().
- Returns:
The configuration written to
toml_path.- Return type:
- Raises:
KeyError – If
nc_pathcarries no embedded config metadata.