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_classis aTransportConfigwhose fields use none ofRESERVED_SETTINGS, andmet_config_classa pydantic model;the record
config.settings()writes is plain data, andconfig_classreads it back to a config with the same record: a stored settings folder is found that way; and so for each configconfig.realizations(3)returns, unless it refuses with aValueError;sha256,versionanddata_filesmake aModelInfo(sha256may raiseFileNotFoundErrorwhen 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, andrun_manytoo for a batched model), and checks the result. A result of a type other than particles (the model’sresult) is checked by its type and stored and read back. Particles are checked further: the columns of the particle table, ages that go the wayn_hoursdoes and stay within it, the release heights of a column or multipoint release (from a row atage = 0or the model’srelease_rows), and a particle file that stores every column. A model’scheck_releasesmust return its table’s columns in order; when it refuses release, the run must fail asRELEASE_REFUSED, and nothing is run. Run it with a point, a column and a multipoint release to cover each.- Raises:
AssertionError – Saying which promise is broken.
SimulationError – If the run fails, as it would in a project.
- Return type:
- Parameters:
model (TransportModel)
config (TransportConfig)
met (Any)
release (TypeAliasForwardRef('runtraj.releases.Release') | None)
Examples
>>> from runtraj.models import check_model >>> from runtraj.models.hysplit import HysplitConfig, HysplitModel >>> check_model(HysplitModel(), HysplitConfig(n_hours=-24))