Transforms#

Particle transforms multiply each particle row’s weight, and the footprint is made from foot times weight (see Particle Weighting (Transforms)). They are runtraj’s (runtraj.transforms), listed here because PYSTILT’s footprint, background and transport error use them. 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.

Built-in transforms#

runtraj.transforms.AveragingKernel

Transform that weights each row by an averaging kernel.

runtraj.transforms.PressureWeighting

Transform that weights each particle by its share of the column's air mass.

runtraj.transforms.FirstOrderLifetime

Transform that decays each row's weight by exp(-age / lifetime).

runtraj.transforms.DryDeposition

Transform that weighs each row by the tracer that survives dry deposition.

runtraj.transforms.Oxidation

Transform that weighs each row by the tracer that survives a reaction with an oxidant.

Averaging-kernel tables#

runtraj.transforms.averaging_kernel_table

Return a table of averaging kernels, one per release, for AveragingKernel.

Science helpers#

runtraj.transforms.weigh

Return a copy of the particles with weight multiplied by factor.

runtraj.transforms.release_coordinate

Return each particle's value of coordinate at release, indexed by particle.

runtraj.transforms.particle_pwf

Return each particle's release pressure and pressure weight.

runtraj.transforms.ak_weights

Return the averaging kernel at each particle's release coordinate.

runtraj.transforms.survival

Return the fraction of a tracer that survives from each row to the release.

runtraj.transforms.dry_deposition_survival

Return the fraction of a depositing tracer that survives from each row to the release.

Loading and dumping#

runtraj.transforms.load_transform

Return the transform for one config entry.

runtraj.transforms.dump_transform

Return the config mapping for one transform, the inverse of load_transform().

runtraj.transforms.apply_transforms

Apply transforms in order, each with the release and the directory.

runtraj.transforms.transform_kind

Return the kind that declares a transform in a config.

Sampling a field at particles#

sample_field() reads a gridded field in the cell nearest each point: an oxidant along each trajectory, a mole fraction where each particle ends (stilt.background()), or a surface flux under each particle (particles.stilt.enhancement).

runtraj.sampling.sample_field

Return the field's value in the cell nearest each point.

runtraj.sampling.vertical_dim

Return the name of a field's vertical dimension.

runtraj.sampling.nearest_cell

Return the index of the cell nearest each value, or -1 outside the cells.