openairclim.utils.config_files
Helpers for creating and inspecting OpenAirClim config files.
- openairclim.utils.config_files.list_nc_data_vars(filepath: Path | str) list[str][source]
List data variable names in a NetCDF file.
Used e.g. to discover the available scenario names inside a background concentration file (e.g. “SSP2-4.5”), which are stored as data variables.
- openairclim.utils.config_files.list_nc_files(directory_path: Path) list[str][source]
List NetCDF filenames in a directory.
- Parameters:
directory_path (Path) – Directory to scan.
- Returns:
Sorted list of
.ncfilenames found, or an empty list if the directory does not exist.- Return type:
- openairclim.utils.config_files.prepare_for_save(config: dict, working_dir: str) dict[source]
Return a copy of config with directory paths made relative.
- openairclim.utils.config_files.resolve_dir(working_dir: str, dir_str: str) Path[source]
Resolve a (possibly relative) directory string against
working_dir.
- openairclim.utils.config_files.to_relative(working_dir: str, absolute_path: str) str[source]
Convert an absolute path to one relative to
working_dir.Uses “..” segments where necessary, so that directories outside
working_dirstill resolve correctly on another machine or OS, as long as their position relative toworking_diris preserved. Falls back to the absolute path unchanged only when no relative path can be computed (e.g. paths on different drives on Windows).