Exceptions#

Every exception runtraj raises is a runtraj.RuntrajError, so one except clause catches them all:

import runtraj

try:
    project.run()
except runtraj.RuntrajError as error:
    print(f"runtraj stopped: {error}")

Each one also subclasses the builtin that describes it. A SimulationError is a RuntimeError, and a HYSPLITNotFoundError is a FileNotFoundError. A MeteorologyError, raised when a met’s files cannot be found, is both. An except for the builtin catches it too. Plain input checks, such as a negative particle count, raise ValueError.

Base class#

runtraj.RuntrajError

Base class for every exception runtraj raises.

Failed runs#

A worker records a SimulationError as a failed simulation (runtraj.Simulation.failure). Its reason is a short name for the cause: for HYSPLIT, one of runtraj.models.hysplit.FailureReason, such as MET_COVERAGE, NO_PARTICLE_DATA, or TIMEOUT. A run that the meteorology does not cover fails as MET_COVERAGE.

Two reasons come from runtraj itself, for any transport model:

RELEASE_REFUSED

The transport model cannot run the release, and said so in its check_releases before the run; runtraj check lists it too. With HYSPLIT, it is a multipoint release whose points share a horizontal location: use a ColumnRelease for a column, or one PointRelease per height.

NO_RELEASE_ROWS

Where the particles of a column or multipoint release started is not known: the model wrote no row at age = 0 and gives no release_rows, or its release_rows left out a particle. A model should write a release row at age = 0 (The Particle Table).

runtraj.exceptions.SimulationError

A simulation failed while it ran.

runtraj.exceptions.MeteorologyError

The meteorology files a simulation needs could not be found or staged.

Stopped runs#

A run on cpus above 1 raises WorkerDied when a worker process is killed outright, as the out-of-memory killer does. It is not a failed simulation: nothing is recorded, and running again continues.

runtraj.exceptions.WorkerDied

A worker process died without Python's say, and the run stopped.

Setup#

A project does not open on a machine where a class its config.yaml names by import path is not installed (MissingClass, an ImportError): a transport model or a stage in another package. The message names the package to install, and the runtraj commands exit with 2.

runtraj.exceptions.HYSPLITNotFoundError

The HYSPLIT executable (hycs_std) is missing, or cannot run.

runtraj.exceptions.MissingClass

A class that config.yaml names cannot be imported here.