Skip to content

Gaussian puff

Time-resolved Gaussian puff (Pasquill-Gifford), exact wind integrals (integrix), and Ornstein-Uhlenbeck sub-grid turbulence. Tier I.

gauss_puff

Gaussian puff model (JAX + integrix + NumPyro).

Submodules
  • dispersion — Pasquill-Gifford σ(s) coefficients + shared Briggs dispatch
  • wind — piecewise-linear WindSchedule + exact cumulative integrals
  • turbulence — Ornstein-Uhlenbeck sub-grid position disturbances on puff centres
  • puff — single-puff kernel, evolve_puffs, simulate_puff (xarray)
  • inference — NumPyro Bayesian inference for Q (constant) and Q_i (random walk)

The inference submodule is imported lazily on first attribute access so that from plumax import gauss_puff does not pull in NumPyro for consumers of only the forward model.

puff_concentration_vmap module-attribute

puff_concentration_vmap = vmap(puff_concentration, in_axes=(None, None, None, 0, 0, 0, 0, 0, 0, 0), out_axes=0)

Vectorised over puffs (per-puff params batched along axis 0, receptor shared).

PuffState

Bases: Module

Container for the Lagrangian state of a puff ensemble at a single time.

Attributes

release_times : Float[Array, "N"] Puff release times [s]. x, y, z : Float[Array, "N"] Puff-centre positions at the evaluation time [m]. travel_distance : Float[Array, "N"] Cumulative travel distance since release [m]. mass : Float[Array, "N"] Puff mass [kg]. Inactive puffs (not yet released) have mass 0.

OUTurbulence dataclass

OUTurbulence(sigma_fluctuations: float = 0.5, correlation_time: float = 60.0)

Ornstein-Uhlenbeck turbulence for puff-release position disturbances.

Attributes

sigma_fluctuations : float OU fluctuation amplitude [m/√s]. Together with correlation_time it sets the steady-state RMS offset σ_∞ = σ_f · √(τ_c / 2) [m]. correlation_time : float OU correlation time [s]. Offsets for puffs released within τ_c of each other are strongly correlated; puffs released more than a few τ_c apart are effectively independent.

Notes

Gorroño et al. (2023) calibrated comparable parameters against large-eddy simulations of methane plumes; defaults in the Eucalyptus release are (σ_f, τ_c) = (0.5 m/s, 60 s) giving a steady-state RMS offset of about 2.7 m — appropriate for 20 m-GSD Sentinel-2 pixels.

stationary_std property

stationary_std: float

Steady-state RMS per-component offset σ_f · √(τ_c / 2) [m].

WindSchedule

Bases: Module

Piecewise-linear time-varying wind field.

Attributes

times : Float[Array, "T"] Monotone increasing time knots [s]. u_wind : Float[Array, "T"] x-component of wind velocity at the knots [m/s]. v_wind : Float[Array, "T"] y-component of wind velocity at the knots [m/s].

Notes

The schedule behaves as a piecewise-linear interpolant between knots. Queries outside [times[0], times[-1]] linearly extrapolate — consumers that need strict clamping should range-check times before calling. A single knot is a constant wind.

from_speed_direction classmethod

from_speed_direction(times: ndarray | ndarray, wind_speed: ndarray | ndarray, wind_direction: ndarray | ndarray) -> WindSchedule

Build a schedule from (speed, direction) in meteorological "from" convention.

wind_direction = 270° is a wind from the west (u > 0); wind_direction = 0° is a wind from the north (v < 0).

u = −|V| · sin(θ),   v = −|V| · cos(θ),   θ = direction (radians).
Parameters

times : array-like, shape (T,) Monotone time knots [s]. wind_speed : array-like, shape (T,) Wind speed at each knot [m/s]. Must be ≥ 0. wind_direction : array-like, shape (T,) Wind direction at each knot [degrees from North].

Returns

WindSchedule In the default float dtype (float64 with 64-bit JAX).

Raises

ValueError If the knot times are too far from their epoch for the dtype to resolve a hundredth of their finest spacing.

Source code in src/plumax/gauss_puff/_src/wind.py
@classmethod
def from_speed_direction(
    cls,
    times: np.ndarray | jnp.ndarray,
    wind_speed: np.ndarray | jnp.ndarray,
    wind_direction: np.ndarray | jnp.ndarray,
) -> WindSchedule:
    """Build a schedule from (speed, direction) in meteorological "from" convention.

    ``wind_direction = 270°`` is a wind *from* the west (u > 0);
    ``wind_direction = 0°`` is a wind *from* the north (v < 0).

        u = −|V| · sin(θ),   v = −|V| · cos(θ),   θ = direction (radians).

    Parameters
    ----------
    times : array-like, shape (T,)
        Monotone time knots [s].
    wind_speed : array-like, shape (T,)
        Wind speed at each knot [m/s]. Must be ≥ 0.
    wind_direction : array-like, shape (T,)
        Wind direction at each knot [degrees from North].

    Returns
    -------
    WindSchedule
        In the default float dtype (float64 with 64-bit JAX).

    Raises
    ------
    ValueError
        If the knot times are too far from their epoch for the dtype to
        resolve a hundredth of their finest spacing.
    """
    # the default float dtype: float64 with 64-bit JAX, else float32
    times_j = jnp.asarray(times, dtype=float)
    speed_j = jnp.asarray(wind_speed, dtype=float)
    wind_east, wind_north = wind_components(
        speed_j, jnp.asarray(wind_direction, dtype=float)
    )
    # traced knot times cannot be read on the host, so their check is skipped
    if not _is_traced(times):
        knots = np.asarray(times, dtype=np.float64)
        gaps = np.abs(np.diff(knots))
        # Δt_min = min_k (t_{k+1} − t_k) over distinct knots, the finest spacing
        finest = float(np.min(np.where(gaps > 0.0, gaps, np.inf), initial=np.inf))
        if np.isfinite(finest):
            _check_time_resolution(
                knots,
                finest,
                times_j.dtype,
                caller="WindSchedule.from_speed_direction",
            )
    return cls(times=times_j, u_wind=wind_east, v_wind=wind_north)

wind_at

wind_at(t: Float[Array, '']) -> tuple[Float[Array, ''], Float[Array, '']]

The wind (u(t), v(t)) at time t, linear between knots.

u(t) = (1 − λ) u_k + λ u_{k+1}, λ = (t − t_k) / (t_{k+1} − t_k), continued along the first or last segment outside the knots.

Source code in src/plumax/gauss_puff/_src/wind.py
def wind_at(self, t: Float[Array, ""]) -> tuple[Float[Array, ""], Float[Array, ""]]:
    """The wind (u(t), v(t)) at time ``t``, linear between knots.

    u(t) = (1 − λ) u_k + λ u_{k+1},  λ = (t − t_k) / (t_{k+1} − t_k),
    continued along the first or last segment outside the knots.
    """
    wind_east, wind_north = self._path().evaluate(t)
    return wind_east, wind_north

speed_at

speed_at(t: Float[Array, '']) -> Float[Array, '']

The wind speed |V(t)| = √(u(t)² + v(t)²), with a zero gradient in calm air.

Source code in src/plumax/gauss_puff/_src/wind.py
def speed_at(self, t: Float[Array, ""]) -> Float[Array, ""]:
    """The wind speed |V(t)| = √(u(t)² + v(t)²), with a zero gradient in calm air."""
    wind_east, wind_north = self.wind_at(t)
    # |V| = √(u² + v²), by geophysix's double where
    return speed_of(wind_east, wind_north)

calculate_briggs_dispersion_xyz

calculate_briggs_dispersion_xyz(distance: ndarray, params: ndarray) -> tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]

Evaluate σ_x(s), σ_y(s), σ_z(s) from Briggs parameters.

Thin wrapper around the plume model's Briggs evaluator that additionally exposes σ_x = σ_y so this routine is signature-compatible with :func:calculate_pg_dispersion. Lets callers swap dispersion schemes without changing downstream code.

Parameters

distance : jnp.ndarray Puff travel distance [m]. params : jnp.ndarray, shape (6,) Briggs parameters [a_y, b_y, c_y, a_z, b_z, c_z].

Returns

sigma_x, sigma_y, sigma_z : jnp.ndarray Dispersion coefficients [m]. σ_x = σ_y.

Source code in src/plumax/gauss_puff/_src/dispersion.py
@jit
def calculate_briggs_dispersion_xyz(
    distance: jnp.ndarray,
    params: jnp.ndarray,
) -> tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]:
    """Evaluate σ_x(s), σ_y(s), σ_z(s) from Briggs parameters.

    Thin wrapper around the plume model's Briggs evaluator that additionally
    exposes ``σ_x = σ_y`` so this routine is signature-compatible with
    :func:`calculate_pg_dispersion`. Lets callers swap dispersion schemes
    without changing downstream code.

    Parameters
    ----------
    distance : jnp.ndarray
        Puff travel distance [m].
    params : jnp.ndarray, shape (6,)
        Briggs parameters ``[a_y, b_y, c_y, a_z, b_z, c_z]``.

    Returns
    -------
    sigma_x, sigma_y, sigma_z : jnp.ndarray
        Dispersion coefficients [m]. ``σ_x = σ_y``.
    """
    crosswind_spread, vertical_spread = calculate_briggs_dispersion(distance, params)
    return crosswind_spread, crosswind_spread, vertical_spread

calculate_pg_dispersion

calculate_pg_dispersion(distance: ndarray, params: ndarray) -> tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]

Evaluate σ_x(s), σ_y(s), σ_z(s) from Pasquill-Gifford parameters.

