weac.parser.smp_parser module¶
Parse SnowMicroPen .PNT files into WEAC layers via snowmicropyn.
Density and SSA are derived with snowmicropyn’s Löwe 2012 shot-noise model plus one of the shipped parameterizations (see https://snowmicropyn.readthedocs.io/en/latest/):
Proksch, 2015 (
P2015)Calonne & Richter, 2020 (
CR2020)King, 2020a / 2020b (
K2020a,K2020b)
- class weac.parser.smp_parser.SMPProfile(coordinates, depth_mm, penetration_resistance_kPa, density_kg_m3, ssa_m2_kg, density_method)[source]¶
Bases:
objectWindowed SMP penetration resistance, density, and SSA cropped to the snowpack.
- Parameters:
coordinates (tuple[float, float] | None)
depth_mm (ndarray)
penetration_resistance_kPa (ndarray)
density_kg_m3 (ndarray)
ssa_m2_kg (ndarray)
density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b'])
- coordinates: tuple[float, float] | None¶
- depth_mm: ndarray¶
- penetration_resistance_kPa: ndarray¶
- density_kg_m3: ndarray¶
- ssa_m2_kg: ndarray¶
- density_method: Literal['P2015', 'CR2020', 'K2020a', 'K2020b']¶
- __init__(coordinates, depth_mm, penetration_resistance_kPa, density_kg_m3, ssa_m2_kg, density_method)¶
- Parameters:
coordinates (tuple[float, float] | None)
depth_mm (ndarray)
penetration_resistance_kPa (ndarray)
density_kg_m3 (ndarray)
ssa_m2_kg (ndarray)
density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b'])
- Return type:
None
- class weac.parser.smp_parser.SMPParser(file_path, *, density_method='P2015', surface_mm=None, surface_method='snowmicropyn', apply_drift_correction=False)[source]¶
Bases:
objectParser for SMP
.PNTfiles using snowmicropyn.- Parameters:
file_path (str)
density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b'])
surface_mm (float | None)
surface_method (Literal['snowmicropyn', 'knappe', 'manual'])
apply_drift_correction (bool)
- __init__(file_path, *, density_method='P2015', surface_mm=None, surface_method='snowmicropyn', apply_drift_correction=False)[source]¶
Load a
.PNTfile and mark surface and ground.- Parameters:
file_path (str) – Path to the SMP
.PNTfile.density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b']) – Default parameterization for
extract_profile().surface_mm (float | None) – Manual surface marker, mm along the probe. When set, the surface is placed here and
surface_methodis recorded as"manual". Required whensurface_methodis"manual".surface_method (Literal['snowmicropyn', 'knappe', 'manual']) –
"snowmicropyn"callssnowmicropyn.Profile.detect_surface()."knappe"usesdetect_knappe_surface()."manual"places the surface atsurface_mm.apply_drift_correction (bool) – Subtract snowmicropyn’s force offset after the surface marker is set.
- file_path: str¶
- density_method: Literal['P2015', 'CR2020', 'K2020a', 'K2020b']¶
- surface_method: Literal['snowmicropyn', 'knappe', 'manual']¶
- loaded_profile: Profile¶
- extract_profile(*, density_method=None)[source]¶
Return the windowed penetration resistance/density/SSA profile for one parameterization.
Runs the Löwe 2012 shot-noise model plus the selected parameterization on the cropped snowpack and returns a fresh
SMPProfileeach call (no caching).density_method=Noneuses the constructor default; surface and ground markers are set once at construction and reused here.- Parameters:
density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b'] | None)
- Return type:
- extract_layers(*, method='bin', density_method=None, layer_thickness_mm=None, gradient_threshold=12.0)[source]¶
Segment the SMP density profile into WEAC slab layers (top-down).
The SnowMicroPen is driven normal to the slope, so
depth_mmis already a slope-normal depth and is used directly as WEACLayer.h. Plumb profiles (SnowScope, SnowPilot) still scale bycos(phi); SMP does not.- Parameters:
method (Literal['bin', 'gradient']) – Layering mode.
"bin"groups at a fixed thickness (or the native spacing);"gradient"cuts where the density gradient over a fixed 2.5 mm span exceedsgradient_threshold.density_method (Literal['P2015', 'CR2020', 'K2020a', 'K2020b'] | None) – Optional parameterization override for this call only (constructor default is unchanged).
layer_thickness_mm (float | None) – Bin mode only;
Nonegroups at native Loewe spacing with a 1 mm floor, a value groups samples into ~that thickness. Ignored in gradient mode.gradient_threshold (float) – Gradient mode only; cut threshold
Tin kg/m^3/mm over the 2.5 mm span. Default12.
- Returns:
(layers, density_methods)with layers ordered surface -> ground anddensity_methods = [parameterization] * len(layers).- Return type:
tuple[list[Layer], list[str]]