config⚓︎
The configuration boundary: one normalisation and one validation, however a config arrives.
A run is described by three sections -- the problem (dataassim for pipt,
optim for popt), the ensemble and the simulator (fwdsim) --
read from TOML, YAML or the legacy .pipt/.popt text format, or built
as dictionaries in a script. Whichever way they arrive, :func:normalize
turns them into the one form the rest of PET reads: the canonical name where
a key has had several spellings, a boolean where a flag could be yes/no,
a dictionary where a sub-block could be a list of pairs, and the field
conversions (datatype, reportpoint, assimindex) done once. The
result is a copy; nothing downstream sees, or changes, the caller's
dictionaries. :func:validate says what a run would fail on, by section and
key, instead of an assertion or a KeyError somewhere inside a scheme.
ConfigError
⚓︎
Bases: ValueError
A config that cannot run, with every problem listed.
Problem
⚓︎
One thing wrong with a config. fatal problems stop a run at construction.
as_flag(value, default=False)
⚓︎
A boolean from a flag value: booleans as they are, yes/no/true/false strings, else truthiness.
fatal_problems(cfg_prb, cfg_sim=None, cfg_ens=None)
⚓︎
The problems that stop a run at construction.
is_dataassim(problem_section)
⚓︎
Whether the problem section describes a data-assimilation run (else an optimisation).
normalize(cfg_prb, cfg_sim, cfg_ens=None)
⚓︎
All three sections as the rest of PET reads them: field conversions, canonical names, flags, blocks.
Returns (problem, simulator, ensemble); the ensemble is {} when the
config has none (the legacy text format keeps those keys in DATAASSIM).
normalize_dataassim(keys)
⚓︎
The dataassim section in canonical form, as a copy.
normalize_ensemble(keys)
⚓︎
The ensemble section in canonical form, as a copy.
normalize_optim(keys)
⚓︎
The optim section in canonical form, as a copy.
normalize_simulator(keys)
⚓︎
The simulator section in canonical form, as a copy.
pairs_to_dict(entries)
⚓︎
[[key, value], [key], [key, v1, v2]] -> {key: value, key: None, key: [v1, v2]}.
unknown_keys(cfg_prb, cfg_ens=None)
⚓︎
Keys in the two sections PET owns that nothing reads -- usually a misspelling.
validate(cfg_prb, cfg_sim=None, cfg_ens=None)
⚓︎
Everything a run would fail on, by section and key; empty when the config is fine.
Expects normalised sections (see :func:normalize). The ensemble's
requirements are checked when an ensemble section is given or the problem
section carries its keys, as legacy text files do.