σ_i(s) = exp(a_i + b_i · ln(s) + c_i · (ln s)²) for i ∈ {y, z}; σ_x := σ_y.

Parameters

distance : jnp.ndarray Puff travel distance [m]. Non-positive values are clamped to 1 m so that ln(s) stays finite. params : jnp.ndarray, shape (6,) [a_y, b_y, c_y, a_z, b_z, c_z].

Returns

sigma_x, sigma_y : jnp.ndarray Horizontal dispersion coefficients [m]. σ_x = σ_y. sigma_z : jnp.ndarray Vertical dispersion coefficient [m].

Source code in src/plumax/gauss_puff/_src/dispersion.py
@jit
def calculate_pg_dispersion(
    distance: jnp.ndarray,
    params: jnp.ndarray,
) -> tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]:
    """Evaluate σ_x(s), σ_y(s), σ_z(s) from Pasquill-Gifford parameters.

    σ_i(s) = exp(a_i + b_i · ln(s) + c_i · (ln s)²) for i ∈ {y, z};
    σ_x := σ_y.

    Parameters
    ----------
    distance : jnp.ndarray
        Puff travel distance [m]. Non-positive values are clamped to 1 m
        so that ``ln(s)`` stays finite.
    params : jnp.ndarray, shape (6,)
        ``[a_y, b_y, c_y, a_z, b_z, c_z]``.

    Returns
    -------
    sigma_x, sigma_y : jnp.ndarray
        Horizontal dispersion coefficients [m]. ``σ_x = σ_y``.
    sigma_z : jnp.ndarray
        Vertical dispersion coefficient [m].
    """
    (
        crosswind_intercept,
        crosswind_slope,
        crosswind_curvature,
        vertical_intercept,
        vertical_slope,
        vertical_curvature,
    ) = params
    # s = max(s₀, 1)
    clamped_distance = jnp.maximum(distance, 1.0)
    # ln s = log(s)
    log_distance = jnp.log(clamped_distance)
    # σ_y = exp(a_y + b_y ln s + c_y (ln s)²)
    crosswind_spread = jnp.exp(
        crosswind_intercept
        + crosswind_slope * log_distance
        + crosswind_curvature * log_distance**2
    )
    # σ_z = exp(a_z + b_z ln s + c_z (ln s)²)
    vertical_spread = jnp.exp(
        vertical_intercept
        + vertical_slope * log_distance
        + vertical_curvature * log_distance**2
    )
    return crosswind_spread, crosswind_spread, vertical_spread

get_dispersion_scheme

get_dispersion_scheme(scheme: str) -> tuple[dict[str, jnp.ndarray], DispersionFn]

Return (params_dict, calculator_fn) for a named dispersion scheme.

Parameters

scheme : str One of 'pg' (Pasquill-Gifford, default) or 'briggs'.

Raises

ValueError If scheme is not a registered key.

Source code in src/plumax/gauss_puff/_src/dispersion.py
def get_dispersion_scheme(
    scheme: str,
) -> tuple[dict[str, jnp.ndarray], DispersionFn]:
    """Return ``(params_dict, calculator_fn)`` for a named dispersion scheme.

    Parameters
    ----------
    scheme : str
        One of ``'pg'`` (Pasquill-Gifford, default) or ``'briggs'``.

    Raises
    ------
    ValueError
        If ``scheme`` is not a registered key.
    """
    if scheme not in DISPERSION_SCHEMES:
        raise ValueError(
            f"get_dispersion_scheme: `scheme` must be one of "
            f"{tuple(DISPERSION_SCHEMES)}, got {scheme!r}"
        )
    return DISPERSION_SCHEMES[scheme]

get_pg_params

get_pg_params(stability_class: str) -> jnp.ndarray

Return the Pasquill-Gifford parameter vector for a stability class.

Parameters

stability_class : str One of 'A', 'B', 'C', 'D', 'E', 'F'.

Returns

params : jnp.ndarray, shape (6,) [a_y, b_y, c_y, a_z, b_z, c_z].

Raises

ValueError If stability_class is not one of A-F.

Source code in src/plumax/gauss_puff/_src/dispersion.py
def get_pg_params(stability_class: str) -> jnp.ndarray:
    """Return the Pasquill-Gifford parameter vector for a stability class.

    Parameters
    ----------
    stability_class : str
        One of ``'A'``, ``'B'``, ``'C'``, ``'D'``, ``'E'``, ``'F'``.

    Returns
    -------
    params : jnp.ndarray, shape (6,)
        ``[a_y, b_y, c_y, a_z, b_z, c_z]``.

    Raises
    ------
    ValueError
        If ``stability_class`` is not one of A-F.
    """
    return lookup_stability(
        PG_DISPERSION_PARAMS, stability_class, caller="get_pg_params"
    )

evolve_puffs

evolve_puffs(schedule: WindSchedule, release_times: Float[Array, ' N'], current_time: Float[Array, ''], source_location: tuple[float, float, float], puff_mass: Float[Array, ' N'] | float, position_disturbance: tuple[Float[Array, ' N'], Float[Array, ' N']] | None = None) -> PuffState

Advance a puff ensemble to current_time under a time-varying wind.

Uses :func:cumulative_wind_integrals to compute (I_u, I_v, S) at the release times and at current_time in one call, then derives per-puff positions and travel distances as differences.

Puffs with release_times > current_time are "not yet released" — their mass is set to 0 and position is placed at the source, so they contribute nothing to the downstream field.

Parameters

schedule : WindSchedule Time-varying wind field. release_times : Float[Array, "N"] Puff release times [s], none before the schedule's first knot. current_time : Float[Array, ""] Evaluation time [s]. source_location : tuple of float, (3,) (x, y, z) source coordinates [m]. z ≥ 0. puff_mass : Float[Array, "N"] or float Per-puff mass [kg], or a scalar applied to all puffs. position_disturbance : tuple of Float[Array, "N"], optional Per-puff (Δx, Δy) offsets [m] applied on top of the wind advection. Intended for OU-process turbulence samples (see :func:plumax.gauss_puff.turbulence.sample_ou_offsets), but any caller-provided offset array is accepted. Offsets for not-yet-released puffs are ignored.

Returns

puff_state : PuffState Puff positions, travel distances, and masses at current_time.

Source code in src/plumax/gauss_puff/_src/puff.py
@eqx.filter_jit
def evolve_puffs(
    schedule: WindSchedule,
    release_times: Float[Array, " N"],
    current_time: Float[Array, ""],
    source_location: tuple[float, float, float],
    puff_mass: Float[Array, " N"] | float,
    position_disturbance: tuple[Float[Array, " N"], Float[Array, " N"]] | None = None,
) -> PuffState:
    """Advance a puff ensemble to ``current_time`` under a time-varying wind.

    Uses :func:`cumulative_wind_integrals` to compute ``(I_u, I_v, S)`` at the
    release times and at ``current_time`` in one call, then derives per-puff
    positions and travel distances as differences.

    Puffs with ``release_times > current_time`` are "not yet released" — their
    mass is set to 0 and position is placed at the source, so they contribute
    nothing to the downstream field.

    Parameters
    ----------
    schedule : WindSchedule
        Time-varying wind field.
    release_times : Float[Array, "N"]
        Puff release times [s], none before the schedule's first knot.
    current_time : Float[Array, ""]
        Evaluation time [s].
    source_location : tuple of float, (3,)
        ``(x, y, z)`` source coordinates [m]. ``z ≥ 0``.
    puff_mass : Float[Array, "N"] or float
        Per-puff mass [kg], or a scalar applied to all puffs.
    position_disturbance : tuple of Float[Array, "N"], optional
        Per-puff ``(Δx, Δy)`` offsets [m] applied on top of the wind advection.
        Intended for OU-process turbulence samples (see
        :func:`plumax.gauss_puff.turbulence.sample_ou_offsets`),
        but any caller-provided offset array is accepted. Offsets for
        not-yet-released puffs are ignored.

    Returns
    -------
    puff_state : PuffState
        Puff positions, travel distances, and masses at ``current_time``.
    """
    current_time_array = jnp.asarray(current_time)
    # the release times, then t
    save_at = jnp.concatenate([release_times, einx.id(" -> 1", current_time_array)])
    east, north, travel = cumulative_wind_integrals(schedule, save_at)
    at_release = (east[:-1], north[:-1], travel[:-1])
    now = (east[-1], north[-1], travel[-1])
    return _puffs_at(
        current_time_array,
        release_times,
        at_release,
        now,
        source_location,
        puff_mass,
        position_disturbance,
    )

frequency_to_release_interval

frequency_to_release_interval(release_frequency: float) -> float

Convert a release frequency f [Hz] into a release interval Δt [s].

Δt = 1 / f.

Source code in src/plumax/gauss_puff/_src/puff.py
def frequency_to_release_interval(release_frequency: float) -> float:
    """Convert a release frequency f [Hz] into a release interval Δt [s].

    ``Δt = 1 / f``.
    """
    require_positive(
        "release_frequency", release_frequency, caller="frequency_to_release_interval"
    )
    return 1.0 / release_frequency

make_release_times

make_release_times(t_start: float, t_end: float, release_frequency: float) -> jnp.ndarray

Evenly spaced puff release times in [t_start, t_end).

Parameters

t_start, t_end : float Simulation time window [s]. t_start < t_end required. release_frequency : float Puff release rate [Hz]. Must be > 0.

Returns

release_times : jnp.ndarray, shape (N,) Times [t_start, t_start + Δt, t_start + 2Δt, ...] with Δt = 1 / release_frequency, all strictly less than t_end, in the default float dtype (float64 with 64-bit JAX).

Raises

