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: object

Windowed 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: object

Parser for SMP .PNT files 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 .PNT file and mark surface and ground.

Parameters:
  • file_path (str) – Path to the SMP .PNT file.

  • 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_method is recorded as "manual". Required when surface_method is "manual".

  • surface_method (Literal['snowmicropyn', 'knappe', 'manual']) – "snowmicropyn" calls snowmicropyn.Profile.detect_surface(). "knappe" uses detect_knappe_surface(). "manual" places the surface at surface_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 SMPProfile each call (no caching). density_method=None uses 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:

SMPProfile

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_mm is already a slope-normal depth and is used directly as WEAC Layer.h. Plumb profiles (SnowScope, SnowPilot) still scale by cos(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 exceeds gradient_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; None groups 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 T in kg/m^3/mm over the 2.5 mm span. Default 12.

Returns:

(layers, density_methods) with layers ordered surface -> ground and density_methods = [parameterization] * len(layers).

Return type:

tuple[list[Layer], list[str]]