openairclim.core.config_model

Pydantic schema for the TOML configuration file. Single source of truth for required/optional keys, defaults, and valid option strings (e.g. RF methods, attribution methods).

This file provides structural validation only. Checks that depend on input files, aircraft parameters etc. are in read_config.py.

Config, AircraftEntry and AircraftCsvRow are the only public classes. Config’s sections are implemented similarly to the TOML tree. Callers outside of this module should resolve the values by walking Config.model_fields (dotted TOML path) rather than importing them directly, so that they track the config’s actual shape instead of this file’s internal class names. The AircraftEntry and AircraftCsvRow classes are dynamically keyed and hence cannot be reached via model_fields.

openairclim.core.config_model.ALIAS_MAP = {'output.full_run': 'output.run_oac'}

Maps deprecated config keys to their replacement, applied before validation so renamed keys keep working in old config files.

class openairclim.core.config_model.AircraftCsvRow(*, b: Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=20.0), Le(le=80.0)])] | None = None, PMrel: float | None = None, G_250: float | None = None, SAC_eq: Literal['CON', 'HYB', 'H2C', 'H2FC'] | None = None, Q_h: float | None = None, eta: float | None = None, eta_elec: float | None = None, EIH2O: float | None = None, R: float | None = None, PM: float | None = None, ac: str)[source]

Bases: AircraftEntry

One row of the aircraft csv file: AircraftEntry’s fields plus the aircraft identifier column, and pandas’ NaN/blank-string “missing” convention mapped to None before AircraftEntry’s own field validation/derivation runs (which expects None.)

ac: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class openairclim.core.config_model.AircraftEntry(*, b: Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=20.0), Le(le=80.0)])] | None = None, PMrel: float | None = None, G_250: float | None = None, SAC_eq: Literal['CON', 'HYB', 'H2C', 'H2FC'] | None = None, Q_h: float | None = None, eta: float | None = None, eta_elec: float | None = None, EIH2O: float | None = None, R: float | None = None, PM: float | None = None)[source]

Bases: BaseModel

Aircraft-specific parameters, defined in-line in the config (config[“aircraft”][<ac_id>]) or in a row of a linked csv file.

Aircraft identifiers are required if the emission inventories have an ac data variable. In addition, the parameters b (wingspan [m]), PMrel (nvPM emissions relative to 1.5e15 kg⁻¹) and G_250 (slope of the Schmidt-Appleman mixing line at 250 hPa [Pa/K]) are required if contrails are being calculated (i.e. “cont” in config[“species”][“out”]). These parameters can also be calculated using sub-values, defined in AIRCRAFT_DERIVATION_MAP.

Field declaration order matches the aircraft csv column order, but is not important.

EIH2O: float | None
G_250: float | None
PM: float | None
PMrel: float | None
Q_h: float | None
R: float | None
SAC_eq: Literal['CON', 'HYB', 'H2C', 'H2FC'] | None
b: Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=20.0), Le(le=80.0)])] | None
eta: float | None
eta_elec: float | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class openairclim.core.config_model.Config(*, species: _SpeciesConfig, inventories: _InventoriesConfig, output: _OutputConfig, time: _TimeConfig, background: _BackgroundConfig, responses: _ResponsesConfig, temperature: _TemperatureConfig = <factory>, metrics: _MetricsConfig = <factory>, aircraft: _AircraftConfig, parametric: _ParametricConfig = <factory>)[source]

Bases: BaseModel

Provides a pydantic data skeleton for a valid OpenAirClim configuration. Set up to match the TOML file structure.

Raises:

ValueError – If there are errors with the climate metrics definitions

aircraft: _AircraftConfig
background: _BackgroundConfig
inventories: _InventoriesConfig
metrics: _MetricsConfig
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

output: _OutputConfig
parametric: _ParametricConfig
responses: _ResponsesConfig
species: _SpeciesConfig
temperature: _TemperatureConfig
time: _TimeConfig
openairclim.core.config_model.validate_config(config: dict) dict[source]

Validate a raw config dict against the schema and fill in defaults.

Parameters:

config (dict) – Configuration dictionary, as loaded from TOML.

Returns:

Configuration dictionary with structure/types validated,

deprecated keys migrated, and defaults filled in.

Return type:

dict