ValueError If the window is empty, or the times are too far from their epoch for the dtype to resolve a hundredth of Δt (float32 at a Unix time).

Notes

The count is ceil((t_end − t_start) / Δt), snapped to the nearest integer within 1e-9 relative, so a window of K whole intervals gets K releases even where floating point rounds the quotient just above K. When the window is not an exact multiple of Δt the final, partial interval still gets a release (e.g. [0, 0.5) at 1 Hz yields one puff at t = 0, and [0, 10.5) yields eleven). That trailing puff represents a shorter slice of the continuous source, so its emitted mass must be weighted by its actual interval duration — see :func:release_durations and how simulate_puff assigns puff_mass. All release times remain strictly < t_end.

Source code in src/plumax/gauss_puff/_src/puff.py
def make_release_times(
    t_start: float,
    t_end: float,
    release_frequency: float,
) -> jnp.ndarray:
    """Evenly spaced puff release times in ``[t_start, t_end)``.

    Parameters
    ----------
    t_start, t_end : float
        Simulation time window [s]. ``t_start < t_end`` required.
    release_frequency : float
        Puff release rate [Hz]. Must be > 0.

    Returns
    -------
    release_times : jnp.ndarray, shape (N,)
        Times ``[t_start, t_start + Δt, t_start + 2Δt, ...]`` with
        ``Δt = 1 / release_frequency``, all strictly less than ``t_end``, in
        the default float dtype (float64 with 64-bit JAX).

    Raises
    ------
    ValueError
        If the window is empty, or the times are too far from their epoch for
        the dtype to resolve a hundredth of ``Δt`` (float32 at a Unix time).

    Notes
    -----
    The count is ``ceil((t_end − t_start) / Δt)``, snapped to the nearest
    integer within 1e-9 relative, so a window of K whole intervals gets K
    releases even where floating point rounds the quotient just above K. When
    the window is not an exact multiple of ``Δt`` the **final, partial interval
    still gets a release** (e.g. ``[0, 0.5)`` at 1 Hz yields one puff at ``t = 0``, and
    ``[0, 10.5)`` yields eleven). That trailing puff represents a shorter slice
    of the continuous source, so its emitted mass must be weighted by its actual
    interval duration — see :func:`release_durations` and how ``simulate_puff``
    assigns ``puff_mass``. All release times remain strictly ``< t_end``.
    """
    if not (t_end > t_start):
        raise ValueError(
            f"make_release_times: `t_end` must be > `t_start` "
            f"(got t_start={t_start!r}, t_end={t_end!r})"
        )
    release_interval = frequency_to_release_interval(release_frequency)
    # N = ⌈(t_end − t_start) / Δt⌉, snapped within 1e-9 relative
    num_puffs = _count_steps(t_end - t_start, release_interval)
    # t_i = t_start + i Δt
    times = t_start + np.arange(num_puffs) * release_interval
    release_times = jnp.asarray(times, dtype=float)
    _check_time_resolution(
        times, release_interval, release_times.dtype, caller="make_release_times"
    )
    return release_times

puff_concentration

puff_concentration(x: ndarray, y: ndarray, z: ndarray, puff_x: Float[ArrayLike, ''], puff_y: Float[ArrayLike, ''], puff_z: Float[ArrayLike, ''], sigma_x: Float[ArrayLike, ''], sigma_y: Float[ArrayLike, ''], sigma_z: Float[ArrayLike, ''], puff_mass: Float[ArrayLike, '']) -> jnp.ndarray

Evaluate the concentration from a single Gaussian puff (JIT).

Includes ground-reflection via an image source at z = −puff_z.

Parameters

x, y, z : jnp.ndarray Receptor coordinates [m]. Broadcast-compatible. puff_x, puff_y, puff_z : float Puff-centre position [m]. puff_z ≥ 0. sigma_x, sigma_y, sigma_z : float Dispersion coefficients [m]. All > 0. puff_mass : float Mass of the puff [kg]. Must be ≥ 0.

Returns

concentration : jnp.ndarray Mass concentration [kg/m³], same shape as the broadcast of the input coordinates.

Source code in src/plumax/gauss_puff/_src/puff.py
@jit
def puff_concentration(
    x: jnp.ndarray,
    y: jnp.ndarray,
    z: jnp.ndarray,
    puff_x: Float[ArrayLike, ""],
    puff_y: Float[ArrayLike, ""],
    puff_z: Float[ArrayLike, ""],
    sigma_x: Float[ArrayLike, ""],
    sigma_y: Float[ArrayLike, ""],
    sigma_z: Float[ArrayLike, ""],
    puff_mass: Float[ArrayLike, ""],
) -> jnp.ndarray:
    """Evaluate the concentration from a single Gaussian puff (JIT).

    Includes ground-reflection via an image source at ``z = −puff_z``.

    Parameters
    ----------
    x, y, z : jnp.ndarray
        Receptor coordinates [m]. Broadcast-compatible.
    puff_x, puff_y, puff_z : float
        Puff-centre position [m]. ``puff_z ≥ 0``.
    sigma_x, sigma_y, sigma_z : float
        Dispersion coefficients [m]. All > 0.
    puff_mass : float
        Mass of the puff [kg]. Must be ≥ 0.

    Returns
    -------
    concentration : jnp.ndarray
        Mass concentration [kg/m³], same shape as the broadcast of the input
        coordinates.
    """
    # Δx = x − x_p
    offset_x = x - puff_x
    # Δy = y − y_p
    offset_y = y - puff_y
    # Δz₋ = z − z_p
    offset_z_direct = z - puff_z
    # Δz₊ = z + z_p
    offset_z_reflected = z + puff_z

    normalization = jnp.power(2.0 * jnp.pi, 1.5) * sigma_x * sigma_y * sigma_z

    # exp(−Δx² / 2σ_x²)
    exp_x = jnp.exp(-0.5 * jnp.square(offset_x / sigma_x))
    # exp(−Δy² / 2σ_y²)
    exp_y = jnp.exp(-0.5 * jnp.square(offset_y / sigma_y))
    # exp(−Δz₋² / 2σ_z²)
    exp_z_direct = jnp.exp(-0.5 * jnp.square(offset_z_direct / sigma_z))
    # exp(−Δz₊² / 2σ_z²)
    exp_z_reflected = jnp.exp(-0.5 * jnp.square(offset_z_reflected / sigma_z))

    return (
        (puff_mass / normalization) * exp_x * exp_y * (exp_z_direct + exp_z_reflected)
    )

release_durations

release_durations(release_times: ndarray, t_end: float) -> jnp.ndarray

Per-puff emission-interval durations [s] for a continuous source.

Each puff carries the mass emitted over its interval, i.e. up to the next release (or t_end for the last puff). The durations therefore sum to t_end − release_times[0] exactly: interior intervals equal the release spacing Δt while the final, possibly partial interval is the remainder. Multiply by the emission rate Q to get the per-puff mass.

Parameters

release_times : jnp.ndarray, shape (N,) Monotone increasing release times [s], as from :func:make_release_times. t_end : float End of the emission window [s]; must exceed the last release time.

Returns

durations : jnp.ndarray, shape (N,) Per-puff interval durations [s], all > 0, in the default float dtype.

Source code in src/plumax/gauss_puff/_src/puff.py
def release_durations(
    release_times: jnp.ndarray,
    t_end: float,
) -> jnp.ndarray:
    """Per-puff emission-interval durations [s] for a continuous source.

    Each puff carries the mass emitted over its interval, i.e. up to the next
    release (or ``t_end`` for the last puff). The durations therefore sum to
    ``t_end − release_times[0]`` exactly: interior intervals equal the release
    spacing ``Δt`` while the final, possibly partial interval is the remainder.
    Multiply by the emission rate ``Q`` to get the per-puff mass.

    Parameters
    ----------
    release_times : jnp.ndarray, shape (N,)
        Monotone increasing release times [s], as from
        :func:`make_release_times`.
    t_end : float
        End of the emission window [s]; must exceed the last release time.

    Returns
    -------
    durations : jnp.ndarray, shape (N,)
        Per-puff interval durations [s], all > 0, in the default float dtype.
    """
    rel = np.asarray(release_times, dtype=np.float64)
    if rel.size == 0:
        return jnp.zeros((0,), dtype=float)
    edges = np.append(rel, float(t_end))
    # Δt_i = t_{i+1} − t_i, with t_N = t_end
    return jnp.asarray(np.diff(edges), dtype=float)

release_interval_to_frequency

release_interval_to_frequency(release_interval: float) -> float

Convert a release interval Δt [s] into a release frequency f [Hz].

f = 1 / Δt. Both Δt and f are common ways to parametrise puff cadence; this pair of helpers makes the conversion explicit.

Source code in src/plumax/gauss_puff/_src/puff.py
def release_interval_to_frequency(release_interval: float) -> float:
    """Convert a release interval Δt [s] into a release frequency f [Hz].

    ``f = 1 / Δt``. Both Δt and f are common ways to parametrise puff cadence;
    this pair of helpers makes the conversion explicit.
    """
    require_positive(
        "release_interval", release_interval, caller="release_interval_to_frequency"
    )
    return 1.0 / release_interval

simulate_puff

simulate_puff(emission_rate: float | ndarray, source_location: tuple[float, float, float], wind_speed: ndarray, wind_direction: ndarray, stability_class: str, domain_x: tuple[float, float, int], domain_y: tuple[float, float, int], domain_z: tuple[float, float, int], time_array: ndarray, release_frequency: float = 1.0, scheme: str = 'pg', background_conc: float = 0.0, turbulence: OUTurbulence | None = None, turbulence_seed: int | Generator | None = None) -> xr.Dataset

