runtraj.transforms.survival#

runtraj.transforms.survival(particles, rate)[source]#

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

Use it for a loss whose rate is known at every row and does not depend on how much tracer the particle carries: a reaction with an oxidant, deposition, rain-out, or a lifetime from your own chemistry model. The fraction emitted at a row is the fraction that reaches the release, so a row’s weight times it is still that row’s share at the release.

Parameters:
  • particles (DataFrame) – The particle table, with particle and age (minutes) columns.

  • rate (ArrayLike) – The loss rate at each row, in s⁻¹, aligned with particles. Zero where there is no loss.

Returns:

The surviving fraction, between 0 and 1, aligned with particles’ index.

Return type:

Series

Raises:

ValueError – If a column is missing, rate has the wrong length, or a rate is negative or missing.

Notes

The fraction at a row is \(\exp(-\sum k \, \Delta t)\) over the steps from the release to that row, where each row stands for the step that ends at it (a particle’s first step runs from the release) and \(k\) is that row’s rate. A rate that changes slowly between rows, such as one set by temperature or an oxidant field, needs no particular step; a rate that switches on and off within a step, such as deposition below a fixed height, needs short steps (dry_deposition_survival() asks for one-minute rows).

Examples

>>> import pandas as pd
>>> from runtraj.transforms import survival
>>> p = pd.DataFrame({"particle": [1, 1, 1], "age": [-60.0, -120.0, -180.0]})
>>> survival(p, rate=[1e-4, 1e-4, 0.0]).round(4).tolist()
[0.6977, 0.4868, 0.4868]