mal_core.habitat.aquatic_stress
Preserved aquatic stress mechanisms: desiccation ramp + rain washout.
End-mechanism formulas carried over from the retired regime (M14 pool hydrology), now expressed against the new availability state (plan 02 §7.2: keep the biological bits, drop the mm model):
desiccation_rate(days_dry)— grace period firstaquatic_stress.desicc_grace_daysdays, then an exponential ramp todesicc_base_daily(ramp exponentdesicc_ramp_decay). Applies to eggs and early instars (L1, L2). The C++ engine drivesdays_dryfrom consecutive days below the activation threshold (a cell with S > habitat.activation_min_engine has days_dry = 0).washout_fraction(rain_mm)— heavy-rain cohort flush, linear from 0 atwash_threshold_mmtowash_fraction_maxat2 x wash_threshold_mm, capped. Applies to all aquatic stages; adults are never washed out.
Values live in mal-core/config/model_constants.yaml (aquatic_stress
section); both formulas mirror mal_abm_fast/aquatic_stress.hpp 1:1.
1"""Preserved aquatic stress mechanisms: desiccation ramp + rain washout. 2 3End-mechanism formulas carried over from the retired regime (M14 pool 4hydrology), now expressed against the new availability state (plan 02 5§7.2: keep the biological bits, drop the mm model): 6 7* ``desiccation_rate(days_dry)`` — grace period first 8 ``aquatic_stress.desicc_grace_days`` days, then an exponential ramp to 9 ``desicc_base_daily`` (ramp exponent ``desicc_ramp_decay``). Applies to 10 eggs and early instars (L1, L2). 11 The C++ engine drives ``days_dry`` from consecutive days below the 12 activation threshold (a cell with S > habitat.activation_min_engine 13 has days_dry = 0). 14* ``washout_fraction(rain_mm)`` — heavy-rain cohort flush, linear from 0 15 at ``wash_threshold_mm`` to ``wash_fraction_max`` at 16 ``2 x wash_threshold_mm``, capped. Applies to all aquatic stages; 17 adults are never washed out. 18 19Values live in ``mal-core/config/model_constants.yaml`` (aquatic_stress 20section); both formulas mirror ``mal_abm_fast/aquatic_stress.hpp`` 1:1. 21""" 22from __future__ import annotations 23 24import math 25 26from .config import CONFIG 27 28_STRESS = CONFIG["aquatic_stress"] 29 30 31def desiccation_rate(days_dry: int | float) -> float: 32 """Daily mortality fraction at a dry (not active) patch.""" 33 grace = float(_STRESS["desicc_grace_days"]) 34 if days_dry <= grace: 35 return 0.0 36 past_grace = float(days_dry) - grace 37 ramp = 1.0 - math.exp( 38 -float(_STRESS["desicc_ramp_decay"]) * past_grace) 39 return float(_STRESS["desicc_base_daily"]) * ramp 40 41 42def washout_fraction(rain_mm: float) -> float: 43 """Fraction of aquatic cohorts flushed by today's rain.""" 44 wash_mm = float(_STRESS["wash_threshold_mm"]) 45 frac_max = float(_STRESS["wash_fraction_max"]) 46 if rain_mm < wash_mm: 47 return 0.0 48 excess = (float(rain_mm) - wash_mm) / wash_mm 49 return min(frac_max, excess * frac_max) 50 51 52__all__ = ["desiccation_rate", "washout_fraction"]
def
desiccation_rate(days_dry: int | float) -> float:
32def desiccation_rate(days_dry: int | float) -> float: 33 """Daily mortality fraction at a dry (not active) patch.""" 34 grace = float(_STRESS["desicc_grace_days"]) 35 if days_dry <= grace: 36 return 0.0 37 past_grace = float(days_dry) - grace 38 ramp = 1.0 - math.exp( 39 -float(_STRESS["desicc_ramp_decay"]) * past_grace) 40 return float(_STRESS["desicc_base_daily"]) * ramp
Daily mortality fraction at a dry (not active) patch.
def
washout_fraction(rain_mm: float) -> float:
43def washout_fraction(rain_mm: float) -> float: 44 """Fraction of aquatic cohorts flushed by today's rain.""" 45 wash_mm = float(_STRESS["wash_threshold_mm"]) 46 frac_max = float(_STRESS["wash_fraction_max"]) 47 if rain_mm < wash_mm: 48 return 0.0 49 excess = (float(rain_mm) - wash_mm) / wash_mm 50 return min(frac_max, excess * frac_max)
Fraction of aquatic cohorts flushed by today's rain.