Simulate a time-resolved Gaussian-puff dispersion field on a 3-D grid.

Wraps :func:evolve_puffs + :func:simulate_puff_field with grid construction, the cumulative integrals of a time-varying wind, and optional column integration. Returns an :class:xarray.Dataset with variables on a (time, x, y, z) grid.

Parameters

emission_rate : float or ndarray Continuous emission rate Q [kg/s]. Scalar constant Q, or an array of length n_puffs specifying Q at each puff release time. The puff mass is Q · Δt_release with Δt_release = 1/release_frequency. Entries must be ≥ 0 (scalar or array); Q = 0 yields a zero field. source_location : tuple of float, (3,) (x, y, z) source coordinates [m]. z ≥ 0. wind_speed : ndarray, shape (T_w,) Wind speed [m/s] at each entry in time_array. Must be same length. wind_direction : ndarray, shape (T_w,) Wind direction [deg from North]. Same length as time_array. stability_class : str One of 'A', …, 'F'. domain_x, domain_y, domain_z : tuple of (float, float, int) (start, stop, n_points) for each axis. time_array : ndarray, shape (T,) Monotone increasing evaluation times [s]. release_frequency : float Puff release rate [Hz]. Δt_release = 1/release_frequency. Default 1 Hz. scheme : str Dispersion scheme: 'pg' (Pasquill-Gifford, default) or 'briggs' (sharing coefficients with the steady plume model). background_conc : float Additive background concentration [kg/m³]. Default 0. turbulence : OUTurbulence, optional Ornstein-Uhlenbeck sub-grid turbulence applied as per-puff (Δx, Δy) offsets at release time. Adds realistic meander on top of the wind-driven advection. Defaults to None (deterministic puffs). turbulence_seed : int or numpy.random.Generator, optional Seed for the OU sampler; required for bit-exact reproducibility when turbulence is set.

Returns

ds : xarray.Dataset Variables: concentration (time, x, y, z) [kg/m³], column_concentration (time, x, y) [kg/m²], wind_speed/wind_direction (time,).

Raises

ValueError On invalid stability class, non-positive emission rate, shape mismatches, unknown scheme, or malformed domain tuples.

Source code in src/plumax/gauss_puff/_src/puff.py
def simulate_puff(
    emission_rate: float | np.ndarray,
    source_location: tuple[float, float, float],
    wind_speed: np.ndarray,
    wind_direction: np.ndarray,
    stability_class: str,
    domain_x: tuple[float, float, int],
    domain_y: tuple[float, float, int],
    domain_z: tuple[float, float, int],
    time_array: np.ndarray,
    release_frequency: float = 1.0,
    scheme: str = "pg",
    background_conc: float = 0.0,
    turbulence: OUTurbulence | None = None,
    turbulence_seed: int | np.random.Generator | None = None,
) -> xr.Dataset:
    """Simulate a time-resolved Gaussian-puff dispersion field on a 3-D grid.

    Wraps :func:`evolve_puffs` + :func:`simulate_puff_field` with grid
    construction, the cumulative integrals of a time-varying wind, and optional
    column integration. Returns an :class:`xarray.Dataset` with variables
    on a ``(time, x, y, z)`` grid.

    Parameters
    ----------
    emission_rate : float or ndarray
        Continuous emission rate Q [kg/s]. Scalar constant Q, or an array of
        length ``n_puffs`` specifying Q at each puff release time. The puff
        mass is ``Q · Δt_release`` with ``Δt_release = 1/release_frequency``.
        Entries must be ≥ 0 (scalar or array); ``Q = 0`` yields a zero field.
    source_location : tuple of float, (3,)
        ``(x, y, z)`` source coordinates [m]. ``z ≥ 0``.
    wind_speed : ndarray, shape (T_w,)
        Wind speed [m/s] at each entry in ``time_array``. Must be same length.
    wind_direction : ndarray, shape (T_w,)
        Wind direction [deg from North]. Same length as ``time_array``.
    stability_class : str
        One of ``'A'``, …, ``'F'``.
    domain_x, domain_y, domain_z : tuple of (float, float, int)
        ``(start, stop, n_points)`` for each axis.
    time_array : ndarray, shape (T,)
        Monotone increasing evaluation times [s].
    release_frequency : float
        Puff release rate [Hz]. Δt_release = 1/release_frequency. Default 1 Hz.
    scheme : str
        Dispersion scheme: ``'pg'`` (Pasquill-Gifford, default) or
        ``'briggs'`` (sharing coefficients with the steady plume model).
    background_conc : float
        Additive background concentration [kg/m³]. Default 0.
    turbulence : OUTurbulence, optional
        Ornstein-Uhlenbeck sub-grid turbulence applied as per-puff ``(Δx, Δy)``
        offsets at release time. Adds realistic meander on top of the
        wind-driven advection. Defaults to ``None`` (deterministic puffs).
    turbulence_seed : int or numpy.random.Generator, optional
        Seed for the OU sampler; required for bit-exact reproducibility
        when ``turbulence`` is set.

    Returns
    -------
    ds : xarray.Dataset
        Variables: ``concentration`` ``(time, x, y, z)`` [kg/m³],
        ``column_concentration`` ``(time, x, y)`` [kg/m²],
        ``wind_speed``/``wind_direction`` ``(time,)``.

    Raises
    ------
    ValueError
        On invalid stability class, non-positive emission rate, shape
        mismatches, unknown scheme, or malformed domain tuples.
    """
    import xarray as xr  # lazy — only this entry point requires xarray

    scheme_params_dict, dispersion_fn = get_dispersion_scheme(scheme)

    check_stability(stability_class, caller="simulate_puff", table=scheme_params_dict)
    check_source(source_location, caller="simulate_puff")
    # the default float dtype: float64 with 64-bit JAX, else float32
    dtype = jnp.result_type(float)
    time_array = np.asarray(time_array, dtype=dtype)
    wind_speed = np.asarray(wind_speed, dtype=dtype)
    wind_direction = np.asarray(wind_direction, dtype=dtype)
    if time_array.ndim != 1 or time_array.size < 2:
        raise ValueError("simulate_puff: `time_array` must be 1-D with ≥ 2 entries")
    if wind_speed.shape != time_array.shape:
        raise ValueError(
            f"simulate_puff: `wind_speed` shape {wind_speed.shape} must match "
            f"`time_array` shape {time_array.shape}"
        )
    if wind_direction.shape != time_array.shape:
        raise ValueError(
            f"simulate_puff: `wind_direction` shape {wind_direction.shape} "
            f"must match `time_array` shape {time_array.shape}"
        )
    require_positive("wind_speed", wind_speed, caller="simulate_puff", allow_zero=True)

    check_domain("domain_x", domain_x, caller="simulate_puff")
    check_domain("domain_y", domain_y, caller="simulate_puff")
    check_domain("domain_z", domain_z, caller="simulate_puff")
    require_positive("release_frequency", release_frequency, caller="simulate_puff")

    dispersion_params = scheme_params_dict[stability_class]

    x_grid = node_axis(domain_x)
    y_grid = node_axis(domain_y)
    z_grid = node_axis(domain_z)
    num_x, num_y, num_levels = len(x_grid), len(y_grid), len(z_grid)
    num_times = len(time_array)

    mesh_x_flat, mesh_y_flat, mesh_z_flat = flat_mesh(x_grid, y_grid, z_grid)
    x_flat = jnp.asarray(mesh_x_flat, dtype=dtype)
    y_flat = jnp.asarray(mesh_y_flat, dtype=dtype)
    z_flat = jnp.asarray(mesh_z_flat, dtype=dtype)

    release_interval = frequency_to_release_interval(release_frequency)
    release_times = make_release_times(
        float(time_array[0]), float(time_array[-1]), release_frequency
    )
    num_puffs = int(release_times.shape[0])
    # Per-puff emission-interval durations: full Δt for interior puffs, the
    # remainder for the final (possibly partial) interval. Weighting mass by
    # these durations conserves the total emitted mass Q·(t_end − t_start) even
    # when the window is not an exact multiple of the release interval.
    durations = release_durations(release_times, float(time_array[-1]))

    if np.ndim(emission_rate) == 0:
        q_scalar = float(emission_rate)
        require_positive(
            "emission_rate", q_scalar, caller="simulate_puff", allow_zero=True
        )
        # m_i = Q Δt_i
        puff_mass = jnp.asarray(q_scalar * durations, dtype=dtype)
    else:
        emission_array = np.asarray(emission_rate, dtype=dtype)
        if emission_array.shape != (num_puffs,):
            raise ValueError(
                f"simulate_puff: array `emission_rate` must have shape "
                f"({num_puffs},) matching the number of releases in "
                f"[t_start, t_end) at release_frequency={release_frequency}, "
                f"got {emission_array.shape}"
            )
        require_positive(
            "emission_rate", emission_array, caller="simulate_puff", allow_zero=True
        )
        # m_i = Q_i Δt_i
        puff_mass = jnp.asarray(emission_array * np.asarray(durations), dtype=dtype)

    schedule = WindSchedule.from_speed_direction(time_array, wind_speed, wind_direction)

    if turbulence is not None:
        from plumax.gauss_puff.turbulence import sample_ou_offsets

        offset_x_np, offset_y_np = sample_ou_offsets(
            turbulence,
            np.asarray(release_times),
            seed=turbulence_seed,
        )
        position_disturbance = (
            jnp.asarray(offset_x_np, dtype=dtype),
            jnp.asarray(offset_y_np, dtype=dtype),
        )
    else:
        position_disturbance = None

    # (I_u, I_v, S) at every release and every output time, in one call; the
    # xarray entry point compiles its per-time field once
    output_times = jnp.asarray(time_array, dtype=dtype)
    save_at = jnp.concatenate([release_times, output_times])
    east, north, travel = cumulative_wind_integrals(schedule, save_at)
    at_release = (east[:num_puffs], north[:num_puffs], travel[:num_puffs])

    @eqx.filter_jit
    def field_at(current_time, east_now, north_now, travel_now):
        puff_state = _puffs_at(
            current_time,
            release_times,
            at_release,
            (east_now, north_now, travel_now),
            source_location,
            puff_mass,
            position_disturbance,
        )
        return simulate_puff_field(
            (x_flat, y_flat, z_flat),
            puff_state,
            dispersion_params,
            dispersion_fn,
        )

    concentration = np.zeros((num_times, num_x, num_y, num_levels), dtype=dtype)
    for time_index in range(num_times):
        output_index = num_puffs + time_index
        field_flat = field_at(
            output_times[time_index],
            east[output_index],
            north[output_index],
            travel[output_index],
        )
        field_np = np.asarray(field_flat)
        concentration[time_index] = einx.id(
            "(x y z) -> x y z", field_np, x=num_x, y=num_y
        )

    # C = C + C_bg
    concentration = concentration + background_conc

    # Trapezoidal vertical integration over the (endpoint-inclusive) z grid;
    # a plain ``sum * dz`` over-counts a vertically uniform component (such as
    # the background) by one grid interval. See gauss_plume.simulate_plume.
    # h_k, the trapezoid weights on the levels z_k
    levels = functax_quad.trapezoid(z_grid)
    # Ω(t, x, y) = Σ_k h_k C(t, x, y, z_k)
    integral = integrix_rule.integrate(levels, concentration, axis=3)
    column = np.asarray(integral.value)

    dataset = xr.Dataset(
        data_vars={
            "concentration": (["time", "x", "y", "z"], concentration),
            "column_concentration": (["time", "x", "y"], column),
            "wind_speed": (["time"], np.asarray(wind_speed)),
            "wind_direction": (["time"], np.asarray(wind_direction)),
        },
        coords={
            "time": np.asarray(time_array),
            "x": x_grid,
            "y": y_grid,
            "z": z_grid,
        },
        attrs={
            "title": "Gaussian puff dispersion (JAX)",
            "source_x": float(source_location[0]),
            "source_y": float(source_location[1]),
            "source_z": float(source_location[2]),
            "stability_class": stability_class,
            "dispersion_scheme": scheme,
            "release_frequency": release_frequency,
            "release_interval": release_interval,
            "n_puffs": num_puffs,
            "background_concentration": background_conc,
            "ou_sigma_fluctuations": (
                float(turbulence.sigma_fluctuations) if turbulence else 0.0
            ),
            "ou_correlation_time": (
                float(turbulence.correlation_time) if turbulence else 0.0
            ),
        },
    )
    label_concentrations(dataset)
    dataset["wind_speed"].attrs = {"long_name": "Wind speed", "units": "m/s"}
    dataset["wind_direction"].attrs = {
        "long_name": "Wind direction",
        "units": "degrees from North (meteorological)",
    }
    return dataset

