Plume operators (geo)¶
Plume post-processing on GeoArrays, behind the [geo] extra (pip install 'plumax[geo]'): the ten operators ported from geotoolz's plume module, as pipekit_ops.Operators built with geoops's public carrier helpers (the pattern of radtrax's [geo] operators). Importing plumax.geo does not need the extra; the operators load on first use, and a missing extra raises an ImportError naming it.
geo
¶
Plume operators on GeoArrays, behind the [geo] extra.
- :mod:
plumax.geo.plume: the ten plume operators ported from geotoolz'splumemodule (#134): masks, contours, footprints, shape filters, column statistics and QND features, wind cones, the integrated mass enhancement, the cross-sectional flux and column-unit conversion. - :mod:
plumax.geo.plume_array: the array functions under them (plume_mask,wind_advection_cone,convert_column_units, ...). - :mod:
plumax.geo.starts: the starting values of an image fit, the direction from the source to the mask's centroid (plume_direction) and a grid of source positions (source_offset_grid) for a multistart solve. - :mod:
plumax.geo.transects: cross-plume transects of a column image (cross_plume_transects,CrossPlumeProfile), each one's line density, centre and width, the smoothed centreline and the width law. - :mod:
plumax.geo.vetting:PlumeVetting, :mod:plumax.vetting's candidate vetting and scene null on GeoArrays, as one Dataset (#157).
Importing this subpackage does not need the extra; the operators load on
first use, and a missing extra raises an ImportError naming it.
plume: the operators¶
The plume operators on GeoArrays (behind the [geo] extra).
Ten operators ported from geotoolz's plume module (#134) with their
behaviour unchanged; its eleventh, SBMP, moved to radtrax as
radtrax.geo.MBMP. They wrap the array functions in
:mod:plumax.geo.plume_array and are pipekit Operators built with geoops's
public carrier helpers, as radtrax's [geo] operators are.
Per-pixel operators accept a geoarray.GeoArray or a plain
np.ndarray and return the same carrier kind; geo-dependent operators
(advection geometry, pixel-area maths, footprints) require a georeferenced
GeoArray and raise TypeError otherwise. The area and distance
operators (PlumeFootprint, WindAdvectionCone, IMEEstimate,
CrossSectionalFlux) work in metres and raise ValueError on a
geographic CRS (see :func:geoops.carrier.require_projected_crs). Vector
outputs are geopandas.GeoDataFrame. Algorithms follow the literature
cited in :mod:plumax.geo.plume_array:
PlumeMask/PlumeContours/PlumeFootprint: Frankenberg et al. (2016) detection and segmentation conventions.IMEEstimate: Varon et al. (2018) integrated mass enhancement.CrossSectionalFlux: Krings et al. (2011) / Varon (2018) appendix.PlumeShapeFilter/PlumeColumnStats/PlumeQNDFeatures: Pérez Carrasco et al. (2026), the false-plume classifier's features.
The IME and cross-section operators expect the enhancement carrier to be
in kg/m^2. Use :class:ColumnToMass to convert from ppm m or mol/m^2.
Nodata: pixels that are non-finite or equal the carrier's
fill_value (see :func:geoops.carrier.valid_pixels) never
enter a threshold, statistic or sum, and are never part of a plume mask or
contour. Output fill values follow the output's meaning, not the
input's: boolean masks declare fill_value=False, float
products (scores, converted columns) hold NaN at nodata pixels and
declare fill_value=NaN, and label images use 0 (see
:class:PlumeContours for its one documented exception).
PlumeMask
¶
PlumeMask(*, threshold: ThresholdMode = 'otsu', min_area_px: int = 50, connectivity: Connectivity = 8, nbins: int = 256)
Bases: Operator
Binary plume mask from a single-band score or enhancement map.
Thresholds the input (absolute number, Otsu, or percentile) and
drops connected components smaller than min_area_px pixels — the
Frankenberg et al. (2016) detection convention, also used by Varon
et al. (2018, 2021) for S2/AVIRIS plume identification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ThresholdMode
|
|
'otsu'
|
min_area_px
|
int
|
Minimum component size in pixels. |
50
|
connectivity
|
Connectivity
|
4 or 8 connectivity for component labelling. |
8
|
nbins
|
int
|
Histogram bins for the |
256
|
Nodata pixels (non-finite or equal to the input's fill value) are
excluded from the Otsu / percentile threshold and are always
False in the mask, which declares fill_value=False.
Examples:
Source code in src/plumax/geo/_src/plume.py
PlumeContours
¶
Bases: Operator
Connected-component labelling of a plume mask.
Returns either an int32 label image (default) or a boolean mask of
the retained components. Component size threshold and connectivity
follow :func:label_components.
Nodata pixels (non-finite -- e.g. a NaN score -- or equal to the
input's fill value) are never part of a contour. In the boolean
output they are False (fill_value=False). In the
label image they hold the input's fill value when it is a
non-positive int32 value (e.g. -9999, so it cannot collide with
a label); otherwise (NaN, no fill, or a
positive fill) they are 0 (background), and a GeoArray output
then carries fill_value=0.
Examples:
Source code in src/plumax/geo/_src/plume.py
PlumeFootprint
¶
PlumeFootprint(*, min_area_m2: float = 500.0, simplify_tolerance: float | None = 15.0, properties: Sequence[str] | None = None, extra_properties: Sequence[Callable[..., Any]] | None = None)
Bases: Operator
Vectorize a plume mask into polygons with per-plume metadata.
The region properties come from the same machinery as
:class:geoops.measure.RegionProps (defaults to
:data:geoops.measure.DEFAULT_REGIONPROPS, pixel units) and the
polygons from :func:georeader.vectorize.get_polygons. Returns a
GeoDataFrame with one row per surviving plume: geometry, area_m2,
centroid,
mean_enhancement / max_enhancement (if enhancement is
supplied), n_pixels, label_id, and skimage region properties such as
major_axis_length, orientation, eccentricity, solidity,
perimeter, bbox-*, and inertia_tensor_eigvals-*.
Nodata pixels never form a polygon (of a boolean mask, or of a label
image whose fill is positive, such as a uint8 raster's 255),
non-positive labels are background, and nodata enhancement pixels are ignored
by the per-polygon statistics.
Geo-dependent: polygonisation needs the carrier's transform and CRS,
so the input must be a georeferenced GeoArray (plain arrays
raise TypeError). Areas are in m^2 and the simplify tolerance in
m, so the CRS must be projected with metre units; a geographic CRS
raises ValueError (reproject with :class:geoops.geom.Reproject
first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_area_m2
|
float
|
Drop polygons smaller than this area (m^2). |
500.0
|
simplify_tolerance
|
float | None
|
Douglas-Peucker tolerance (m) for polygon
simplification; |
15.0
|
properties
|
Sequence[str] | None
|
Region properties forwarded to |
None
|
extra_properties
|
Sequence[Callable[..., Any]] | None
|
User-defined |
None
|
Called as op(mask, enhancement=None). The optional enhancement
carrier must sit on the mask's pixel grid (ValueError otherwise);
it enables the mean_enhancement / max_enhancement statistics
per polygon.
Examples:
Source code in src/plumax/geo/_src/plume.py
PlumeShapeFilter
¶
PlumeShapeFilter(*, min_area_px: int = 50, min_fiber_to_major_ratio: float = 1.0, max_fiber_to_major_ratio: float = 10.0, min_fiber_width: float = 1.0, max_fiber_width: float = 100.0)
Bases: Operator
Drop instance labels that fail a fiber-shape morphology gate.
Adapted from Pérez Carrasco et al. (2026), physical_constraints.
apply_physical_constraints — a post-Mask R-CNN gate that distinguishes
elongated plume features from compact false positives. Per instance:
area = mask.sum(); drop when belowmin_area_px.fiber_length= longest Euclidean path through the skeleton, in pixel widths (diagonal steps countsqrt(2); see :func:geoops.measure.skeleton_length).major_axis=regionprops.axis_major_length— the PCA-based major axis of the equivalent ellipse. The original paper usescv2.minAreaRect(rotated minimum-area rectangle), avoided here to keep the optional-dependency surface unchanged; the two measures agree closely for typical plume morphologies.fiber_width = area / fiber_length.- Keep iff
min_fiber_to_major_ratio <= fiber_length / major_axis <= max_fiber_to_major_ratioANDmin_fiber_width <= fiber_width <= max_fiber_width.
Surviving instances keep their original integer labels; rejected
instances are mapped to background (0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_area_px
|
int
|
Minimum pixel count to consider an instance. |
50
|
min_fiber_to_major_ratio
|
float
|
Lower bound on |
1.0
|
max_fiber_to_major_ratio
|
float
|
Upper bound on |
10.0
|
min_fiber_width
|
float
|
Lower bound on |
1.0
|
max_fiber_width
|
float
|
Upper bound on |
100.0
|
Source code in src/plumax/geo/_src/plume.py
PlumeColumnStats
¶
Bases: Operator
Per-instance in-mask vs background statistics of a column field.
Adapted from Pérez Carrasco et al. (2026), rfc_utils.xch4_metrics.
For every non-zero label in the input map, returns a row with the
in-mask mean, the out-of-mask (background) mean / std, and three
derived metrics used by the paper's Random-Forest false-plume
classifier:
contrast=mean_plume / mean_backgroundz_score=(mean_plume - mean_background) / std_backgroundintensity_per_area=(sum_plume - mean_background * n_plume) / n_plume
Nodata column pixels (non-finite or equal to the column carrier's fill value) are left out of every statistic.
Called as op(labels, column): column is the column field
(single-band GeoArray or plain array) on the label map's pixel
grid (ValueError otherwise).
PlumeQNDFeatures
¶
PlumeQNDFeatures(*, degree: int = 6, eps: float = 50.0, min_samples: int = 50, perc_threshold: float = 98.0)
Bases: Operator
Per-instance Quantile-Normality-Deviation features for plume QA.
Adapted from Pérez Carrasco et al. (2026) — the feature pipeline that
feeds the Random-Forest false-plume classifier
(rfc_utils.get_QND_df_cms / get_plume_info). For each non-zero
label in the input map this operator emits one row containing:
qnd_column_*— polynomial coefficients of the Kolmogorov-Smirnov distance between the in-mask CDF of the column field and a Gaussian fit to the full scene's column distribution, sampled across 100 percentiles in[0.01, 0.99].qnd_albedo_*— same construction over the optional albedo field.n_clumps— DBSCAN cluster count of in-mask pixels above theperc_thresholdpercentile (per the paper's clump-count signal).contrast/z_score/intensity_per_area— the same stats that :class:PlumeColumnStatsemits, included so a single call assembles the full feature vector used by the paper.
Nodata column / albedo pixels (non-finite or equal to the carrier's fill value) are left out of every feature.
Called as op(labels, column, albedo=None): column is the
column-enhancement carrier and albedo an optional albedo carrier,
both on the label map's pixel grid (ValueError otherwise). Without
albedo the qnd_albedo_* coefficients are NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
Degree of the QND polynomial (paper default: 6). |
6
|
eps
|
float
|
DBSCAN |
50.0
|
min_samples
|
int
|
DBSCAN |
50
|
perc_threshold
|
float
|
Percentile (within the instance mask) above which pixels are eligible for clustering. |
98.0
|
Source code in src/plumax/geo/_src/plume.py
WindAdvectionCone
¶
WindAdvectionCone(*, source: Sequence[float], wind_u: float, wind_v: float, half_angle_deg: float = 30.0, max_distance: float = 5000.0, crs: str | None = None)
Bases: Operator
Mask likely downwind plume extent from a source and wind vector.
Rasterizes a circular sector centered at source, oriented along
(wind_u, wind_v), with half-angle half_angle_deg and radius
max_distance. The mask is useful as a prior for plume
segmentation when the source location and wind are known (e.g. from
a reanalysis product), following the practice of Varon et al. (2018,
2021).
Geo-dependent: the cone is rasterised in CRS coordinates via the
carrier's transform, so the input must be a georeferenced
GeoArray (plain arrays raise TypeError). max_distance is
in metres and the cone angle is measured in the map plane, so the
carrier CRS must be projected with metre units; a geographic CRS
raises ValueError (reproject with :class:geoops.geom.Reproject
first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Sequence[float]
|
|
required |
wind_u
|
float
|
Eastward wind component (m/s). |
required |
wind_v
|
float
|
Northward wind component (m/s). |
required |
half_angle_deg
|
float
|
Half-angle of the cone in degrees, in [0, 180];
|
30.0
|
max_distance
|
float
|
Radius of the cone (m). |
5000.0
|
crs
|
str | None
|
Optional CRS of |
None
|
Examples:
>>> cone = WindAdvectionCone(
... source=(x0, y0), wind_u=3.0, wind_v=1.0,
... half_angle_deg=30.0, max_distance=5000.0,
... )(enhancement)
Source code in src/plumax/geo/_src/plume.py
IMEEstimate
¶
IMEEstimate(*, wind_speed: float, length_method: Literal['max_axis', 'convex_hull', 'skeleton'] = 'max_axis', pixel_area_m2: float | None = None, return_uncertainty: bool = True, uncertainty_fraction: float = 0.5)
Bases: Operator
Integrated Mass Enhancement (IME) flux estimator.
Implements the IME method of Varon et al. (2018), AMT Quantifying methane point sources from fine-scale satellite observations of atmospheric methane plumes:
.. math::
\mathrm{IME} \;=\; \sum_{i \in \mathrm{plume}}
\Omega_i \,\Delta A_i, \qquad
Q \;=\; \frac{U_{\mathrm{eff}}\,\mathrm{IME}}{L}
where :math:\Omega_i is the column enhancement (kg/m^2) of pixel
:math:i, :math:\Delta A_i is its area (m^2), :math:L is the
effective plume length (m) — see :func:plume_length — and
:math:U_{\mathrm{eff}} is the effective wind speed (m/s). Varon
et al. (2018) calibrate :math:U_{\mathrm{eff}} against LES
simulations; this operator takes the calibrated value as
wind_speed.
The enhancement carrier MUST be in kg/m^2. Use
:class:ColumnToMass upstream to convert from ppm m or mol/m^2:
passing other units silently produces nonsense. Nodata enhancement
pixels (non-finite or equal to the fill value) add nothing to the IME.
Geo-dependent: pixel area (m^2) and plume length (m) are derived from
the carrier's transform, so the input must be a georeferenced
GeoArray (plain arrays raise TypeError) in a projected CRS
with metre units; a geographic CRS raises ValueError (reproject
with :class:geoops.geom.Reproject first).
Called as op(enhancement, plume_mask): plume_mask is a boolean
carrier selecting plume pixels on the enhancement's pixel grid (same
shape, transform and CRS; ValueError otherwise -- a mask on another
grid would be indexed against the wrong pixels).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wind_speed
|
float
|
Effective wind speed :math: |
required |
length_method
|
Literal['max_axis', 'convex_hull', 'skeleton']
|
Length estimator: |
'max_axis'
|
pixel_area_m2
|
float | None
|
Override the pixel area (m^2); default is the absolute input transform determinant in the projected CRS's metres (exact on an equal-area projection; on UTM it ignores the projection's scale factor, a < 0.1 % error near the central meridian). |
None
|
return_uncertainty
|
bool
|
Append |
True
|
uncertainty_fraction
|
float
|
Fractional 1-sigma uncertainty on Q. The default 0.5 follows Varon et al. (2018) Table 3. |
0.5
|
The call returns a dict with keys ime_kg, length_m,
wind_speed_m_s, emission_rate_kg_s, and optionally
emission_rate_uncertainty_kg_s.
Examples:
Estimate Q in kg/s from a ppm m enhancement map::
from plumax.geo import ColumnToMass, IMEEstimate, PlumeMask
kg_m2 = ColumnToMass(units_in="ppm_m")(enhancement)
mask = PlumeMask(threshold="percentile:99")(kg_m2)
result = IMEEstimate(
wind_speed=3.5,
length_method="convex_hull",
)(kg_m2, mask)
print(result["emission_rate_kg_s"])
Source code in src/plumax/geo/_src/plume.py
CrossSectionalFlux
¶
CrossSectionalFlux(*, source: Sequence[float], wind_u: float, wind_v: float, n_transects: int = 5, transect_spacing_m: float = 100.0)
Bases: Operator
Estimate cross-sectional flux at downwind transects.
For each transect :math:\Gamma_k across the wind at downwind distance
:math:d_k, the operator integrates the column mass carried through it:
.. math::
Q_k \;=\; \int_{\Gamma_k} \gamma(\Omega) \,
(\mathbf{u} \cdot \mathbf{n}) \, d\ell
\;\approx\; \sum_{q} \Delta s_q \, \gamma(\Omega)_q
\, (\mathbf{u} \cdot \mathbf{n}_q)
where :math:\gamma is the trace (:func:functax.transfer.trace_plan),
which reads the column by bilinear interpolation at the midpoint nodes
of a line rule along :math:\Gamma_k, at least 400 and at most a
quarter of a pixel apart, and the sum is integrix's rule sum. Reading the column on the line, rather than summing a strip of
pixels, keeps the flux unbiased when the wind is oblique to the pixel
grid. This is the cross-section method of Krings et al. (2011) and
Varon et al. (2018, appendix); a flat downwind profile of :math:Q_k
versus :math:d_k confirms a steady-state estimate.
The enhancement carrier MUST be in kg/m^2 (see :class:ColumnToMass).
Pixels outside the plume mask and nodata enhancement pixels (non-finite
or equal to the fill value) are read as zero, so they add nothing to a
transect's flux. The scene ends at its pixels' outer edges, where the
edge pixels are read as they are, and nodes beyond it read zero. Each
transect spans the across-wind offsets of the plume pixels whose
bilinear hat reaches it, plus that hat's reach along the transect,
:math:|a e_x + d e_y| + |b e_x + e e_y| for the transform's steps
and the transect's direction :math:e, so the column of the edge
pixels is counted in full. Arc lengths, normals and that reach come
from the transform, so the flux holds for oblique winds and for pixels
that are not square.
Geo-dependent: transect placement and pixel size come from the
carrier's transform and CRS, so the input must be a georeferenced
GeoArray (plain arrays raise TypeError) in a projected CRS
with metre units; a geographic CRS raises ValueError (reproject
with :class:geoops.geom.Reproject first).
Called as op(enhancement, plume_mask): plume_mask is a boolean
plume carrier on the enhancement's pixel grid (ValueError
otherwise).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Sequence[float]
|
|
required |
wind_u
|
float
|
Eastward wind component (m/s). |
required |
wind_v
|
float
|
Northward wind component (m/s). |
required |
n_transects
|
int
|
Number of downwind transects to evaluate. |
5
|
transect_spacing_m
|
float
|
Along-wind distance between transects (m). |
100.0
|
The call returns a geopandas.GeoDataFrame with one row per
transect: geometry (the across-wind LineString the flux is
integrated over), transect_id,
distance_m, flux_kg_s, n_pixels (the plume pixels that
the transect's trace reads).
Examples:
Evaluate fluxes at 100 m, 200 m, 300 m downwind::
gdf = CrossSectionalFlux(
source=(x0, y0),
wind_u=3.0, wind_v=1.0,
n_transects=3, transect_spacing_m=100.0,
)(kg_m2, mask)
Source code in src/plumax/geo/_src/plume.py
ColumnToMass
¶
ColumnToMass(*, gas: str = 'CH4', units_in: ColumnUnit = 'ppm_m', units_out: ColumnUnit = 'kg_m2', pressure_pa: float = P_STANDARD, temperature_k: float = T_STANDARD)
Bases: Operator
Convert column enhancement units (ppm m / mol m^-2 / kg m^-2).
Thin wrapper over :func:convert_column_units. The ppm m conversion
uses the ideal-gas air density at the layer's pressure and temperature,
the ISA sea-level 101 325 Pa and 288.15 K unless the scene's are given;
see that function's docstring for the exact relation. Nodata
pixels (non-finite or equal to the fill value) are not converted:
they hold NaN and the output declares fill_value=NaN
(a converted column is a new quantity, so the input's fill -- e.g.
-9999 ppm m -- is not carried over).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas
|
str
|
|
'CH4'
|
units_in
|
ColumnUnit
|
Units of the input carrier. |
'ppm_m'
|
units_out
|
ColumnUnit
|
Desired output units. |
'kg_m2'
|
pressure_pa
|
float
|
Layer pressure p [Pa] for the ppm m conversion. |
P_STANDARD
|
temperature_k
|
float
|
Layer temperature T [K] for the ppm m conversion. |
T_STANDARD
|
Examples:
Source code in src/plumax/geo/_src/plume.py
vetting: plume vetting on carriers¶
PlumeVetting runs plume vetting (vet_candidate and the scene null) on every candidate of a scene and returns the scores as one xarray.Dataset; the decision rule is left to the caller.
Plume vetting on GeoArrays (behind the [geo] extra): one Dataset per scene.
PlumeVetting is the L2 operator over the array-level vetting in
:mod:plumax.vetting (#157): it reads a radiance GeoArray, its
matched-filter GeoArray and a stack of candidate masks, runs
vet_candidate on each candidate and the scene null (null_masks,
null_pvalue) beside it, and returns the scores as one xarray.Dataset.
It returns scores, not a verdict: the decision rule is #158's.
PlumeVetting
¶
PlumeVetting(*, window: AbsorptionWindow, table: Float[ArrayLike, 'D Bf'], delta_grid: Float[ArrayLike, ' D'], n_null: int = 100, key: Array | None = None, k: int = DEFAULT_K, keep: float = DEFAULT_KEEP, degree: int = DEFAULT_DEGREE, box: int = DEFAULT_BOX)
Bases: Operator
Vet every candidate of a scene and its scene null; scores as a Dataset.
Called as PlumeVetting(window=..., table=..., delta_grid=...)(cube, mf, masks).
For each candidate M_c of masks, with every candidate kept out of
the background pool,
(ΔX̂_c, D_norm,c) = vet_candidate(L, MF, M_c), and
p̂_c = null_pvalue(D_norm,c, {D_norm(M_s)}) over n_null copies
M_s of M_c from null_masks, each vetted as M_c is; a copy
that cannot be scored (radtrax's DegenerateInputError) scores
NaN and null_pvalue leaves it out.
The cube is (B, H, W) with its band centres in nm in
attrs["wavelengths"]; mf is (H, W) or (1, H, W) on the
cube's pixel grid, in mol/m² (the units of
window.mf_background_mol_m2). Nodata pixels of either carrier
(non-finite, or equal to its fill_value) are dropped from
every candidate and kept out of the pool and the null copies. The
candidates' random draws split key in candidate order, so the same
key gives the same p_null.
The Dataset has dims candidate (C) and band (the window's
Bf fitting bands, coordinate wavelength_nm) and holds
delta_x_mol_m2 (ΔX̂), d_norm, p_null (NaN when
n_null = 0) and n_pairs per candidate; ratio (R),
continuum (P(λ; ĉ)) and fit (P(λ; ĉ) E(λ; ΔX̂), the fitted
ratio) per candidate and band; and attributes window (the window's
fields as JSON) and key (the key's raw data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
AbsorptionWindow
|
The gas's |
required |
table
|
Float[ArrayLike, 'D Bf']
|
|
required |
delta_grid
|
Float[ArrayLike, ' D']
|
The columns |
required |
n_null
|
int
|
Number of null copies per candidate; |
100
|
key
|
Array | None
|
A |
None
|
k
|
int
|
Number of seeds before growth ( |
DEFAULT_K
|
keep
|
float
|
Fraction of the pairs kept, in (0, 1]. |
DEFAULT_KEEP
|
degree
|
int
|
The continuum's Legendre degree. |
DEFAULT_DEGREE
|
box
|
int
|
Margin, in pixels, around the seeds' bounding box that the pool is drawn from. |
DEFAULT_BOX
|
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
ShapeError
|
If the cube is not |
Examples:
A pipeline sketch, after radtrax's matched filter::
from plumax.geo import PlumeVetting
scores = PlumeVetting(
window=window, table=table, delta_grid=delta_grid, n_null=100
)(
cube, mf, masks
)
scores["d_norm"], scores["p_null"]
Source code in src/plumax/geo/_src/vetting.py
get_config
¶
The JSON-safe configuration, without the arrays (table, grid, key).
Source code in src/plumax/geo/_src/vetting.py
from_config
classmethod
¶
from_config(config: dict[str, Any], *, table: Float[ArrayLike, 'D Bf'] | None = None, delta_grid: Float[ArrayLike, ' D'] | None = None, key: Array | None = None) -> PlumeVetting
Rebuild from get_config's output and the arrays it leaves out.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/plumax/geo/_src/vetting.py
starts: starting values of an image fit¶
The starting direction of a column-plume fit, from the source to the centroid of the plume mask, and the grid of source positions that solve_coupled_multistart starts from.
Starting values for a plume fit (implementation in plumax.geo._src.starts).
plume_direction
¶
plume_direction(mask: Bool[ndarray, 'row col'], transform: Any, source: tuple[float, float], *, weights: Float[ndarray, 'row col'] | None = None) -> float
Direction from the source to the centroid of the mask.
φ₀ = atan2(s̄₂ − s₀₂, s̄₁ − s₀₁), with s̄ = ∑ₙ ωₙ sₙ / ∑ₙ ωₙ over the mask.
Algorithm
- Place every pixel centre sₙ in the CRS with the geotransform.
- Weight the mask pixels by ωₙ (1, or
weights) and take the centroid s̄. - Take the angle of s̄ − s₀.
With the enhancement as weights the centroid is the plume's centre of
mass, which depends less on where the outline is drawn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Bool[ndarray, 'row col']
|
Plume mask; True marks plume pixels. |
required |
transform
|
Any
|
Affine geotransform from |
required |
source
|
tuple[float, float]
|
Source position s₀ [m] in the same CRS. |
required |
weights
|
Float[ndarray, 'row col'] | None
|
Optional weights ωₙ ≥ 0, such as the enhancement. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
φ₀ [rad], counter-clockwise from the CRS x axis (east), in (−π, π]. |
Raises:
| Type | Description |
|---|---|
DomainError
|
If the mask is empty, its weights are negative or sum to zero, or its centroid is within one pixel of the source. |
Examples:
A plume of pixels north-east of the source, on a north-up 60 m grid:
>>> import numpy as np
>>> from affine import Affine
>>> transform = Affine(60.0, 0.0, 0.0, 0.0, -60.0, 600.0)
>>> mask = np.zeros((10, 10), dtype=bool)
>>> mask[[4, 3, 2], [5, 6, 7]] = True
>>> angle = plume_direction(mask, transform, (270.0, 270.0))
>>> round(float(np.degrees(angle)), 6)
45.0
Source code in src/plumax/geo/_src/starts.py
source_offset_grid
¶
source_offset_grid(source: tuple[float, float], *, pixel_size: float, n: int = 3, step: int = 1) -> Float[np.ndarray, 'start axis']
An n × n grid of source positions around the source, step pixels apart.
s_ij = s₀ + step · g · (i, j) for i, j ∈ {−(n − 1)/2, …, (n − 1)/2}.
The starts run over i (x) first and j (y) second, so the middle start, index n² // 2, is the source itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
tuple[float, float]
|
Source position s₀ [m]. |
required |
pixel_size
|
float
|
Pixel side g [m]. |
required |
n
|
int
|
Starts along each axis, odd. |
3
|
step
|
int
|
Spacing of the starts, in pixels. |
1
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, 'start axis']
|
The n² starts, one |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
Examples:
>>> grid = source_offset_grid((100.0, 200.0), pixel_size=60.0)
>>> grid.shape
(9, 2)
>>> grid[4].tolist()
[100.0, 200.0]
>>> grid[0].tolist()
[40.0, 140.0]
Source code in src/plumax/geo/_src/starts.py
transects: cross-plume transects¶
Profiles of the enhancement across the plume at regular downwind distances, by spline interpolation of the image, and each profile's line density, centre and width. CrossPlumeProfile returns them as one table on a GeoArray; the array functions underneath give the smoothed centreline and the width law, the starting values of a column-plume fit. They are NumPy and SciPy code, outside any traced path.
Cross-plume transects (implementation in plumax.geo._src.transects).
CrossPlumeProfile
¶
CrossPlumeProfile(*, source: Sequence[float], direction: float, n_transects: int, transect_spacing_m: float, half_length_m: float, order: int = 3)
Bases: Operator
Transect table of a plume image: one row per downwind distance.
Called as op(enhancement) on a GeoArray in kg m⁻² and a projected
CRS in metres. Returns a GeoDataFrame with geometry (the transect
LineString), distance_m, line_density_kg_m, centre_m,
width_m, centre_smooth_m and converged.
The line density is the signed sum of :func:transect_moments; the
centre and width are those of :func:fit_transect_gaussians with
w_min = δ, and the smoothed centre is :func:smooth_centreline of them.
Samples are a pixel apart. Times a wind speed U, the line density is the
flux Q_k = U q̂_k that CrossSectionalFlux reports, with interpolated
samples in place of whole pixels.
Geo-dependent: the input must be a georeferenced GeoArray (plain
arrays raise TypeError) in a projected CRS with metre units (a
geographic CRS raises ValueError), as for CrossSectionalFlux.
Nodata pixels (non-finite or equal to the fill value) become NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Sequence[float]
|
Source position s₀ [m] in the carrier's CRS. |
required |
direction
|
float
|
Plume direction φ [rad], counter-clockwise from east. |
required |
n_transects
|
int
|
Number of transects T. |
required |
transect_spacing_m
|
float
|
Downwind spacing Δ_d [m]. |
required |
half_length_m
|
float
|
Half the transect length [m]. |
required |
order
|
int
|
Spline order of the interpolation. |
3
|
Examples:
Profiles every 120 m out to 2.4 km, each ±1.5 km across::
table = CrossPlumeProfile(
source=(x0, y0),
direction=np.deg2rad(30.0),
n_transects=20,
transect_spacing_m=120.0,
half_length_m=1500.0,
)(column_mass)
Source code in src/plumax/geo/_src/transects.py
TransectProfiles
dataclass
¶
TransectProfiles(distance: Float[ndarray, ' transect'], offset: Float[ndarray, ' offset'], values: Float[ndarray, 'transect offset'])
Interpolated enhancement across the plume at regular downwind distances.
Attributes:
| Name | Type | Description |
|---|---|---|
distance |
Float[ndarray, ' transect']
|
Downwind distance d_k of each transect [m]. |
offset |
Float[ndarray, ' offset']
|
Crosswind offset c_j of each sample [m], δ apart and symmetric about the plume axis. |
values |
Float[ndarray, 'transect offset']
|
Enhancement v_kj [kg m⁻²]; NaN outside the image or near nodata. |
cross_plume_transects
¶
cross_plume_transects(enhancement: Float[ndarray, 'row col'], transform: Any, *, source: tuple[float, float], direction: float, n_transects: int, spacing: float, half_length: float, sample_spacing: float | None = None, order: int = 3) -> TransectProfiles
Profiles across the plume by spline interpolation of the image.
v_kj = 𝓘_ΔΩ(p_kj) with p_kj = s₀ + d_k e_∥ + c_j e_⊥, d_k = k Δ_d and c_j = (j − (S − 1)/2) δ.
Algorithm
- Build the sample points p_kj in the carrier's coordinates.
- Map them to fractional pixel indices with the inverse transform.
- Interpolate with a spline of the given order, nodata filled with zero; samples outside the image or within two pixels of nodata become NaN.
- Drop transects whose centre point is outside the image.
The S = 2 round(h / δ) + 1 samples run from −h to h, rounded to whole samples. Transects closer than a pixel would reuse the same pixels, so their line densities would be correlated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enhancement
|
Float[ndarray, 'row col']
|
Column enhancement ΔΩ [kg m⁻²], nodata as NaN. |
required |
transform
|
Any
|
Affine geotransform from |
required |
source
|
tuple[float, float]
|
Source position s₀ [m] in the carrier's CRS. |
required |
direction
|
float
|
Plume direction φ [rad], counter-clockwise from east. |
required |
n_transects
|
int
|
Number of transects T. |
required |
spacing
|
float
|
Downwind spacing Δ_d [m]. |
required |
half_length
|
float
|
Half the transect length h [m]. |
required |
sample_spacing
|
float | None
|
Sample spacing δ [m]; defaults to the pixel side. |
None
|
order
|
int
|
Spline order of the interpolation, 0 to 5. |
3
|
Returns:
| Name | Type | Description |
|---|---|---|
The |
TransectProfiles
|
class: |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
DomainError
|
If no transect lies inside the image. |
Examples:
A uniform ridge of 1 kg m⁻² three pixels wide along x, on a 60 m grid, has a line density of 3 × 60 = 180 kg m⁻¹:
>>> import numpy as np
>>> from affine import Affine
>>> transform = Affine(60.0, 0.0, 0.0, 0.0, -60.0, 1200.0)
>>> image = np.zeros((20, 20))
>>> image[9:12, :] = 1.0
>>> profiles = cross_plume_transects(
... image, transform, source=(30.0, 570.0), direction=0.0,
... n_transects=4, spacing=120.0, half_length=300.0,
... )
>>> profiles.values.shape
(4, 11)
>>> np.round(transect_moments(profiles)["line_density"], 9).tolist()
[180.0, 180.0, 180.0, 180.0]
Source code in src/plumax/geo/_src/transects.py
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 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 | |
transect_moments
¶
Line density, centre and width of each transect from its moments.
q̂_k = δ ∑_j v_kj; m̂_k = ∑_j c_j v⁺_kj / ∑_j v⁺_kj; ŵ_k² = ∑_j (c_j − m̂_k)² v⁺_kj / ∑_j v⁺_kj, with v⁺ = max(v, 0).
The line density is the signed sum, unbiased under zero-mean noise. A
positive-part sum would add σ / √(2π) per sample for noise of standard
deviation σ, a bias of S δ σ / √(2π) that grows with the transect. The
same noise floor pulls ŵ_k towards the half-length, so the width of
:func:fit_transect_gaussians is the one to use on noisy images. NaN
samples carry no weight.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
TransectProfiles
|
The transects. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Float[ndarray, ' transect']]
|
|
dict[str, Float[ndarray, ' transect']]
|
one per transect; the centre and width are NaN where no sample is |
dict[str, Float[ndarray, ' transect']]
|
positive. |
Examples:
>>> import numpy as np
>>> profiles = TransectProfiles(
... distance=np.array([60.0]),
... offset=np.array([-60.0, 0.0, 60.0]),
... values=np.array([[1.0, 2.0, 1.0]]),
... )
>>> moments = transect_moments(profiles)
>>> moments["line_density"].tolist(), moments["centre"].tolist()
([240.0], [0.0])
Source code in src/plumax/geo/_src/transects.py
fit_transect_gaussians
¶
fit_transect_gaussians(profiles: TransectProfiles, *, min_width: float, max_offset: float | None = None) -> dict[str, np.ndarray]
Least-squares Gaussian per transect.
(q̂_k, m̂_k, ŵ_k) = argmin ∑_j (v_kj − q / (√(2π) w) exp(−(c_j − m)² / 2w²))², with q ≥ 0, |m| ≤ m_max and w ≥ w_min.
Algorithm
- Start from (the moment q̂_k, the offset of the largest sample, 2δ).
- Solve the bounded problem by trust-region reflective least squares over the finite samples, transect by transect.
- Mark a fit converged when the solver reports success and no parameter sits on a bound.
The fitted q is the area under the Gaussian, so it is a line density.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
TransectProfiles
|
The transects. |
required |
min_width
|
float
|
Smallest width w_min [m], the sample spacing in SPIIRE. |
required |
max_offset
|
float | None
|
Largest centre offset m_max [m]; defaults to twice the half-length. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
|
dict[str, ndarray]
|
|
dict[str, ndarray]
|
transect has fewer than three finite samples or none above zero. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
Examples:
>>> import numpy as np
>>> offset = np.arange(-600.0, 601.0, 60.0)
>>> values = 0.1 / (np.sqrt(2 * np.pi) * 150.0) * np.exp(
... -0.5 * ((offset - 30.0) / 150.0) ** 2
... )
>>> profiles = TransectProfiles(
... distance=np.array([60.0]), offset=offset, values=values[None]
... )
>>> fits = fit_transect_gaussians(profiles, min_width=60.0)
>>> [round(float(fits[key][0]), 6) for key in ("line_density", "centre", "width")]
[0.1, 30.0, 150.0]
>>> bool(fits["converged"][0])
True
Source code in src/plumax/geo/_src/transects.py
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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
smooth_centreline
¶
smooth_centreline(centre: Float[ndarray, ' transect'], width: Float[ndarray, ' transect'], converged: Bool[ndarray, ' transect'], *, window: int = 19, polyorder: int = 2, n_iter: int = 3, threshold: float = 1.5, rejected: Literal['smoothed', 'zero'] = 'smoothed') -> Float[np.ndarray, ' transect']
Centreline with failed fits interpolated and outliers rejected.
m̃ = SG(m̂); m̂_k ← m̃_k where |m̂_k − m̃_k| > 1.5 ŵ_k; repeated, with zeros put before the centres so the line starts at the source.
Algorithm
- Interpolate m̂_k and ŵ_k linearly across the unconverged transects.
- Put 100 zeros before them, which are never rejected.
- Repeat
n_itertimes: smooth with a Savitzky–Golay filter to get m̃_k, and replace m̂_k wherever |m̂_k − m̃_k| > threshold · ŵ_k. - Smooth once more and drop the zeros.
SPIIRE sets the rejected centres to zero (rejected="zero"), which
pulls a bent plume back towards a straight one; the default replaces
them by the smoothed line. The window is shortened to the largest odd
number not above the series length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
centre
|
Float[ndarray, ' transect']
|
Centres m̂_k [m], one per transect. |
required |
width
|
Float[ndarray, ' transect']
|
Widths ŵ_k [m], the scale of the rejection test. |
required |
converged
|
Bool[ndarray, ' transect']
|
Which fits converged. |
required |
window
|
int
|
Savitzky–Golay window, odd. |
19
|
polyorder
|
int
|
Savitzky–Golay polynomial order, below |
2
|
n_iter
|
int
|
Rounds of rejection. |
3
|
threshold
|
float
|
Rejection threshold, in widths. |
1.5
|
rejected
|
Literal['smoothed', 'zero']
|
What a rejected centre becomes: |
'smoothed'
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, ' transect']
|
The smoothed centreline m̃_k [m], one per transect. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
DomainError
|
If no fit converged. |
Examples:
A straight line with one failed fit and one outlier:
>>> import numpy as np
>>> centre = np.zeros(30)
>>> centre[10], centre[20] = 500.0, 400.0
>>> converged = np.ones(30, dtype=bool)
>>> converged[10] = False
>>> smoothed = smooth_centreline(centre, np.full(30, 60.0), converged)
>>> bool(np.max(np.abs(smoothed)) < 60.0)
True
Source code in src/plumax/geo/_src/transects.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
fit_width_law
¶
fit_width_law(distance: Float[ndarray, ' transect'], width: Float[ndarray, ' transect'], *, reference_distance: float, initial_width: float = 0.0) -> tuple[float, float]
Reference width and exponent from a line through the log widths.
½ log(ŵ_k² − w₀²) = log w_ref + b log(d_k / d_ref), by least squares.
Widths at or below w₀, and non-finite ones, are left out. The result is
the reference_width and width_exponent of
gauss_plume.PlumeGeometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
Float[ndarray, ' transect']
|
Downwind distances d_k [m]. |
required |
width
|
Float[ndarray, ' transect']
|
Widths ŵ_k [m], as fitted by :func: |
required |
reference_distance
|
float
|
Reference distance d_ref [m]. |
required |
initial_width
|
float
|
Initial width w₀ [m]. |
0.0
|
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
|
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
DomainError
|
If fewer than two transects at distinct distances keep a width above w₀. |
Examples:
>>> import numpy as np
>>> distance = np.array([250.0, 500.0, 1000.0, 2000.0])
>>> width = 100.0 * (distance / 1000.0) ** 0.8
>>> reference_width, exponent = fit_width_law(
... distance, width, reference_distance=1000.0
... )
>>> round(reference_width, 6), round(exponent, 6)
(100.0, 0.8)
Source code in src/plumax/geo/_src/transects.py
plume_array: the array functions¶
Plume masks, geometry and column units on NumPy arrays (behind [geo]).
The array functions under the operators in :mod:plumax.geo.plume, ported
from geotoolz's plume module (#134) with their behaviour unchanged.
They take plain arrays and an affine transform, no carrier, but build on
geoops's public mask, measure and threshold helpers and on shapely, so they
need the [geo] extra too. Algorithms and unit conventions follow the
trace-gas plume literature cited per function:
- Varon et al. (2018), AMT: the integrated mass enhancement (IME) method.
- Frankenberg et al. (2016), PNAS: airborne CH4 plume detection.
- Thompson et al. (2015), AMT, and Foote et al. (2020), TGRS: the matched-filter CH4 retrievals whose columns these functions convert.
plume_mask
¶
plume_mask(values: Num[ndarray, 'h w'] | Num[ndarray, '1 h w'], *, threshold: ThresholdMode = 'otsu', min_area_px: int = 50, connectivity: Connectivity = 8, nbins: int = 256) -> Bool[np.ndarray, 'h w']
Threshold an enhancement map and remove small connected components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Num[ndarray, 'h w'] | Num[ndarray, '1 h w']
|
Single-band enhancement map, |
required |
threshold
|
ThresholdMode
|
Absolute number, |
'otsu'
|
min_area_px
|
int
|
Minimum connected-component size in pixels. |
50
|
connectivity
|
Connectivity
|
4 or 8 connectivity for component labelling. |
8
|
nbins
|
int
|
Histogram bins for the |
256
|
Returns:
| Type | Description |
|---|---|
Bool[ndarray, 'h w']
|
Boolean |
Source code in src/plumax/geo/_src/plume_array.py
wind_advection_cone
¶
wind_advection_cone(shape: tuple[int, int], transform: Any, *, source: tuple[float, float], wind_u: float, wind_v: float, half_angle_deg: float = 30.0, max_distance: float = 5000.0) -> Bool[np.ndarray, 'h w']
Rasterize an analytical downwind sector mask.
Marks pixels whose center lies within max_distance of source
and whose bearing from the source is within half_angle_deg of the
wind direction (wind_u, wind_v) — a geometric prior for where an
advected plume can be. The source pixel itself is included.
With d = (x − x₀, y − y₀) the offset of a pixel center from the
source and ŵ = (u, v) / ‖(u, v)‖ the unit wind vector, a pixel is
inside when
‖d‖ ≤ max_distance and d·ŵ ≥ ‖d‖ · cos(half_angle_deg)
i.e. the angle between d and ŵ is at most half_angle_deg.
For half_angle_deg ≤ 90 the angle test alone keeps the sector in
the downwind half-plane (cos ≥ 0 ⇒ d·ŵ ≥ 0); half_angle_deg > 90
widens it past the crosswind line, and half_angle_deg = 180 is the
full disc of radius max_distance, upwind pixels included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
Raster shape |
required |
transform
|
Any
|
Affine-like geotransform of the raster; its CRS units
must match |
required |
source
|
tuple[float, float]
|
|
required |
wind_u
|
float
|
Eastward wind component. |
required |
wind_v
|
float
|
Northward wind component. |
required |
half_angle_deg
|
float
|
Half-angle of the sector in degrees, in [0, 180]. |
30.0
|
max_distance
|
float
|
Sector radius in CRS units. |
5000.0
|
Returns:
| Type | Description |
|---|---|
Bool[ndarray, 'h w']
|
Boolean |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the wind vector is zero, |
Source code in src/plumax/geo/_src/plume_array.py
convert_column_units
¶
convert_column_units(values: Num[ndarray, '*dims'], *, gas: str = 'CH4', units_in: ColumnUnit = 'ppm_m', units_out: ColumnUnit = 'kg_m2', pressure_pa: float = P_STANDARD, temperature_k: float = T_STANDARD) -> Float[np.ndarray, '*dims']
Convert column enhancement among ppm m, mol/m^2, and kg/m^2.
A ppm m enhancement is a mixing ratio integrated along the path, so its
amount of gas depends on the air number density there, :math:p / (k_B T):
.. math::
\Omega_{\mathrm{mol/m^2}} \;=\; \frac{X \cdot 10^{-6}\, p}{k_B T N_A},
\qquad
\Omega_{\mathrm{kg/m^2}} \;=\; M_{\mathrm{gas}}
\cdot \Omega_{\mathrm{mol/m^2}}
where X is the enhancement in ppm m, :math:p and :math:T the
pressure and temperature of the layer, :math:k_B the Boltzmann constant,
:math:N_A Avogadro's number and :math:M_{\mathrm{gas}} the molar mass
(CH4: 0.0160425 kg/mol; CO2: 0.0440095 kg/mol). It is the same relation as
:func:plumax.obs.ppm_m_to_column_mass, and both default to the ISA
sea-level 101 325 Pa and 288.15 K; pass the scene's values when known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Num[ndarray, '*dims']
|
The column enhancement, in |
required |
gas
|
str
|
|
'CH4'
|
units_in
|
ColumnUnit
|
Units of |
'ppm_m'
|
units_out
|
ColumnUnit
|
Units of the result. |
'kg_m2'
|
pressure_pa
|
float
|
Layer pressure p [Pa], used by the ppm m conversions. |
P_STANDARD
|
temperature_k
|
float
|
Layer temperature T [K], used by the ppm m conversions. |
T_STANDARD
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The enhancement in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
UnitError
|
If a unit is unknown; a |
Source code in src/plumax/geo/_src/plume_array.py
plume_length
¶
plume_length(mask: Bool[ndarray, 'h w'], transform: Any, *, method: Literal['max_axis', 'convex_hull', 'skeleton'] = 'max_axis') -> float
Estimate plume length L from active pixel centers.
L is the effective length used by Varon et al. (2018) in the IME
method Q = U_eff * IME / L. Three estimators are supported:
"max_axis": maximum pairwise distance between active pixels, taken over the vertices of their convex hull (the same value as over every pair, in memory that does not grow withN²). Fast and robust; matches the original Varon 2018 definition for reasonably linear plumes."convex_hull": max diameter of the convex hull of the active pixels, which is the"max_axis"value, since that already runs over the hull's vertices. Collinear points, which have no 2-D hull, give the point-set diameter."skeleton": length of the plume centreline, via :func:geoops.measure.skeleton_lengthwith the transform as the pixel step. The mask is skeletonised andLis the longest geodesic path through the 8-connected skeleton, with each step weighted by its Euclidean length in CRS units (so diagonal steps and anisotropic pixels are measured correctly). Better than the chord for curved plumes. The path runs between skeleton pixel centres, so for thick plumes it is shorter than the mask extent by roughly the plume width.
Lengths are in CRS units (m for a projected metric CRS) and measured between pixel centres.
A single-pixel mask returns one linear pixel size,
sqrt(pixel_area), for every method: it has no geometry to
measure, and the one-pixel proxy is the documented convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Bool[ndarray, 'h w']
|
Boolean |
required |
transform
|
Any
|
Affine-like geotransform ( |
required |
method
|
Literal['max_axis', 'convex_hull', 'skeleton']
|
Length estimator (see above). |
'max_axis'
|
Returns:
| Type | Description |
|---|---|
float
|
The plume length in CRS units; |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/plumax/geo/_src/plume_array.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
pixel_area
¶
Return pixel area from an affine-like transform determinant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
Any
|
Affine-like object exposing |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
float
|
projected metric CRS). |
Source code in src/plumax/geo/_src/plume_array.py
pixel_centers
¶
pixel_centers(shape: tuple[int, int], transform: Any) -> tuple[Float[np.ndarray, 'h w'], Float[np.ndarray, 'h w']]
Return x/y coordinate grids for pixel centers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
Raster shape |
required |
transform
|
Any
|
Affine-like geotransform mapping |
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, 'h w']
|
Tuple |
Float[ndarray, 'h w']
|
coordinates of each pixel center. |
Source code in src/plumax/geo/_src/plume_array.py
squeeze_single_band
¶
squeeze_single_band(values: Shaped[ndarray, 'h w'] | Shaped[ndarray, '1 h w']) -> Shaped[np.ndarray, 'h w']
Return a 2-D plume map from a 2-D or singleton-band array.
Thin delegate to :func:geoops.carrier.single_band, kept under
geotoolz's historical public name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Shaped[ndarray, 'h w'] | Shaped[ndarray, '1 h w']
|
A |
required |
Returns:
| Type | Description |
|---|---|
Shaped[ndarray, 'h w']
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |