Transforms and Sampling#
Particle transforms say how much each particle row counts: for a column
measurement, its averaging kernel and its share of the column’s air; for a
species lost on the way, the fraction that survives to the release. Each
multiplies the particles’ weight column (The Particle Table). A transform
is any object with an apply(particles, release=None, directory=None)
method. The built-ins are pydantic models, and their fields are their
config.yaml keys under a stage’s transforms:.
from runtraj.transforms import FirstOrderLifetime, apply_transforms
weighted = apply_transforms(particles, [FirstOrderLifetime(lifetime_hours=24)])
weighted["weight"] # exp(-age / 24 h) at each row
Built-in transforms#
Transform that weights each row by an averaging kernel. |
|
Transform that weights each particle by its share of the column's air mass. |
|
Transform that decays each row's |
|
Transform that weighs each row by the tracer that survives dry deposition. |
|
Transform that weighs each row by the tracer that survives a reaction with an oxidant. |
Averaging-kernel tables#
Return a table of averaging kernels, one per release, for |
Science helpers#
Return a copy of the particles with |
|
Return each particle's value of |
|
Return each particle's release pressure and pressure weight. |
|
Return the averaging kernel at each particle's release coordinate. |
|
Return the fraction of a tracer that survives from each row to the release. |
|
Return the fraction of a depositing tracer that survives from each row to the release. |
Loading and dumping#
Return the transform for one config entry. |
|
Return the config mapping for one transform, the inverse of |
|
Apply transforms in order, each with the release and the directory. |
|
Return the |
Sampling a field at particles#
sample_field() reads a gridded field (an xarray.DataArray
on a lat/lon or y/x grid, with an optional vertical
dimension and time) in the cell nearest each point: an oxidant along
each trajectory, or a mole fraction where each particle ends.
Return the field's value in the cell nearest each point. |
|
Return the name of a field's vertical dimension. |
|
Return the index of the cell nearest each value, or |