simulate_puff_field

simulate_puff_field(receptor_coords: tuple[Float[Array, ' P'], Float[Array, ' P'], Float[Array, ' P']], puff_state: PuffState, dispersion_params: Float[Array, ' 6'], dispersion_fn: Callable) -> Float[Array, ' P']

Sum the contributions of all puffs at each receptor.

Parameters

receptor_coords : tuple of Float[Array, "P"] (x, y, z) receptor coordinates [m]. puff_state : PuffState Per-puff positions, travel distances, and masses. dispersion_params : Float[Array, " 6"] Dispersion coefficient vector for the chosen scheme and stability class. dispersion_fn : callable A function with signature (distance, params) → (σ_x, σ_y, σ_z). See :func:plumax.gauss_puff.dispersion.calculate_pg_dispersion and :func:calculate_briggs_dispersion_xyz.

Returns

concentration : Float[Array, "P"] Total concentration [kg/m³] at each receptor.

Source code in src/plumax/gauss_puff/_src/puff.py
def simulate_puff_field(
    receptor_coords: tuple[Float[Array, " P"], Float[Array, " P"], Float[Array, " P"]],
    puff_state: PuffState,
    dispersion_params: Float[Array, " 6"],
    dispersion_fn: Callable,
) -> Float[Array, " P"]:
    """Sum the contributions of all puffs at each receptor.

    Parameters
    ----------
    receptor_coords : tuple of Float[Array, "P"]
        ``(x, y, z)`` receptor coordinates [m].
    puff_state : PuffState
        Per-puff positions, travel distances, and masses.
    dispersion_params : Float[Array, " 6"]
        Dispersion coefficient vector for the chosen scheme and stability class.
    dispersion_fn : callable
        A function with signature ``(distance, params) → (σ_x, σ_y, σ_z)``.
        See :func:`plumax.gauss_puff.dispersion.calculate_pg_dispersion`
        and :func:`calculate_briggs_dispersion_xyz`.

    Returns
    -------
    concentration : Float[Array, "P"]
        Total concentration [kg/m³] at each receptor.
    """
    receptor_x, receptor_y, receptor_z = receptor_coords

    spread_x, crosswind_spread, vertical_spread = dispersion_fn(
        puff_state.travel_distance, dispersion_params
    )

    per_puff = puff_concentration_vmap(
        receptor_x,
        receptor_y,
        receptor_z,
        puff_state.x,
        puff_state.y,
        puff_state.z,
        spread_x,
        crosswind_spread,
        vertical_spread,
        puff_state.mass,
    )
    if per_puff.shape[0] == 0:
        # einx rejects a zero-size axis; no puffs add no concentration
        return jnp.zeros(per_puff.shape[1:], dtype=per_puff.dtype)
    # C(r) = Σ_i C_i(r)
    return einx.sum("[puff] P", per_puff)

sample_ou_offsets

sample_ou_offsets(turbulence: OUTurbulence, release_times: Float[ndarray, ' N'] | ndarray, seed: int | Generator | None = None) -> tuple[np.ndarray, np.ndarray]

Draw per-puff (Δx, Δy) offsets from a 2-D OU process at release times.

Integrates the OU SDE via its exact transition density — the two-point Gaussian update that is exact for constant coefficients — so the result is statistically correct even for coarse release_times spacing and does not accumulate Euler-Maruyama bias.

Parameters

turbulence : OUTurbulence Turbulence parameters. release_times : ndarray, shape (N,) Puff release times [s]. Must be monotone non-decreasing. The first puff starts at the OU stationary distribution so the ensemble is already mixed (no warm-up transient visible in the field). seed : int or numpy.random.Generator, optional Seed or generator for reproducibility. If None a fresh default generator is used and results will vary across calls.

Returns

dx, dy : ndarray, shape (N,) Per-puff position offsets [m], to be added to the advected puff centres in :func:~plumax.gauss_puff.puff.evolve_puffs.

Source code in src/plumax/gauss_puff/_src/turbulence.py
def sample_ou_offsets(
    turbulence: OUTurbulence,
    release_times: Float[np.ndarray, " N"] | np.ndarray,
    seed: int | np.random.Generator | None = None,
) -> tuple[np.ndarray, np.ndarray]:
    """Draw per-puff (Δx, Δy) offsets from a 2-D OU process at release times.

    Integrates the OU SDE via its *exact* transition density — the two-point
    Gaussian update that is exact for constant coefficients — so the result
    is statistically correct even for coarse ``release_times`` spacing and
    does not accumulate Euler-Maruyama bias.

    Parameters
    ----------
    turbulence : OUTurbulence
        Turbulence parameters.
    release_times : ndarray, shape (N,)
        Puff release times [s]. Must be monotone non-decreasing. The first
        puff starts at the OU stationary distribution so the ensemble is
        already mixed (no warm-up transient visible in the field).
    seed : int or numpy.random.Generator, optional
        Seed or generator for reproducibility. If ``None`` a fresh default
        generator is used and results will vary across calls.

    Returns
    -------
    dx, dy : ndarray, shape (N,)
        Per-puff position offsets [m], to be added to the advected puff
        centres in :func:`~plumax.gauss_puff.puff.evolve_puffs`.
    """
    release_array = np.asarray(release_times, dtype=np.float64)
    if release_array.size == 0:
        return np.empty((0,), dtype=np.float64), np.empty((0,), dtype=np.float64)
    rel = einx.id("... -> (...)", release_array)
    if np.any(np.diff(rel) < 0.0):
        raise ValueError(
            "sample_ou_offsets: `release_times` must be monotone non-decreasing."
        )

    rng = seed if isinstance(seed, np.random.Generator) else np.random.default_rng(seed)

    fluctuation_amplitude = float(turbulence.sigma_fluctuations)
    correlation_time = float(turbulence.correlation_time)
    stationary_std = turbulence.stationary_std

    num_releases = rel.size
    offset_x = np.empty(num_releases, dtype=np.float64)
    offset_y = np.empty(num_releases, dtype=np.float64)

    # Initial puff drawn from the stationary distribution so the trajectory
    # is already mixed — no need to run burn-in before the first release.
    # p₀ = σ_∞ ξ,   ξ ~ 𝒩(0, I)
    initial_draw = rng.standard_normal(2) * stationary_std
    offset_x[0] = initial_draw[0]
    offset_y[0] = initial_draw[1]

    # σ_f = 0 → deterministic OU, stays at the initial draw (which will
    # itself be exactly zero since σ_inf = 0). Shortcut to avoid spurious
    # zero-variance noise draws.
    if fluctuation_amplitude == 0.0:
        offset_x[:] = 0.0
        offset_y[:] = 0.0
        return offset_x, offset_y

    for index in range(1, num_releases):
        # Δτ = τ_i − τ_{i−1}
        time_step = rel[index] - rel[index - 1]
        # a = exp(−Δτ / τ_c)
        decay = np.exp(-time_step / correlation_time)
        # Conditional variance of p(t+Δt) | p(t) under the exact OU transition.
        # v = σ_∞² (1 − a²)
        step_var = stationary_std**2 * (1.0 - decay**2)
        # s = √max(v, 0)
        step_std = np.sqrt(max(step_var, 0.0))
        noise = rng.standard_normal(2)
        # p_i = a p_{i−1} + s ξ
        offset_x[index] = decay * offset_x[index - 1] + step_std * noise[0]
        offset_y[index] = decay * offset_y[index - 1] + step_std * noise[1]

    return offset_x, offset_y

