weac.parser.utils package

Submodules

Module contents

Shared helpers for WEAC field-profile parsers.

weac.parser.utils.bin_profile_to_layers(depth_mm, density_kg_m3, *, layer_thickness_mm=None, min_thickness_mm=1.0, depth_scale=1.0)[source]

Bin a density profile into WEAC slab layers (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.

  • layer_thickness_mm (float | None) – Target layer thickness. None groups at the native sample spacing (each cell is its own layer) subject to the min_thickness_mm floor; a value groups adjacent cells until each run reaches roughly that thickness.

  • min_thickness_mm (float) – Minimum layer thickness [mm]. Adjacent cells are merged until a run reaches this floor; 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.0 leaves thicknesses unscaled.

Returns:

Layers ordered surface -> ground. sum(layer.h) equals the summed cell thickness times depth_scale.

Return type:

list[Layer]

weac.parser.utils.detect_knappe_surface(samples)[source]

Return the Knappe surface distance in mm along the SMP profile.

samples needs distance and force columns (snowmicropyn’s Profile.samples). Falls back to the first sample when the profile is shorter than the 1 mm window or no surface rises out of the air noise.

Return type:

float

weac.parser.utils.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| exceeds T start their own layer; <= T samples merge. Default 12 (== 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.0 leaves thicknesses unscaled.

Returns:

Layers ordered surface -> ground. sum(layer.h) equals the summed cell thickness times depth_scale.

Return type:

list[Layer]

weac.parser.utils.plumb_to_slope_normal(phi_deg)[source]

Scale vertical (plumb) depth/thickness to distance along slope normal.

Field profiles typically report depths from the surface along the vertical. WEAC slab layer thicknesses are measured normal to the slope. The plumb-line depth d_v is converted to slope-normal depth d_n by d_n = d_v * cos(phi), where phi is the slope angle from horizontal.

Parameters:

phi_deg (float)

Return type:

float