weac.parser.utils.layer_gradient module¶
Segment a windowed density profile into WEAC slab layers by gradient.
Companion to weac.parser.utils.layer_binning. Instead of grouping at a
fixed thickness, this cuts the depth-ordered (surface -> ground) density series
wherever the density gradient over a fixed 2.5 mm span exceeds a threshold,
so ramps become a staircase of >= 1 mm layers while quiet stretches collapse
into one homogeneous layer.
Why a fixed span¶
The native Loewe hop differs between parameterizations (CR2020 / P2015 / King),
so an adjacent-sample slope is not comparable across methods. Measuring
|drho/dz| over a constant 2.5 mm baseline (the P2015 window) makes a single
threshold T meaningful for every parameterization.
Segmentation model¶
Each sample owns a “cell” (spacing to the next sample, last repeated), exactly
as in the binning helper, so sum(layer.h) equals the summed cell thickness
(times depth_scale). A sample whose fixed-span gradient is > T is a cut:
it stands as its own layer (subject to the 1 mm floor). Consecutive <= T
samples merge into one layer until the next cut. Thickness is depth_scale
scaled; density is the cell-thickness-weighted mean over the run.
- weac.parser.utils.layer_gradient.gradient_profile_to_layers(depth_mm, density_kg_m3, *, threshold_kg_m3_per_mm=12.0, span_mm=2.5, min_thickness_mm=1.0, depth_scale=1.0)[source]¶
Segment a density profile into WEAC slab layers by gradient (top-down).
- Parameters:
depth_mm (ndarray) – Depth-ordered (surface -> ground) sample positions [mm].
density_kg_m3 (ndarray) – Density at each sample [kg m^-3]; same shape as
depth_mm.threshold_kg_m3_per_mm (float) – Cut threshold
T. Samples whose fixed-span|drho/dz|exceedsTstart their own layer;<= Tsamples merge. Default12(== 30 kg/m^3 across the 2.5 mm span).span_mm (float) – Fixed baseline for the gradient [mm]; default
2.5.min_thickness_mm (float) – Minimum layer thickness [mm]. Sub-floor segments are merged forward; a trailing remainder below the floor is folded into the previous layer.
depth_scale (float) – Plumb -> slope-normal factor applied to every
h(cos(phi));1.0leaves thicknesses unscaled.
- Returns:
Layers ordered surface -> ground.
sum(layer.h)equals the summed cell thickness timesdepth_scale.- Return type:
list[Layer]