cumulative_wind_integrals

cumulative_wind_integrals(schedule: WindSchedule, save_at: Float[Array, ' M'], rtol: float = 1e-08, atol: float = 1e-06) -> tuple[Float[Array, ' M'], Float[Array, ' M'], Float[Array, ' M']]

Running integrals of the wind and of its speed from the first knot.

I_u(s) = ∫{t_0}^{s} u dτ, I_v(s) = ∫ |V| dτ.}^{s} v dτ, S(s) = ∫_{t_0}^{s

Algorithm
  1. Put the knots and the save times together and sort them: the nodes t_n, between which the wind is linear.
  2. I_u and I_v: the running trapezoid sum on the nodes, I(t_n) = Σ_{m ≤ n} ½ (t_m − t_{m−1}) (û_{m−1} + û_m), exact for a linear wind (integrix.scan.cumulative).
  3. S: each interval [t_{n−1}, t_n] by adaptive Gauss–Kronrod, summed (integrix.adapt.cumulative_adaptive); |V| has a kink where the wind passes through zero, which the bisection resolves.
  4. Read each save time at its node.

The save times may come in any order and may repeat. Times past the last knot read the wind continued along the last segment. Every output has a finite reverse-mode gradient, in calm air too.

Parameters

schedule : WindSchedule Time-varying wind field. save_at : Float[Array, "M"] Times [s] at which to return the integrals, none before schedule.times[0]. rtol, atol : float Relative and absolute tolerance [m] of the Gauss–Kronrod rule on each interval of S; rtol is held at 10 ε of the wind's dtype or above (1.2e-6 in float32), which the rule can still meet.

Returns

I_u, I_v, S : Float[Array, "M"] Cumulative integrals of u, v, and wind speed [m], each at save_at.

Raises

ParameterError If a save time is before the first knot (when save_at is traced, when the compiled function runs).

Examples

A wind from 5 to 3 m/s over 10 s, read halfway: I_u = 5·5 − ½·0.2·5² = 22.5 m.

import jax.numpy as jnp schedule = WindSchedule( ... times=jnp.array([0.0, 10.0]), ... u_wind=jnp.array([5.0, 3.0]), ... v_wind=jnp.zeros(2), ... ) east, north, travel = cumulative_wind_integrals(schedule, jnp.array([5.0, 10.0])) tuple(round(float(value), 6) for value in east) (22.5, 40.0) bool(jnp.allclose(travel, east)) True

Source code in src/plumax/gauss_puff/_src/wind.py
def cumulative_wind_integrals(
    schedule: WindSchedule,
    save_at: Float[Array, " M"],
    rtol: float = 1e-8,
    atol: float = 1e-6,
) -> tuple[Float[Array, " M"], Float[Array, " M"], Float[Array, " M"]]:
    """Running integrals of the wind and of its speed from the first knot.

    I_u(s) = ∫_{t_0}^{s} u dτ,  I_v(s) = ∫_{t_0}^{s} v dτ,  S(s) = ∫_{t_0}^{s} |V| dτ.

    Algorithm:
        1. Put the knots and the save times together and sort them: the nodes
           t_n, between which the wind is linear.
        2. I_u and I_v: the running trapezoid sum on the nodes,
           I(t_n) = Σ_{m ≤ n} ½ (t_m − t_{m−1}) (û_{m−1} + û_m), exact for a
           linear wind (``integrix.scan.cumulative``).
        3. S: each interval [t_{n−1}, t_n] by adaptive Gauss–Kronrod, summed
           (``integrix.adapt.cumulative_adaptive``); |V| has a kink where the
           wind passes through zero, which the bisection resolves.
        4. Read each save time at its node.

    The save times may come in any order and may repeat. Times past the last
    knot read the wind continued along the last segment. Every output has a
    finite reverse-mode gradient, in calm air too.

    Parameters
    ----------
    schedule : WindSchedule
        Time-varying wind field.
    save_at : Float[Array, "M"]
        Times [s] at which to return the integrals, none before
        ``schedule.times[0]``.
    rtol, atol : float
        Relative and absolute tolerance [m] of the Gauss–Kronrod rule on each
        interval of S; ``rtol`` is held at 10 ε of the wind's dtype or above
        (1.2e-6 in float32), which the rule can still meet.

    Returns
    -------
    I_u, I_v, S : Float[Array, "M"]
        Cumulative integrals of u, v, and wind speed [m], each at ``save_at``.

    Raises
    ------
    ParameterError
        If a save time is before the first knot (when ``save_at`` is traced,
        when the compiled function runs).

    Examples
    --------
    A wind from 5 to 3 m/s over 10 s, read halfway: I_u = 5·5 − ½·0.2·5² = 22.5 m.

    >>> import jax.numpy as jnp
    >>> schedule = WindSchedule(
    ...     times=jnp.array([0.0, 10.0]),
    ...     u_wind=jnp.array([5.0, 3.0]),
    ...     v_wind=jnp.zeros(2),
    ... )
    >>> east, north, travel = cumulative_wind_integrals(schedule, jnp.array([5.0, 10.0]))
    >>> tuple(round(float(value), 6) for value in east)
    (22.5, 40.0)
    >>> bool(jnp.allclose(travel, east))
    True
    """
    save_at = jnp.asarray(save_at)
    first_knot = schedule.times[0]
    xp = np if is_concrete(save_at, first_knot) else jnp
    # bad = some t < t₀ (or NaN)
    bad = ~xp.all(xp.asarray(save_at) >= xp.asarray(first_knot))
    save_at = check_values(
        save_at,
        bad,
        "cumulative_wind_integrals: a save time is before the wind schedule's "
        "first knot; the integrals start there",
        error=ParameterError,
    )
    return _integrals(schedule, save_at, rtol, atol)

gaussian_puff_model

gaussian_puff_model(observations: ndarray | None = None, receptor_coords: tuple[ndarray, ndarray, ndarray] | None = None, observation_times: ndarray | None = None, source_location: tuple[float, float, float] | None = None, schedule: WindSchedule | None = None, release_times: ndarray | None = None, release_interval: float | None = None, stability_class: str = 'C', scheme: str = 'pg', prior_emission_rate_mean: float = 0.1, prior_emission_rate_std: float = 0.05, background_prior_std: float = 5e-07, obs_noise_std: float = 5e-07, puff_durations: ndarray | None = None, noise: Noise | None = None) -> jnp.ndarray

NumPyro model for the Gaussian puff forward with a constant Q prior.

Priors

emission_rate ~ LogNormal(μ_log, σ_log) [kg/s] background ~ HalfNormal(σ_bg) [kg/m³]

Likelihood

obs ~ noise(f_puff(emission_rate, ...) + background)

with noise defaulting to GaussianNoise(obs_noise_std), i.e. obs ~ Normal(f_puff + background, σ_obs).

where (μ_log, σ_log) are the log-space parameters derived from the requested real-scale (prior_emission_rate_mean, prior_emission_rate_std).

Parameters

observations : jnp.ndarray, shape (N,), optional Observed concentrations [kg/m³]. If None, runs in prior-predictive mode. receptor_coords : tuple of jnp.ndarray, optional (x, y, z) each shape (N,) [m]. observation_times : jnp.ndarray, shape (N,), optional Time at which each observation was taken [s]. Matches observations in length. source_location : tuple of float, (3,), optional schedule : WindSchedule, optional release_times : jnp.ndarray, shape (N_puffs,), optional release_interval : float, optional Δt_release [s]. Required (as a presence flag) when a forward evaluation is needed. Used for the per-puff mass m = Q · Δt only as a fallback when puff_durations is not supplied. puff_durations : jnp.ndarray, shape (N_puffs,), optional Per-puff emission-interval durations [s] (from :func:plumax.gauss_puff.puff.release_durations). When given, the per-puff mass is m_i = Q · duration_i — so the trailing, possibly partial interval carries only its actual duration, matching simulate_puff and conserving emitted mass. Falls back to Q · release_interval for every puff when omitted. stability_class : str scheme : str Dispersion scheme: 'pg' or 'briggs'. prior_emission_rate_mean, prior_emission_rate_std : float background_prior_std, obs_noise_std : float obs_noise_std is the σ of the default Gaussian noise; ignored when noise is given. noise : Noise, optional Observation-noise model from :mod:plumax.gauss_plume.likelihoods. Default None is GaussianNoise(obs_noise_std).

Source code in src/plumax/gauss_puff/_src/inference.py
def gaussian_puff_model(
    observations: jnp.ndarray | None = None,
    receptor_coords: tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray] | None = None,
    observation_times: jnp.ndarray | None = None,
    source_location: tuple[float, float, float] | None = None,
    schedule: WindSchedule | None = None,
    release_times: jnp.ndarray | None = None,
    release_interval: float | None = None,
    stability_class: str = "C",
    scheme: str = "pg",
    prior_emission_rate_mean: float = 0.1,
    prior_emission_rate_std: float = 0.05,
    background_prior_std: float = 5e-7,
    obs_noise_std: float = 5e-7,
    puff_durations: jnp.ndarray | None = None,
    noise: Noise | None = None,
) -> jnp.ndarray:
    """NumPyro model for the Gaussian puff forward with a constant Q prior.

    Priors:
        emission_rate ~ LogNormal(μ_log, σ_log)                     [kg/s]
        background    ~ HalfNormal(σ_bg)                            [kg/m³]

    Likelihood:
        obs ~ noise(f_puff(emission_rate, ...) + background)

    with ``noise`` defaulting to ``GaussianNoise(obs_noise_std)``, i.e.
    ``obs ~ Normal(f_puff + background, σ_obs)``.

    where ``(μ_log, σ_log)`` are the log-space parameters derived from the
    requested real-scale ``(prior_emission_rate_mean, prior_emission_rate_std)``.

    Parameters
    ----------
    observations : jnp.ndarray, shape (N,), optional
        Observed concentrations [kg/m³]. If None, runs in prior-predictive mode.
    receptor_coords : tuple of jnp.ndarray, optional
        ``(x, y, z)`` each shape (N,) [m].
    observation_times : jnp.ndarray, shape (N,), optional
        Time at which each observation was taken [s]. Matches ``observations``
        in length.
    source_location : tuple of float, (3,), optional
    schedule : WindSchedule, optional
    release_times : jnp.ndarray, shape (N_puffs,), optional
    release_interval : float, optional
        ``Δt_release`` [s]. Required (as a presence flag) when a forward
        evaluation is needed. Used for the per-puff mass ``m = Q · Δt`` only as
        a fallback when ``puff_durations`` is not supplied.
    puff_durations : jnp.ndarray, shape (N_puffs,), optional
        Per-puff emission-interval durations [s] (from
        :func:`plumax.gauss_puff.puff.release_durations`). When given, the
        per-puff mass is ``m_i = Q · duration_i`` — so the trailing, possibly
        partial interval carries only its actual duration, matching
        ``simulate_puff`` and conserving emitted mass. Falls back to
        ``Q · release_interval`` for every puff when omitted.
    stability_class : str
    scheme : str
        Dispersion scheme: ``'pg'`` or ``'briggs'``.
    prior_emission_rate_mean, prior_emission_rate_std : float
    background_prior_std, obs_noise_std : float
        ``obs_noise_std`` is the σ of the default Gaussian noise; ignored when
        ``noise`` is given.
    noise : Noise, optional
        Observation-noise model from :mod:`plumax.gauss_plume.likelihoods`.
        Default ``None`` is ``GaussianNoise(obs_noise_std)``.
    """
    _require_forward_inputs(
        observations,
        receptor_coords,
        observation_times,
        source_location,
        schedule,
        release_times,
        release_interval,
    )
    scheme_params_dict, dispersion_fn = get_dispersion_scheme(scheme)
    check_stability(
        stability_class, caller="gaussian_puff_model", table=scheme_params_dict
    )
    dispersion_params = scheme_params_dict[stability_class]

    emission = LognormalEmission.from_moments(
        prior_emission_rate_mean, prior_emission_rate_std
    )
    emission_rate = numpyro.sample(
        "emission_rate", dist.LogNormal(emission.loc, emission.scale)
    )
    background = numpyro.sample("background", dist.HalfNormal(background_prior_std))

    # The forward model is evaluated whenever its inputs are present —
    # independently of whether `observations` were provided. This keeps
    # NumPyro's `Predictive` path (observations=None + full inputs) producing
    # model-driven draws, while prior-predictive calls without forward inputs
    # fall through to a background-only draw.
    forward_ready = _forward_inputs_present(
        receptor_coords,
        observation_times,
        source_location,
        schedule,
        release_times,
        release_interval,
    )

    if forward_ready:
        if puff_durations is not None:
            puff_mass = emission_rate * jnp.asarray(puff_durations)
        else:
            puff_mass = emission_rate * release_interval * jnp.ones_like(release_times)
        predicted = _predict_observations(
            puff_mass,
            release_times,
            receptor_coords,
            observation_times,
            source_location,
            schedule,
            dispersion_params,
            dispersion_fn,
        )
        predicted = predicted + background
    else:
        predicted = background

    noise_model = GaussianNoise(std=obs_noise_std) if noise is None else noise
    return noise_model("obs", predicted, observations)

