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_trajectories

Run the transport model for one release and return its particles.

calc_footprint

Calculate a footprint from particles, as STILT-R's calc_footprint does.

footprint.footprint_particles

Return the particles a footprint under config is made from, with the foot it uses.

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.

Project

A STILT project: releases, settings, the simulations they define, and their footprints.

Release objects#

Release

Base class of the release types.

PointRelease

Release that releases particles from one point.

ColumnRelease

Release that releases particles evenly along a vertical line.

MultiPointRelease

Release that releases particles from several points at once.

read_releases

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.

Simulation

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.

footprint.config.footprint_settings

Return the settings that identify a footprint, besides its particles, in canonical form.

footprint.config.read_footprint_settings

Return the footprint config that footprint_settings() recorded.

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_particles

Read a particle file.

read_footprint

Read a footprint file, NetCDF or the Parquet files PYSTILT stores.

footprint.write_footprint

Write a footprint to a Parquet file that read_footprint() reads alone.

footprint.write_empty_footprint

Record in a footprint file that a release's footprint is empty: no particle reached the grid.

footprint.open_footprints

Open stored footprints as one dataset, stacked on the layer from each release's time.

particles.ParticlesAccessor

PYSTILT methods on a particle table, as particles.stilt.

footprint.FootprintAccessor

PYSTILT methods on a footprint, as foot.stilt.

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).

migration.read_stilt_r

Read STILT-R or X-STILT by-id output, one simulation at a time.

migration.import_stilt_r

Write the runs of a STILT-R or X-STILT by-id folder into a PYSTILT output directory.

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.

background

Return the background mole fraction at a release.

Background

Background at a release, returned by background().

transport_error

Return the transport-error variance of a modeled enhancement (Lin and Gerbig, 2005).

TransportError

Transport error of a modeled enhancement, returned by transport_error().

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.

Mesh

Polygon cells with ids, the most general geometry.

Zones

Regions made by merging the cells of a Grid or Mesh.

footprint.Geometry

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.

footprint.overlap_weights

Return the fraction of each raster cell inside each geometry cell.

footprint.check_resolution

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.

sampling.sample_met

Return the particles with met columns sampled from ARL files at each particle's position.

sampling.calc_pbl_height

Return the mixed-layer height at each particle, found from the met's profile as HYSPLIT's kmixd: 3 finds it.