Gaussian plume¶
Steady-state Gaussian plume with Briggs dispersion, plus NumPyro emission-rate inference. Tier I.
gauss_plume
¶
Steady-state Gaussian plume model (JAX + NumPyro).
Submodules
- dispersion — Briggs σ_y(x), σ_z(x) coefficients (A-F stability classes)
- plume — coordinate rotation + JIT forward model + xarray wrapper
- inference — NumPyro Bayesian inference for Q (and optional stability)
The inference submodule is imported lazily on first attribute access so
that from plumax import gauss_plume does not pull in NumPyro
for consumers of only the forward model.
plume_concentration_vmap
module-attribute
¶
plume_concentration_vmap = vmap(plume_concentration, in_axes=(0, 0, 0, None, None, None, None, None, None, None), out_axes=0)
Vectorised over receptor locations — x, y, z batched along axis 0.
calculate_briggs_dispersion
¶
Evaluate σ_y(x), σ_z(x) from Briggs parameters.
σ_i(x) = a_i · x · (1 + b_i · x)^{c_i} for i ∈ {y, z}.
Parameters¶
distance : jnp.ndarray
Downwind distance from source [m]. Negative / zero values are clamped
to 1 m so that the coefficient evaluation stays finite; upwind points
are masked elsewhere in the plume model.
params : jnp.ndarray, shape (6,)
[a_y, b_y, c_y, a_z, b_z, c_z].
Returns¶
sigma_y : jnp.ndarray
Lateral dispersion coefficient [m], same shape as distance.
sigma_z : jnp.ndarray
Vertical dispersion coefficient [m], same shape as distance.
Source code in src/plumax/gauss_plume/dispersion.py
get_dispersion_params
¶
Return the Briggs 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_plume/dispersion.py
plume_concentration
¶
plume_concentration(x: ndarray, y: ndarray, z: ndarray, source_x: float, source_y: float, source_z: float, wind_u: float, wind_v: float, emission_rate: float, dispersion_params: ndarray) -> jnp.ndarray
Evaluate the steady-state Gaussian plume concentration.
Computes the mass concentration [kg/m³] at receptor points (x, y, z)
in the fixed reference frame. Coordinates are rotated into the
wind-aligned frame internally, upwind points are masked to zero, and
ground reflection is applied.
Parameters¶
x, y, z : jnp.ndarray
Receptor coordinates in the fixed frame [m]. Broadcast-compatible.
source_x, source_y, source_z : float
Source location [m]. source_z is the emission height above ground.
wind_u, wind_v : float
Wind velocity components [m/s]. The total wind speed is clamped
below to :data:MIN_WIND_SPEED for numerical stability.
emission_rate : float
Continuous emission rate Q [kg/s].
dispersion_params : jnp.ndarray, shape (6,)
[a_y, b_y, c_y, a_z, b_z, c_z] (Briggs parameters).
Returns¶
concentration : jnp.ndarray Mass concentration [kg/m³], same shape as the broadcast of the input coordinates. Zero at upwind locations (x' ≤ 0).
Source code in src/plumax/gauss_plume/plume.py
rotate_to_wind_frame
¶
rotate_to_wind_frame(x: ndarray, y: ndarray, source_x: float, source_y: float, wind_u: float, wind_v: float) -> tuple[jnp.ndarray, jnp.ndarray]
Rotate fixed-frame coordinates into the wind-aligned frame.
The wind-aligned frame has its origin at the source, its x'-axis pointing
downwind, and its y'-axis pointing crosswind (90° counter-clockwise from
x', following the right-hand rule). The rotation angle is
θ = atan2(wind_v, wind_u) [rad].
Parameters¶
x, y : jnp.ndarray Receptor coordinates in the fixed frame [m]. Must have matching shapes (or be broadcast-compatible). source_x, source_y : float Source location in the fixed frame [m]. wind_u, wind_v : float Wind velocity components [m/s].
Returns¶
x_wind : jnp.ndarray Downwind coordinate x' [m] (> 0 downwind, < 0 upwind of source). y_wind : jnp.ndarray Crosswind coordinate y' [m].
Source code in src/plumax/gauss_plume/plume.py
simulate_plume
¶
simulate_plume(emission_rate: float, source_location: tuple[float, float, float], wind_speed: float, wind_direction: float, stability_class: str, domain_x: tuple[float, float, int], domain_y: tuple[float, float, int], domain_z: tuple[float, float, int], background_conc: float = 0.0) -> xr.Dataset
Simulate a steady-state Gaussian plume on a 3-D grid.
Wraps :func:plume_concentration with grid construction, wind-from-angle
to (u, v) conversion, and column integration, returning an
:class:xarray.Dataset suitable for plotting / I/O.
Wind-direction convention follows the meteorological "from" convention:
wind_direction = 270° is a wind from the west (flowing east);
wind_direction = 0° is a wind from the north (flowing south).
u = -wind_speed · sin(θ), v = -wind_speed · cos(θ),
with θ = wind_direction in radians.
Parameters¶
emission_rate : float
Continuous emission rate Q [kg/s]. Must be strictly positive.
source_location : tuple of float, (3,)
(x, y, z) source coordinates [m]. z ≥ 0.
wind_speed : float
Wind speed magnitude [m/s]. Must be strictly positive.
wind_direction : float
Wind direction [degrees from North, meteorological "from" convention].
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. start < stop and
n_points ≥ 2.
background_conc : float
Additive background concentration [kg/m³]. Default 0.0.
Returns¶
ds : xarray.Dataset
Variables: concentration (x, y, z) [kg/m³],
column_concentration (x, y) [kg/m²].
Raises¶
ValueError On invalid stability class, non-positive emission rate, non-positive wind speed, malformed domain tuples, or negative source height.
Source code in src/plumax/gauss_plume/plume.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
gaussian_plume_model
¶
gaussian_plume_model(observations: ndarray | None = None, receptor_coords: tuple[ndarray, ndarray, ndarray] | None = None, source_location: tuple[float, float, float] | None = None, wind_u: float | None = None, wind_v: float | None = None, stability_class: str = 'C', prior_emission_rate_mean: float = 0.1, prior_emission_rate_std: float = 0.05, infer_stability: bool = False, background_prior_std: float = 5e-07, obs_noise_std: float = 5e-07) -> jnp.ndarray
NumPyro model for the steady-state Gaussian plume.
Priors
emission_rate ~ LogNormal(μ_log, σ_log) [kg/s] stability_idx ~ Categorical(1/6, ..., 1/6) (optional) [A..F] background ~ HalfNormal(σ_bg) [kg/m³]
where (μ_log, σ_log) are the log-space parameters derived from the
requested real-scale (prior_emission_rate_mean, prior_emission_rate_std)
via the method-of-moments inversion in :func:_lognormal_from_moments.
Likelihood
obs ~ Normal(f_plume(emission_rate, ...) + background, σ_obs)
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,), in the fixed frame [m]. Required
whenever observations is not None.
source_location : tuple of float, optional
(x, y, z) source coordinates [m]. Required whenever observations
is not None.
wind_u, wind_v : float, optional
Wind velocity components [m/s]. Required whenever observations
is not None.
stability_class : str
Stability class used if infer_stability=False. Default 'C'.
prior_emission_rate_mean, prior_emission_rate_std : float
Real-scale prior mean / std for the emission rate [kg/s]. The
implementation converts these to log-space parameters internally, so
the realised prior has the requested mean and variance.
infer_stability : bool
If True, sample a categorical stability_idx latent over A-F.
background_prior_std : float
HalfNormal scale for the background concentration [kg/m³].
obs_noise_std : float
Observation noise σ [kg/m³].
Raises¶
ValueError
If observations is provided but any of receptor_coords,
source_location, wind_u, or wind_v is None — that
combination disconnects the likelihood from the forward model and
would produce a meaningless posterior. Prior-predictive runs
(observations=None) are allowed with any subset of forward-model
inputs.
Source code in src/plumax/gauss_plume/inference.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
infer_emission_rate
¶
infer_emission_rate(observations: NDArray, observation_coords: tuple[NDArray, NDArray, NDArray], source_location: tuple[float, float, float], wind_speed: float, wind_direction: float, stability_class: str = 'C', infer_stability: bool = False, prior_mean: float = 0.1, prior_std: float = 0.05, num_warmup: int = 500, num_samples: int = 1000, num_chains: int = 1, seed: int = 0, progress_bar: bool = False, print_summary: bool = False, obs_noise_std: float = 5e-07, background_prior_std: float = 5e-07) -> dict[str, NDArray]
Infer the plume emission rate via NUTS.
Wraps :func:gaussian_plume_model with input validation, wind-from-angle
to (u, v) conversion, and posterior unpacking into NumPy arrays.
Parameters¶
observations : ndarray, shape (N,)
Observed concentrations [kg/m³].
observation_coords : tuple of ndarray
(x, y, z), each shape (N,), in the fixed frame [m].
source_location : tuple of float, (3,)
(x, y, z) source coordinates [m].
wind_speed : float
Wind speed magnitude [m/s]. Must be > 0.
wind_direction : float
Wind direction [degrees from North, meteorological "from" convention].
stability_class : str
Stability class used if infer_stability=False. Default 'C'.
infer_stability : bool
If True, jointly sample a categorical stability-class latent.
prior_mean, prior_std : float
Prior parameters for the emission rate [kg/s].
num_warmup, num_samples, num_chains : int
NUTS sampler configuration.
seed : int
PRNG seed.
progress_bar : bool
If True, show the NumPyro progress bar. Default False.
print_summary : bool
If True, call mcmc.print_summary() after the run.
obs_noise_std : float
Observation-noise σ for the Gaussian likelihood [kg/m³]. Set this to
the sensor noise so the posterior width reflects the instrument rather
than the hard-coded default.
background_prior_std : float
HalfNormal scale for the background-concentration prior [kg/m³].
Returns¶
samples : dict[str, ndarray]
Posterior draws keyed by site name: 'emission_rate',
'background', and (if infer_stability) 'stability_idx'.
Raises¶
ValueError
On invalid stability class, non-positive wind speed, shape mismatches
between observations and observation_coords, or empty data.
Source code in src/plumax/gauss_plume/inference.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |