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, or, with mode: concentration, its
concentration grids (The concentration mode). With mode:
trajectory it runs hyts_std instead (The trajectory mode).
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:.
HYSPLIT's config: every setting that shapes what it makes. |
The HYSPLIT build#
runtraj 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.
Return the |
|
Return the HYSPLIT program called name that a run uses: |
|
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 (longitude,
latitude and height, like release.coords(); the CONTROL file lists
each latitude first, and the writer swaps them), 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 file 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
(The Particle Table); by hand:
from pathlib import Path
from runtraj.particles import add_release_heights
from runtraj.models.hysplit import (
HysplitConfig,
HysplitModel,
read_particle_dat,
run_hycs_std,
write_inputs,
)
from runtraj.models.hysplit.driver import PARTICLE_FILE
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(Path("run") / PARTICLE_FILE, config.varsiwant)
particles = add_release_heights(particles, release, HysplitModel().release_rows)
Write everything |
|
Run the |
|
Read HYSPLIT's particle file as a particle table. |
The concentration mode#
With mode: concentration runtraj writes HYSPLIT’s own concentration
output, ICHEM from ichem (0 unless set), with HYSPLIT’s dispersion
scheme (IDSP unset) in place of ICHEM=8 and IDSP=2. The pollutants and grids are
written to CONTROL:
In |
In runtraj |
|---|---|
Lines 10 to 14: the pollutants, their emission rate, hours and start |
|
Lines 15 to 25: the grids, their center, spacing, span, file, levels, sampling start, stop and interval |
|
Lines 26 to 31: deposition, wet removal, decay and resuspension of each pollutant |
The other fields of each pollutant, in HYSPLIT’s units |
read_cdump() reads one grid’s file, packed
(cpack 1, HYSPLIT’s default, or 3) or not (cpack: 0), as a
Dataset of Result Types and Concentration. A file of one point per grid (cpack:
2) is refused. A run fails as NO_CONCENTRATION_DATA when a grid has
no file, or a file with no sample, as when sampling_interval is longer
than the run, or fewer samples than the run holds: its length divided by
the interval, in whole intervals. HYSPLIT keeps writing samples,
of zeros, after its particles are gone, so a run whose met ran out after
it started is not found this way, and runtraj does not check a
concentration run for it, as it does a particle run (its files are checked
before the run starts).
HYSPLIT stops releasing when it holds MAXPAR particles. A particle run
releases in one time step, and a concentration run over each pollutant’s
hours, again every qcycle hours; HYSPLIT rounds the particles of
each hour and each time step up, for each pollutant at each location, so
it asks for more than numpar (2010 for 2000 from one location over an
hour, 2070 from three). With maxpar unset a concentration run gets
numpar and that rounding for every cycle
(maxpar_for()), so the grids
hold all that was released. Set maxpar only above that.
ichem is recorded in a concentration run’s settings, 0 when unset. No
value changes the form of the file, only what a cell or a pollutant of it
means, which the file does not say:
read_cdump() is told the ichem and
cmass the run had. What each value does and needs, as seen in runs of
HYSPLIT 5.4.2:
|
What HYSPLIT does, and what runtraj refuses with it |
|---|---|
1 |
Names a pollutant for each |
2 |
Reads |
5 |
Deposits whole particles with a probability. HYSPLIT stops on
|
6 |
Divides each particle’s mass by the air density at its level
before it is counted. The |
9 |
Reads the first of a grid’s levels as a percentage of the mixed
layer depth and counts from the ground to that share of it, at
each particle (10 m at least). |
10 |
Names a pollutant for each emission cycle by the tenths of an hour
from the start of the run, read as the dimension
|
3, 4, 7, 11 |
Refused: dust emission needs an emission and an area on each
location; 4 counts on the met model’s grid for HYSPLIT’s chemistry
builds; 7 needs momentum fluxes in the met files; 11 needs a
|
8 |
Refused here: it is |
others |
Refused: HYSPLIT ran |
One pollutant of a HYSPLIT concentration run: what is released, and how it is removed. |
|
One grid of a HYSPLIT concentration run: where and how often the particles are counted. |
|
One conversion of a HYSPLIT concentration run with |
|
Read one of HYSPLIT's binary concentration files ( |
The trajectory mode#
With mode: trajectory runtraj runs HYSPLIT’s trajectory program,
hyts_std, from exec/ of the same HYSPLIT folder (or PATH), and
its SHA-256 is the one in the run’s settings. CONTROL has the lines
both programs read (the release time and locations, n_hours,
w_option, z_top, the met files), then ./ and tdump, where
the trajectories are written.
SETUP.CFG is one namelist for both programs, and hyts_std reads
the dispersion model’s entries too: ICHEM and IDSP change its
trajectories. So a trajectory run’s SETUP.CFG holds only:
In |
In runtraj |
|---|---|
|
Fixed at 1: heights above ground, |
|
The release’s |
|
|
|
The |
|
The settings of those names. |
Every other setting is the dispersion model’s and is left out of a
trajectory run, neither written nor recorded
(TRAJECTORY_SETTINGS). nstr and
nver (restarts and splits) are refused: a release starts its own
trajectories, and runtraj does not read a split run’s file.
hyts_std starts a trajectory at every location in CONTROL, so a
multipoint release may hold two points at one place, which hycs_std
would join into a line source. A column release is refused
(RELEASE_REFUSED), since there is no line source to make of it.
read_tdump() reads the file by the widths of
its fields. A run fails as NO_TRAJECTORIES_DATA when there is no file
or no row in it, and as MET_COVERAGE when it holds fewer trajectories
than the release has locations: hyts_std leaves out a location outside
the met’s domain and numbers the rest from 1. A trajectory that leaves the
domain later ends there, and its run is complete. Met that runs out is
found as in any run, from the files before it starts and from HYSPLIT’s
warning after.
Read a trajectory file |
Reading the input files#
ControlFile holds what a CONTROL file
says, and read() reads one.
read_namelist() reads a SETUP.CFG into a
dict by lowercase name. Use them to look at the input files of a run that
was made without runtraj.
Contents of a HYSPLIT |
|
Return the entries of a |
Releases#
HYSPLIT joins release points at one latitude and longitude into a vertical
line source, so it refuses a multipoint release whose points share a
horizontal location
(check_releases()): runtraj check
lists it, and its run fails as RELEASE_REFUSED before hycs_std
starts. HYSPLIT 5.1.0
writes no particle row at age = 0, so
release_rows() says where each
particle of a column or multipoint release started: particle k of a
column in slab k, and a multipoint release’s particles matched to a
point from their first row (The Particle Table).
Return the releases HYSPLIT cannot run, one row each, with |
|
Return where each particle of a HYSPLIT run started, for a run that wrote no row at |
Failure reasons#
When a run ends, runtraj 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. 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
runtraj.Simulation.failure and runtraj status report it.
Each reason, what happened, and what to do:
Reason |
What happened, and what to do |
|---|---|
|
The meteorology does not cover the run. The message says which:
|
|
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. |
|
The transport model ran but wrote no particles. Read the log
( |
|
A concentration run wrote no file for a grid, one with no sample,
or one with fewer samples than the run holds. A
|
|
A trajectory run wrote no |
|
HYSPLIT stopped with a Fortran error, which the message names. Read
the log and the kept workdir’s |
|
HYSPLIT reached |
|
|
|
A multipoint release whose points share a horizontal location,
which HYSPLIT would join into a line source. Use a
|
|
The run took longer than |
an error’s name |
Any other error is recorded by its class, such as |
Why a HYSPLIT run failed. |