HYSPLIT Integration#

HYSPLIT is the transport model behind every simulation, unless a variant names another. The worker gets it as runtraj.models.hysplit.HysplitModel (see Execution), which picks the met files, writes HYSPLIT’s input files, runs hycs_std, and reads the particles it writes.

Config#

runtraj.models.hysplit.HysplitConfig holds every setting that shapes the particles HYSPLIT makes. In config.yaml they are the keys of the hysplit block under models:.

runtraj.models.hysplit.HysplitConfig

HYSPLIT's config: every setting that shapes the particles it makes.

The HYSPLIT build#

PYSTILT includes no HYSPLIT. find_hycs_std() returns the hycs_std a run uses: exec/hycs_std under directory, or else the first on PATH (Installation). HysplitModel.sha256 is its checksum, part of each run’s settings, and HysplitModel.version the version it prints when it starts, recorded beside them. data_tables() gives HYSPLIT’s data tables a run uses, from the bdyfiles/ folder of directory or beside the hycs_std on PATH.

runtraj.models.hysplit.find_hycs_std

Return the hycs_std a run uses: exec/hycs_std under directory, else the first on PATH.

runtraj.models.hysplit.data_tables

Return HYSPLIT's data tables a run uses, by name: a file to link, or the text to write.

Running HYSPLIT#

write_inputs() writes everything hycs_std reads into a folder: CONTROL, SETUP.CFG, and the error and mixed-layer files when the settings call for them. It takes what CONTROL starts from: a release time and release locations (latitude, longitude and height, in CONTROL’s order), with kmsl 0 for heights above ground and 1 above sea level, as SETUP.CFG’s KMSL. HysplitModel passes a release’s time, release points (release.coords()) and altitude_ref. run_hycs_std() runs hycs_std in the folder, and read_particle_dat() reads its PARTICLE_STILT.DAT as a particle table. Use them to look at or change the input files of a run. A project run then adds the release heights and, when it makes the footprint, the near-field correction (The Particle Table); by hand:

from pathlib import Path

from stilt.footprint import correct_near_field
from runtraj.particles import add_release_heights
from runtraj.models.hysplit import (
    HysplitConfig,
    read_particle_dat,
    run_hycs_std,
    write_inputs,
)

config = HysplitConfig(n_hours=-24, numpar=200)
write_inputs(
    "run",
    release_time=release.time,
    locations=release.coords(),
    config=config,
    met_files=met_files,
    kmsl=1 if release.altitude_ref == "msl" else 0,
)
run_hycs_std(Path("run"))
particles = read_particle_dat("run/PARTICLE_STILT.DAT", config.varsiwant)
particles = add_release_heights(particles, release)
particles = correct_near_field(particles, release, config.veght)

runtraj.models.hysplit.write_inputs

Write everything hycs_std reads for one run into workdir.

runtraj.models.hysplit.run_hycs_std

Run the hycs_std in workdir, writing its output to hysplit.log.

runtraj.models.hysplit.read_particle_dat

Read HYSPLIT's particle file as a particle table.

Failure reasons#

When a run ends, PYSTILT reads HYSPLIT’s log for the messages it knows. When the particles stopped before n_hours, it also checks where: a particle more than 5 grid cells inside the met’s domain means the met ran out (MET_COVERAGE), since particles that leave the domain end at its edge (Validation). A known failure, a timeout, or a run without particle output raises a SimulationError whose reason is a runtraj.models.hysplit.FailureReason. The worker records it, and stilt.Simulation.failure and stilt status report it.

Each reason, what happened, and what to do:

Reason

What happened, and what to do

MET_COVERAGE

The meteorology does not cover the run. The message says which:

  • No met file ... for <hours>: a file the run needs is missing. Check the met’s directory against the files on disk. A backward run needs files from n_hours before the release time to just after it, a forward run from the release time to just after n_hours later (Meteorology). stilt check finds these before a run.

  • The met file ... is damaged or The met files hold no time step between ...: a file is there but cut short, written partway, or has records lost to null bytes, so it lacks hours the run needs. Download or crop it again. PYSTILT checks each file before HYSPLIT runs (arlmet.File.check()).

  • The met file ... holds one time period: HYSPLIT cannot read a file with one time period. Use files that each hold at least two (stilt check finds this before a run).

  • no more meteorology: the particles reached a time that no met file holds. HYSPLIT says so in the WARNING file of the kept workdir.

  • The particles stopped ... h into the ... h run, up to ... grid cells inside the met's domain: the particles stopped before n_hours and at least one was more than 5 grid cells from every side of the met grid. Particles that leave the domain end within 2 cells of its edge, so the met ran out, though HYSPLIT may have written no warning and Complete Hysplit. Look for a met file with fewer hours than its name says, and download or crop it again. PYSTILT checks this only when outdt is 0, the default: with fewer rows, a particle’s last row can be far from where it left.

  • A HYSPLIT message, such as start point not within (x,y,t) any data file: the release is outside the files, in time or in space. source point off grid says the release is outside the met’s grid (check the sign of its longitude; stilt check lists such a release as met_domain), and Start height above mdl domain that it is above the met’s top; the line gives the height and the top.

VARYING_MET_INTERVAL

The met files do not all have the same time step, such as hourly and 3-hourly files mixed in one directory. Keep one product per met.

NO_PARTICLE_DATA

The transport model ran but wrote no particles. Read the log (sim.log): it usually says why.

FORTRAN_RUNTIME_ERROR

HYSPLIT stopped with a Fortran error, which the message names. Read the log and the kept workdir’s MESSAGE file.

PARTICLE_LIMIT

HYSPLIT reached maxpar before every location of a multipoint release got its particles, so the last ones would have fewer or none. Leave maxpar unset, or raise it (Releases (receptors)).

EXIT_STATUS

hycs_std was killed by a signal, or exited with a non-zero status, and its log holds no other known message. The message names the signal or the status, and the log ends with the last lines of HYSPLIT’s MESSAGE file. A SIGKILL that nothing in PYSTILT sent is often the kernel’s out-of-memory killer: ask for more memory per task, or run fewer releases at once. The particles HYSPLIT had written are not kept, and running again runs the simulation again.

TIMEOUT

The run took longer than timeout under execution:. Raise it, or look for a slow node or a met file read over a slow filesystem.

an error’s name

Any other error is recorded by its class, such as ValueError, with its traceback. That is usually a bug or a setup problem worth reporting.

runtraj.models.hysplit.FailureReason

Why a HYSPLIT run failed.