gaussian_puff_rw_model

gaussian_puff_rw_model(observations: ndarray, receptor_coords: tuple[ndarray, ndarray, ndarray], observation_times: ndarray, source_location: tuple[float, float, float], schedule: WindSchedule, release_times: ndarray, release_interval: float, stability_class: str = 'C', scheme: str = 'pg', prior_emission_rate_mean: float = 0.1, prior_emission_rate_std: float = 0.05, rw_step_std: float = 0.02, background_prior_std: float = 5e-07, obs_noise_std: float = 5e-07, puff_durations: ndarray | None = None, noise: Noise | None = None) -> jnp.ndarray

Random-walk state-space model for a time-varying emission rate Q_i.

Each puff i has its own emission rate Q_i. A Gaussian random walk on ln Q_i gives a smoothness prior, with the first step anchored by the LogNormal(prior_mean, prior_std) prior:

ln Q_0            ~ Normal(μ_log, σ_log)
ln Q_i | ln Q_{i−1} ~ Normal(ln Q_{i−1}, rw_step_std)        for i ≥ 1
Q_i              = exp(ln Q_i)                              [kg/s]

Likelihood is the same as :func:gaussian_puff_model, including the noise override (default GaussianNoise(obs_noise_std)).

Source code in src/plumax/gauss_puff/_src/inference.py
def gaussian_puff_rw_model(
    observations: jnp.ndarray,
    receptor_coords: tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray],
    observation_times: jnp.ndarray,
    source_location: tuple[float, float, float],
    schedule: WindSchedule,
    release_times: jnp.ndarray,
    release_interval: float,
    stability_class: str = "C",
    scheme: str = "pg",
    prior_emission_rate_mean: float = 0.1,
    prior_emission_rate_std: float = 0.05,
    rw_step_std: float = 0.02,
    background_prior_std: float = 5e-7,
    obs_noise_std: float = 5e-7,
    puff_durations: jnp.ndarray | None = None,
    noise: Noise | None = None,
) -> jnp.ndarray:
    """Random-walk state-space model for a time-varying emission rate Q_i.

    Each puff ``i`` has its own emission rate ``Q_i``. A Gaussian random walk
    on ``ln Q_i`` gives a smoothness prior, with the first step anchored by
    the LogNormal(``prior_mean``, ``prior_std``) prior:

        ln Q_0            ~ Normal(μ_log, σ_log)
        ln Q_i | ln Q_{i−1} ~ Normal(ln Q_{i−1}, rw_step_std)        for i ≥ 1
        Q_i              = exp(ln Q_i)                              [kg/s]

    Likelihood is the same as :func:`gaussian_puff_model`, including the
    ``noise`` override (default ``GaussianNoise(obs_noise_std)``).
    """
    scheme_params_dict, dispersion_fn = get_dispersion_scheme(scheme)
    check_stability(
        stability_class, caller="gaussian_puff_rw_model", table=scheme_params_dict
    )
    dispersion_params = scheme_params_dict[stability_class]

    num_puffs = release_times.shape[0]
    if num_puffs == 0:
        raise ValueError(
            "gaussian_puff_rw_model: `release_times` must contain ≥ 1 puff; "
            "got n_puffs=0. Check that t_end − t_start ≥ 1/release_frequency."
        )

    emission = LognormalEmission.from_moments(
        prior_emission_rate_mean, prior_emission_rate_std
    )

    innovations = numpyro.sample(
        "innovations",
        dist.Normal(0.0, 1.0).expand([num_puffs]).to_event(1),
    )
    # Build ln Q_i by cumulative sum of scaled innovations, first anchored
    # to the LogNormal prior location.
    # ln Q₀ = μ_log + σ_log ε₀
    first = emission.loc + emission.scale * innovations[0]
    # δ_i = σ_rw ε_i
    increments = rw_step_std * innovations[1:]
    # ln Q_i = ln Q₀ + Σ_{j ≤ i} δ_j
    cumulative_increments = jnp.cumsum(increments)
    later = first + cumulative_increments
    if num_puffs == 1:
        # einx rejects a zero-size axis; one puff is ln Q₀ alone
        log_q = einx.id(" -> 1", first)
    else:
        log_q = einx.id(", step -> (1 + step)", first, later)
    emission_series = numpyro.deterministic("emission_rate", jnp.exp(log_q))

    background = numpyro.sample("background", dist.HalfNormal(background_prior_std))

    if puff_durations is not None:
        puff_mass = emission_series * jnp.asarray(puff_durations)
    else:
        puff_mass = emission_series * release_interval
    predicted = _predict_observations(
        puff_mass,
        release_times,
        receptor_coords,
        observation_times,
        source_location,
        schedule,
        dispersion_params,
        dispersion_fn,
    )
    predicted = predicted + background

    noise_model = GaussianNoise(std=obs_noise_std) if noise is None else noise
    return noise_model("obs", predicted, observations)

infer_emission_rate

