weac.parser package¶
Subpackages¶
- weac.parser.plotting package
- Submodules
- Module contents
- weac.parser.utils package
Submodules¶
Module contents¶
Parsers that convert field-profile formats into WEAC layers.
- class weac.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]]
- class weac.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.SnowPilotParser(file_path)[source]¶
Bases:
objectParser for SnowPilot files using the snowpylot library.
- Parameters:
file_path (str)
- pit_slope_angle_deg()[source]¶
Slope angle from CAAML
validSlopeAngleif present, elseNone.- Return type:
float | None
- extract_layers(slope_angle_deg=0.0)[source]¶
Extract layers from snowpit.
Depths and thicknesses in CAAML are measured along the vertical. For WEAC, pass the same slope angle (degrees from horizontal) as
ScenarioConfig.phi; thicknesses and matching depths are scaled to slope-normal bycos(phi). The default0leaves depths unchanged (vertical equals slope-normal on flat terrain). To use the angle stored in the pit file, passslope_angle_deg=parser.pit_slope_angle_deg() or 0.0.- Parameters:
slope_angle_deg (float)
- Return type:
tuple[list[Layer], list[str]]
- class weac.parser.SnowScopeParser(file_path, *, density_method='HAGENMULLER2018', semilog_slope=None, semilog_intercept=None)[source]¶
Bases:
objectParser for SnowScope CSV files.
- Parameters:
file_path (str)
density_method (DensityMethod)
semilog_slope (float | None)
semilog_intercept (float | None)
- __init__(file_path, *, density_method='HAGENMULLER2018', semilog_slope=None, semilog_intercept=None)[source]¶
- Parameters:
file_path (str)
density_method (Literal['HAGENMULLER2018'])
semilog_slope (float | None)
semilog_intercept (float | None)
- extract_profile(*, density_method=None, semilog_slope=None, semilog_intercept=None)[source]¶
Return depth, penetration resistance, and density for one parameterization.
Converts penetration resistance (kPa) to density (kg/m³) via the semilog model
D = a ln(F) + b, clipping sub-1 kg/m³ values.Coefficients are chosen in order: call-level
semilog_slope/semilog_intercept, then call-leveldensity_method, then constructor custom semilog (if set), else the constructordensity_methodpreset.- Parameters:
density_method (Literal['HAGENMULLER2018'] | None)
semilog_slope (float | None)
semilog_intercept (float | None)
- Return type:
- extract_layers(slope_angle_deg=0.0, *, method='bin', density_method=None, semilog_slope=None, semilog_intercept=None, layer_thickness_mm=None, gradient_threshold=12.0)[source]¶
Segment the SnowScope density profile into WEAC slab layers (top-down).
The SnowScope probe descends along the global vertical, so
depth_mmis a plumb depth while WEACLayer.his slope-normal. As in the SnowPilot parser, thicknesses are converted plumb -> slope-normal bycos(phi)viaplumb_to_slope_normal(). The SnowScope file records no slope, soslope_angle_degdefaults to0(no scaling); scale only when the angle is known (pass it explicitly).- Parameters:
slope_angle_deg (float) – Slope angle [deg from horizontal].
0leaveshas recorded; non-zero scaleshbycos(phi).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['HAGENMULLER2018'] | None) – Optional preset override for this call only.
semilog_slope (float | None) – Optional semilog slope
ainD = a ln(F) + bfor this call; must be paired withsemilog_intercept.semilog_intercept (float | None) – Optional semilog intercept
b; must be paired withsemilog_slope. Takes precedence overdensity_method.layer_thickness_mm (float | None) – Bin mode only;
Nonegroups at native sample 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]]
- class weac.parser.SnowScopeProfile(depth_mm, penetration_resistance_kPa, density_kg_m3, density_method)[source]¶
Bases:
objectAligned SnowScope penetration resistance and derived density.
- Parameters:
depth_mm (ndarray)
penetration_resistance_kPa (ndarray)
density_kg_m3 (ndarray)
density_method (Literal['HAGENMULLER2018', 'CUSTOM'])
- depth_mm: ndarray¶
- penetration_resistance_kPa: ndarray¶
- density_kg_m3: ndarray¶
- density_method: Literal['HAGENMULLER2018', 'CUSTOM']¶
- __init__(depth_mm, penetration_resistance_kPa, density_kg_m3, density_method)¶
- Parameters:
depth_mm (ndarray)
penetration_resistance_kPa (ndarray)
density_kg_m3 (ndarray)
density_method (Literal['HAGENMULLER2018', 'CUSTOM'])
- Return type:
None