runtraj.models.check_model#

runtraj.models.check_model(model, config, met=None, release=None)[source]#

Check that model keeps the promises runtraj relies on, for one config.

Call it from the tests of a transport model of your own, as runtraj.stages.check_stage() is for a stage. It checks that:

  • config_class is a TransportConfig whose fields use none of RESERVED_SETTINGS, and met_config_class a pydantic model;

  • the record config.settings() writes is plain data, and config_class reads it back to a config with the same record: a stored settings folder is found that way; and so for each config config.realizations(3) returns, unless it refuses with a ValueError;

  • sha256, version and data_files make a ModelInfo (sha256 may raise FileNotFoundError when the build is not on this machine).

With a release and its met (of met_config_class), it also runs the model once, through the code a project’s run uses (run, and run_many too for a batched model), and checks the result. A result of a type other than particles (the model’s result) is checked by its type and stored and read back. Particles are checked further: the columns of the particle table, ages that go the way n_hours does and stay within it, the release heights of a column or multipoint release (from a row at age = 0 or the model’s release_rows), and a particle file that stores every column. A model’s check_releases must return its table’s columns in order; when it refuses release, the run must fail as RELEASE_REFUSED, and nothing is run. Run it with a point, a column and a multipoint release to cover each.

Raises:
Return type:

None

Parameters:

Examples

>>> from runtraj.models import check_model
>>> from runtraj.models.hysplit import HysplitConfig, HysplitModel
>>> check_model(HysplitModel(), HysplitConfig(n_hours=-24))