infer_emission_rate(observations: ndarray, observation_coords: tuple[ndarray, ndarray, ndarray], observation_times: ndarray, source_location: tuple[float, float, float], wind_times: ndarray, wind_speed: ndarray, wind_direction: ndarray, release_frequency: float, t_start: float, t_end: float, stability_class: str = 'C', scheme: str = 'pg', prior_mean: float = 0.1, prior_std: float = 0.05, obs_noise_std: float = 5e-07, num_warmup: int = 500, num_samples: int = 1000, num_chains: int = 1, seed: int = 0, progress_bar: bool = False, print_summary: bool = False, noise: Noise | None = None) -> dict[str, np.ndarray]

NUTS inference of a constant emission rate from puff observations.

Parameters

observations : ndarray, shape (N,) Observed concentrations [kg/m³]. observation_coords : tuple of ndarray, each shape (N,) (x, y, z) receptor coordinates [m]. observation_times : ndarray, shape (N,) Evaluation time for each observation [s]. source_location : tuple of float, (3,) wind_times, wind_speed, wind_direction : ndarray, shape (T_w,) Wind schedule. Direction follows the meteorological "from" convention. release_frequency : float Puff release rate [Hz]. t_start, t_end : float Simulation window [s]. Release times are laid down on [t_start, t_end). stability_class : str scheme : str Dispersion scheme: 'pg' or 'briggs'. prior_mean, prior_std : float Real-scale prior moments for Q. obs_noise_std : float σ of the default Gaussian noise; ignored when noise is given. num_warmup, num_samples, num_chains, seed : int progress_bar, print_summary : bool noise : Noise, optional Observation-noise model from :mod:plumax.gauss_plume.likelihoods. Default None is GaussianNoise(obs_noise_std).

Returns

samples : dict[str, ndarray] Posterior draws keyed by site name: 'emission_rate', 'background'.

Source code in src/plumax/gauss_puff/_src/inference.py
def infer_emission_rate(
    observations: np.ndarray,
    observation_coords: tuple[np.ndarray, np.ndarray, np.ndarray],
    observation_times: np.ndarray,
    source_location: tuple[float, float, float],
    wind_times: np.ndarray,
    wind_speed: np.ndarray,
    wind_direction: np.ndarray,
    release_frequency: float,
    t_start: float,
    t_end: float,
    stability_class: str = "C",
    scheme: str = "pg",
    prior_mean: float = 0.1,
    prior_std: float = 0.05,
    obs_noise_std: float = 5e-7,
    num_warmup: int = 500,
    num_samples: int = 1000,
    num_chains: int = 1,
    seed: int = 0,
    progress_bar: bool = False,
    print_summary: bool = False,
    noise: Noise | None = None,
) -> dict[str, np.ndarray]:
    """NUTS inference of a **constant** emission rate from puff observations.

    Parameters
    ----------
    observations : ndarray, shape (N,)
        Observed concentrations [kg/m³].
    observation_coords : tuple of ndarray, each shape (N,)
        ``(x, y, z)`` receptor coordinates [m].
    observation_times : ndarray, shape (N,)
        Evaluation time for each observation [s].
    source_location : tuple of float, (3,)
    wind_times, wind_speed, wind_direction : ndarray, shape (T_w,)
        Wind schedule. Direction follows the meteorological "from" convention.
    release_frequency : float
        Puff release rate [Hz].
    t_start, t_end : float
        Simulation window [s]. Release times are laid down on ``[t_start, t_end)``.
    stability_class : str
    scheme : str
        Dispersion scheme: ``'pg'`` or ``'briggs'``.
    prior_mean, prior_std : float
        Real-scale prior moments for Q.
    obs_noise_std : float
        σ of the default Gaussian noise; ignored when ``noise`` is given.
    num_warmup, num_samples, num_chains, seed : int
    progress_bar, print_summary : bool
    noise : Noise, optional
        Observation-noise model from :mod:`plumax.gauss_plume.likelihoods`.
        Default ``None`` is ``GaussianNoise(obs_noise_std)``.

    Returns
    -------
    samples : dict[str, ndarray]
        Posterior draws keyed by site name: ``'emission_rate'``, ``'background'``.
    """
    obs, coords, times = _validate_inference_inputs(
        "infer_emission_rate",
        observations,
        observation_coords,
        observation_times,
        wind_times,
        wind_speed,
        wind_direction,
        source_location,
        release_frequency,
        t_start,
        t_end,
        prior_mean,
        prior_std,
    )

    schedule = WindSchedule.from_speed_direction(wind_times, wind_speed, wind_direction)
    release_times = make_release_times(t_start, t_end, release_frequency)
    release_interval = frequency_to_release_interval(release_frequency)
    # Per-puff durations conserve emitted mass: the trailing partial interval
    # carries only its actual duration (matches simulate_puff).
    puff_durations = release_durations(release_times, t_end)

    obs_jax = jnp.asarray(obs)
    coords_jax = tuple(jnp.asarray(coord) for coord in coords)
    times_jax = jnp.asarray(times)

    draws = run_nuts(
        gaussian_puff_model,
        seed=seed,
        num_warmup=num_warmup,
        num_samples=num_samples,
        num_chains=num_chains,
        progress_bar=progress_bar,
        print_summary=print_summary,
        observations=obs_jax,
        receptor_coords=coords_jax,
        observation_times=times_jax,
        source_location=source_location,
        schedule=schedule,
        release_times=release_times,
        release_interval=release_interval,
        puff_durations=puff_durations,
        stability_class=stability_class,
        scheme=scheme,
        prior_emission_rate_mean=prior_mean,
        prior_emission_rate_std=prior_std,
        obs_noise_std=obs_noise_std,
        noise=noise,
    )
    return {site: np.asarray(value) for site, value in draws.items()}

infer_emission_timeseries

infer_emission_timeseries(observations: ndarray, observation_coords: tuple[ndarray, ndarray, ndarray], observation_times: ndarray, source_location: tuple[float, float, float], wind_times: ndarray, wind_speed: ndarray, wind_direction: ndarray, release_frequency: float, t_start: float, t_end: float, stability_class: str = 'C', scheme: str = 'pg', prior_mean: float = 0.1, prior_std: float = 0.05, rw_step_std: float = 0.02, obs_noise_std: float = 5e-07, num_warmup: int = 500, num_samples: int = 1000, num_chains: int = 1, seed: int = 0, progress_bar: bool = False, print_summary: bool = False, noise: Noise | None = None) -> dict[str, np.ndarray]

NUTS inference of a time-varying emission rate series Q_i.

Uses a Gaussian random-walk prior on ln Q along puff indices, anchored by the LogNormal(prior_mean, prior_std) prior on ln Q_0. See :func:gaussian_puff_rw_model. noise overrides the default GaussianNoise(obs_noise_std) likelihood.

Returns posterior draws with key 'emission_rate' of shape (num_samples, n_puffs).

Source code in src/plumax/gauss_puff/_src/inference.py
def infer_emission_timeseries(
    observations: np.ndarray,
    observation_coords: tuple[np.ndarray, np.ndarray, np.ndarray],
    observation_times: np.ndarray,
    source_location: tuple[float, float, float],
    wind_times: np.ndarray,
    wind_speed: np.ndarray,
    wind_direction: np.ndarray,
    release_frequency: float,
    t_start: float,
    t_end: float,
    stability_class: str = "C",
    scheme: str = "pg",
    prior_mean: float = 0.1,
    prior_std: float = 0.05,
    rw_step_std: float = 0.02,
    obs_noise_std: float = 5e-7,
    num_warmup: int = 500,
    num_samples: int = 1000,
    num_chains: int = 1,
    seed: int = 0,
    progress_bar: bool = False,
    print_summary: bool = False,
    noise: Noise | None = None,
) -> dict[str, np.ndarray]:
    """NUTS inference of a **time-varying** emission rate series Q_i.

    Uses a Gaussian random-walk prior on ``ln Q`` along puff indices, anchored
    by the LogNormal(``prior_mean``, ``prior_std``) prior on ``ln Q_0``. See
    :func:`gaussian_puff_rw_model`. ``noise`` overrides the default
    ``GaussianNoise(obs_noise_std)`` likelihood.

    Returns posterior draws with key ``'emission_rate'`` of shape
    ``(num_samples, n_puffs)``.
    """
    obs, coords, times = _validate_inference_inputs(
        "infer_emission_timeseries",
        observations,
        observation_coords,
        observation_times,
        wind_times,
        wind_speed,
        wind_direction,
        source_location,
        release_frequency,
        t_start,
        t_end,
        prior_mean,
        prior_std,
    )
    require_positive("rw_step_std", rw_step_std, caller="infer_emission_timeseries")
    require_positive("obs_noise_std", obs_noise_std, caller="infer_emission_timeseries")

    schedule = WindSchedule.from_speed_direction(wind_times, wind_speed, wind_direction)
    release_times = make_release_times(t_start, t_end, release_frequency)
    release_interval = frequency_to_release_interval(release_frequency)
    puff_durations = release_durations(release_times, t_end)

    draws = run_nuts(
        gaussian_puff_rw_model,
        seed=seed,
        num_warmup=num_warmup,
        num_samples=num_samples,
        num_chains=num_chains,
        progress_bar=progress_bar,
        print_summary=print_summary,
        observations=jnp.asarray(obs),
        receptor_coords=tuple(jnp.asarray(coord) for coord in coords),
        observation_times=jnp.asarray(times),
        source_location=source_location,
        schedule=schedule,
        release_times=release_times,
        release_interval=release_interval,
        puff_durations=puff_durations,
        stability_class=stability_class,
        scheme=scheme,
        prior_emission_rate_mean=prior_mean,
        prior_emission_rate_std=prior_std,
        rw_step_std=rw_step_std,
        obs_noise_std=obs_noise_std,
        noise=noise,
    )
    return {site: np.asarray(value) for site, value in draws.items()}