Core Objects#
The project, its releases, the simulations it runs, and their outputs.
The particle runs are runtraj’s, and
its reference has their classes and functions; this page lists what
stilt adds and the names it gives you.
One release, without a project#
run_trajectories() runs the transport model for one release and
returns its particles, and calc_footprint() makes a footprint from
them. footprint.footprint_particles() gives the particles the
foot a footprint’s settings ask for, as a project’s footprint stage
does. A project runs the same two steps for each of its releases and
stores the results.
particles = stilt.run_trajectories(release, met, n_hours=-24, numpar=200)
foot = stilt.calc_footprint(particles, release, grid)
Run the transport model for one release and return its particles. |
|
Calculate a footprint from particles, as STILT-R's |
|
Return the particles a footprint under config is made from, with the |
Project interface#
Project is what you open a project with. It is runtraj’s
runtraj.Project, which runs the transport model and reads the
particles, with the reads of what STILT makes from the particles added: the
footprints, the Jacobian, and the transport error of a selection. Both open
the same directory; the workers use runtraj’s.
A STILT project: releases, settings, the simulations they define, and their footprints. |
Release objects#
Base class of the release types. |
|
Release that releases particles from one point. |
|
Release that releases particles evenly along a vertical line. |
|
Release that releases particles from several points at once. |
|
Read releases from a CSV file. |
Simulation objects#
A Variant is one variant of a project, resolved: its configs, its
met, the transport model build, and the hashes that find its results.
project.variants holds them, and ProjectConfig.resolve() makes
them from a config.
Simulation, which project.simulation(release_id, variant)
returns, adds the footprint, the background and the transport error to
runtraj’s runtraj.Simulation, which the workers and the stages are
given.
One release run under one variant, with its footprint, background, and transport error. |
Settings and their hashes#
runtraj.identity records what a run was made with, as its folder’s
_settings.yaml holds it, and hashes it. A stage records its own settings
(runtraj.stages.Stage.settings(); the footprint’s are
footprint_settings()), which are hashed with
the particles’ hash and the hash of each stage it reads. A stored record is
read back through the current config classes, so a setting added since, with
a default, still matches.
Return the settings that identify a footprint, besides its particles, in canonical form. |
|
Return the footprint config that |
Particles and footprints#
A simulation’s particles are a pandas DataFrame and its footprint an xarray
DataArray. PYSTILT’s methods on them are under .stilt:
ParticlesAccessor (runtraj’s
ParticlesAccessor with enhancement added) and
FootprintAccessor. The functions below read and
write particle and footprint files without a project.
Read a particle file. |
|
Read a footprint file, NetCDF or the Parquet files PYSTILT stores. |
|
Write a footprint to a Parquet file that |
|
Record in a footprint file that a release's footprint is empty: no particle reached the grid. |
|
Open stored footprints as one dataset, stacked on the layer from each release's time. |
|
PYSTILT methods on a particle table, as |
|
PYSTILT methods on a footprint, as |
Output of STILT-R and X-STILT#
stilt.migration reads the out/by-id folder of a STILT-R or
X-STILT project as releases, particle tables, and footprints, and imports
it into an output directory, where a stilt-r variant reads it
(Coming From STILT-R).
Read STILT-R or X-STILT |
|
Write the runs of a STILT-R or X-STILT |
What the particles give beyond the footprint#
The background mole fraction at a release, from a field sampled where
the particles end (Background), and the transport error of
the modeled enhancement, from a wind-error variant
(Transport Error). With a project they are
sim.background(field) and sim.transport_error(error_sim, flux).
Both weight the particles the way the footprint does.
Return the background mole fraction at a release. |
|
Background at a release, returned by |
|
Return the transport-error variance of a modeled enhancement (Lin and Gerbig, 2005). |
|
Transport error of a modeled enhancement, returned by |
Simulation tables#
project.releases is a pandas DataFrame with one row per release, and
project.simulations one with one row per simulation. Select rows as in
pandas, then pass the selection to the project’s status(),
incomplete(), particles(),
footprints(), jacobian(), or
transport_error().
sims = project.simulations
wbb = sims[(sims.variant == "hrrr") & (sims.site == "WBB")]
feet = project.footprints(wbb)
Spatial geometries#
The cells foot.stilt.aggregate sums a footprint into, such as
polygons, hexagons, windows around point sources, or groups of grid cells.
A Grid works as well. It is documented under Configuration.
Polygon cells with ids, the most general geometry. |
|
Regions made by merging the cells of a |
|
A geometry a footprint can be aggregated onto. |
stilt.footprint also has the helpers that compute how much of each
footprint cell falls in each target cell. These overlap weights are cached,
so each geometry’s weights are computed once per footprint grid.
runtraj.spatial has the CRS helpers.
Return the fraction of each raster cell inside each geometry cell. |
|
Warn when the raster is too coarse to resolve the smallest target cell. |
Sampling fields#
runtraj.sampling.sample_field() looks up a gridded field at points:
a surface flux under a footprint or along particle paths
(foot.stilt.enhancement, particles.stilt.enhancement), or a
mole-fraction field at particle endpoints (stilt.background()); it
is listed with the transforms (Transforms).
sample_met() reads ARL met files at particle
positions, for the particle columns a transport model can write from the
met.
Return the particles with met columns sampled from ARL files at each particle's position. |
|
Return the mixed-layer height at each particle, found from the met's profile as HYSPLIT's |