mal_core.habitat
proxy_habitat_v1 — static breeding-habitat offer + two shared temporal responses.
Canonical model of the pool-hydrology redesign (plan docs/plans/in-process/redesign/02-oferta-criaderos-proxies-download-ingest-abm.md, contract v3.0). Combination formulas for the ABM daily capacity:
S[i,s,t] = clip(sum_g w[s,g] * H[i,g] * A[i,k(g),t], 0, 1)
K[i,s,t] = K_ref[s] * cell_area_km2[i] * S[i,s,t]
Submodules
potential— static potential H[i,g] per habitat type from the manifest contract v3.0 per-cell feature columns.availability— shared temporal responses A[i,k,t] (persistent = 1, pluvial = exponential drying memory + rain recharge), including the causal warm-up.capacity— species-indexed capacity S[i,s,t] and Beverton-Holt scale K[i,s,t].aquatic_stress— biologically preserved end-mechanisms that act on aquatic cohorts (desiccation ramp, heavy-rain washout), mirroring the C++mal_abm_fast/aquatic_stress.hpp.constants— the single value contract (thresholds, scales, names).
These modules are pure python (numpy). The C++ engine re-implements the
same physics; the parity of shared responses is enforced by unit tests
in mal-core/tests/test_habitat_*.py against the Python reference.
Constants migrate to mal-core/config/model_constants.yaml (plan
constants-yaml); engine values win on conflict (see constants.py docstring).
1"""proxy_habitat_v1 — static breeding-habitat offer + two shared temporal responses. 2 3Canonical model of the pool-hydrology redesign (plan 4docs/plans/in-process/redesign/02-oferta-criaderos-proxies-download-ingest-abm.md, 5contract v3.0). Combination formulas for the ABM daily capacity: 6 7 S[i,s,t] = clip(sum_g w[s,g] * H[i,g] * A[i,k(g),t], 0, 1) 8 K[i,s,t] = K_ref[s] * cell_area_km2[i] * S[i,s,t] 9 10Submodules 11---------- 12* ``potential`` — static potential H[i,g] per habitat type from the 13 manifest contract v3.0 per-cell feature columns. 14* ``availability`` — shared temporal responses A[i,k,t] (persistent = 1, 15 pluvial = exponential drying memory + rain recharge), including the 16 causal warm-up. 17* ``capacity`` — species-indexed capacity S[i,s,t] and Beverton-Holt 18 scale K[i,s,t]. 19* ``aquatic_stress`` — biologically preserved end-mechanisms that act on 20 aquatic cohorts (desiccation ramp, heavy-rain washout), mirroring the 21 C++ ``mal_abm_fast/aquatic_stress.hpp``. 22* ``constants`` — the single value contract (thresholds, scales, names). 23 24These modules are pure python (numpy). The C++ engine re-implements the 25same physics; the parity of shared responses is enforced by unit tests 26in ``mal-core/tests/test_habitat_*.py`` against the Python reference. 27Constants migrate to ``mal-core/config/model_constants.yaml`` (plan 28constants-yaml); engine values win on conflict (see constants.py docstring). 29""" 30from __future__ import annotations 31 32from . import ( # noqa: F401 — package-level access 33 aquatic_stress, 34 availability, 35 capacity, 36 config, 37 potential, 38) 39 40# constants.py is a tombstone: it raises for every name. The canonical 41# path is mal_core.habitat.config (CONFIG) — see habitat/__init__.py. 42 43from .config import ( # noqa: F401 44 CONFIG, 45 habitat_names, 46 dynamics_map, 47 persistent_names, 48 pluvial_names, 49) 50 51HABITAT_TYPES = habitat_names() 52HABITAT_DYNAMICS = dynamics_map() 53 54__all__ = [ 55 "aquatic_stress", 56 "availability", 57 "capacity", 58 "config", 59 "potential", 60 "CONFIG", 61 "HABITAT_TYPES", 62 "HABITAT_DYNAMICS", 63]
CONFIG =
mappingproxy({'version': 2, 'contracts': mappingproxy({'env_nc': '3.0', 'cogs_state': '4.0'}), 'habitat_types': mappingproxy({'types': ['surface_persistent', 'wetland_persistent', 'urban_persistent', 'wetland_pluvial', 'open_pluvial', 'crop_pluvial'], 'dynamics': mappingproxy({'surface_persistent': 'persistent', 'wetland_persistent': 'persistent', 'urban_persistent': 'persistent', 'wetland_pluvial': 'pluvial', 'open_pluvial': 'pluvial', 'crop_pluvial': 'pluvial'})}), 'habitat': mappingproxy({'activation_min_engine': 0.01, 'candidate_min_engine': 0.01}), 'pluvial': mappingproxy({'rain_scale_mm': 2.5, 'dry_memory_days': 5.0, 'delta_days': 1.0, 'cold_start_z': 0.0}), 'aquatic_stress': mappingproxy({'desicc_grace_days': 5.0, 'desicc_base_daily': 0.1, 'desicc_ramp_decay': 0.3, 'wash_threshold_mm': 40.0, 'wash_fraction_max': 0.6, 'vulnerable_instar_max': 2}), 'urban': mappingproxy({'beta_urban': 0.75, 'rain_pools_built_damage': 0.3}), 'species': mappingproxy({'default_species': 'coluzzii', 'k_ref': 50.0, 'coluzzii': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.4, 'wetland_persistent': 0.1, 'urban_persistent': 0.2, 'wetland_pluvial': 0.0, 'open_pluvial': 0.25, 'crop_pluvial': 0.05}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.99, 'cattle': 0.005, 'goat': 0.003, 'sheep': 0.001, 'wildlife': 0.001}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 30.0, 'salinity_slope': 0.08, 'host_seeking_scale_m': 300.0, 'host_seeking_radius_m': 1500.0}), 'gambiae_ss': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.05, 'wetland_persistent': 0.05, 'urban_persistent': 0.15, 'wetland_pluvial': 0.0, 'open_pluvial': 0.65, 'crop_pluvial': 0.1}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.99, 'cattle': 0.005, 'goat': 0.003, 'sheep': 0.001, 'wildlife': 0.001}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 20.0, 'salinity_slope': 0.12, 'host_seeking_scale_m': 300.0, 'host_seeking_radius_m': 1500.0}), 'funestus': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.45, 'wetland_persistent': 0.3, 'urban_persistent': 0.1, 'wetland_pluvial': 0.0, 'open_pluvial': 0.1, 'crop_pluvial': 0.05}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.99, 'cattle': 0.005, 'goat': 0.003, 'sheep': 0.001, 'wildlife': 0.001}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 15.0, 'salinity_slope': 0.15, 'host_seeking_scale_m': 300.0, 'host_seeking_radius_m': 1500.0}), 'arabiensis': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.1, 'wetland_persistent': 0.1, 'urban_persistent': 0.15, 'wetland_pluvial': 0.0, 'open_pluvial': 0.55, 'crop_pluvial': 0.1}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.5, 'cattle': 0.2, 'goat': 0.15, 'sheep': 0.1, 'wildlife': 0.05}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 15.0, 'salinity_slope': 0.15, 'host_seeking_scale_m': 120.0, 'host_seeking_radius_m': 1500.0}), 'melas': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.25, 'wetland_persistent': 0.15, 'urban_persistent': 0.15, 'wetland_pluvial': 0.0, 'open_pluvial': 0.4, 'crop_pluvial': 0.05}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.99, 'cattle': 0.005, 'goat': 0.003, 'sheep': 0.001, 'wildlife': 0.001}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 38.0, 'salinity_slope': 0.02, 'host_seeking_scale_m': 300.0, 'host_seeking_radius_m': 1500.0}), 'stephensi': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.25, 'wetland_persistent': 0.15, 'urban_persistent': 0.15, 'wetland_pluvial': 0.0, 'open_pluvial': 0.4, 'crop_pluvial': 0.05}), 'activity_weights': [0.02, 0.1, 0.8, 0.08], 'pref': mappingproxy({'human': 0.7, 'cattle': 0.15, 'goat': 0.05, 'sheep': 0.05, 'wildlife': 0.05}), 'salinity_opt_ppt': 0.0, 'salinity_hi_tol_ppt': 20.0, 'salinity_slope': 0.15, 'host_seeking_scale_m': 300.0, 'host_seeking_radius_m': 1500.0}), 'neutral': mappingproxy({'weights': mappingproxy({'surface_persistent': 0.25, 'wetland_persistent': 0.15, 'urban_persistent': 0.15, 'wetland_pluvial': 0.0, 'open_pluvial': 0.4, 'crop_pluvial': 0.05})})}), 'capacity': mappingproxy({'persistent_availability': 1.0}), 'geodesy': mappingproxy({'earth_radius_m': 6371008.8, 'metres_per_deg_lat': 111195.08023353292}), 'ingest': mappingproxy({'nodata_sentinel': -9999.0, 'nodata_sentinel_int': -9999, 'residential_from_indoor_frac': 0.8, 'coastline_buffer_m': 2000.0, 'coastline_resolution': 'f', 'sea_water_floor': 0.05, 'cell_size_hint_m': 1000.0, 'candidate_min_ingest': 1e-06, 'min_dilation_radius_cells': 1, 'fill_frac_valid_max': 0.5, 'ocean_mask_threshold': 0.5, 'land_mask_threshold': 0.5, 'valid_count_epsilon': 1e-09, 'grid_degrees_step_max': 1, 'nc_compression_level': 4}), 'wildlife': mappingproxy({'class_suitability': mappingproxy({'water': 0.0, 'trees': 0.9, 'grass': 0.6, 'flooded_vegetation': 0.45, 'crops': 0.3, 'shrub_and_scrub': 0.7, 'built': 0.05, 'bare': 0.2, 'snow_and_ice': 0.1}), 'weights': mappingproxy({'habitat': 0.5, 'water': 0.3, 'remoteness': 0.2})}), 'adults': mappingproxy({'daily_mort_basal': 0.87, 'opt_c': 25.0, 'sigma_c': 15.0, 'mort_cap': 0.93, 'mort_floor': 0.6}), 'eip': mappingproxy({'base_c': 16.0, 'threshold_gd': 110.0}), 'transmission': mappingproxy({'beta_hv': 0.4, 'beta_vh': 0.5, 'human_incubation_days': 12, 'human_infectious_days': 20, 'human_immunity_days': 180, 'initial_human_prevalence': 0.05, 'initial_vector_infected_frac': 0.0}), 'dispersal': mappingproxy({'adult_prob_day': 0.05, 'adult_sigma_m': 450.0, 'adult_max_m': 2000.0, 'wind_migration_prob': 0.05, 'wind_flight_hours': 4.0, 'wind_survival': 0.85, 'wind_self_speed_ms': 1.0, 'flight_hour': 20, 'host_flight_step_m': 500.0, 'snap_radius_m': 500.0, 'night_start_hour': 18, 'night_end_hour': 6}), 'host_seeking': mappingproxy({'starvation_days': 7, 'indoor_attraction_add': 0.72, 'urbanicity_add': 0.2, 'indoor_fraction_urban': 0.72, 'indoor_fraction_rural': 0.3, 'detect_range_m': 2000.0, 'approach_step_m': 50.0}), 'oviposition': mappingproxy({'scale_m': 50.0, 'detect_range_m': 2000.0, 'step_m': 50.0, 'min_attraction': 0.3, 'timeout_days': 7}), 'aquatic_stages': mappingproxy({'egg_daily_mort': 0.08, 'pupa_daily_mort': 0.05, 'larva_bh_s0': 0.95, 'larva_bh_alpha': 0.05, 'last_larval_instar': 4, 'salinity_missing_psu': 0.0}), 'thermal': mappingproxy({'efd_max_eggs_per_day': 0.5, 'efd_tmin_c': 16.0, 'efd_tmax_c': 34.0, 'efd_topt_c': 25.0, 'egg_development_tmin_c': 10.0, 'egg_development_tmax_c': 40.0, 'egg_development_scale': 0.00062, 'larva_development_tmin_c': 10.0, 'larva_development_tmax_c': 40.0, 'larva_development_scale': 0.001, 'pupa_development_tmin_c': 12.0, 'pupa_development_tmax_c': 40.0, 'pupa_development_scale': 0.00066}), 'gonotrophic': mappingproxy({'cycle_duration_days': 2.0, 'first_cycle_days': 4.0, 'feeding_success_rate': 0.825, 'egg_batch_mean': 120, 'egg_batch_n': 240, 'egg_batch_min': 30, 'egg_batch_max': 170, 'resting_duration_days': 0.5}), 'rng': mappingproxy({'aquatic_seed_washout': 789, 'aquatic_seed_stage_mortality': 42, 'aquatic_seed_larva_mortality': 123})})
HABITAT_TYPES =
('surface_persistent', 'wetland_persistent', 'urban_persistent', 'wetland_pluvial', 'open_pluvial', 'crop_pluvial')
HABITAT_DYNAMICS =
{'surface_persistent': 'persistent', 'wetland_persistent': 'persistent', 'urban_persistent': 'persistent', 'wetland_pluvial': 'pluvial', 'open_pluvial': 'pluvial', 'crop_pluvial': 'pluvial'}