MalariaSentinel — C++ reference
The contract-defining headers of the ABM engine
Loading...
Searching...
No Matches
wire.hpp
1
23#pragma once
24
25#include <array>
26#include <cmath>
27#include <cstdint>
28
29#include "mal_abm_fast/config.hpp"
30#include <string>
31#include <vector>
32
33namespace mal_abm_fast {
36inline double EIP_BASE_C() { return static_cast<double>(load_config().eip.base_c); }
40inline double EIP_THRESHOLD_GD() { return static_cast<double>(load_config().eip.threshold_gd); }
43inline double ADULT_DISPERSE_PROB() { return static_cast<double>(load_config().dispersal.adult_prob_day); }
46inline double ADULT_DISPERSE_SIGMA_M() { return static_cast<double>(load_config().dispersal.adult_sigma_m); }
49inline double ADULT_DISPERSE_MAX_M() { return static_cast<double>(load_config().dispersal.adult_max_m); }
52inline double WIND_MIGRATION_PROB() { return static_cast<double>(load_config().dispersal.wind_migration_prob); }
55inline double WIND_FLIGHT_HOURS() { return static_cast<double>(load_config().dispersal.wind_flight_hours); }
58inline double WIND_SURVIVAL() { return static_cast<double>(load_config().dispersal.wind_survival); }
61inline double WIND_FLIGHT_SPEED_MS() { return static_cast<double>(load_config().dispersal.wind_self_speed_ms); }
65inline int HOST_SEEKING_STARVATION_DAYS() { return static_cast<int>(load_config().host_seeking.starvation_days); }
68inline double OVIPOSITION_SCALE_M() { return static_cast<double>(load_config().oviposition.scale_m); }
72inline double OVIPOSITION_SEEKING_TIMEOUT_DAYS() { return static_cast<double>(load_config().oviposition.timeout_days); }
75inline double LARVA_BH_S0() { return static_cast<double>(load_config().aquatic_stages.larva_bh_s0); }
78inline double LARVA_BH_ALPHA() { return static_cast<double>(load_config().aquatic_stages.larva_bh_alpha); }
82inline double ADULT_DAILY_MORT_BASAL() { return static_cast<double>(load_config().adults.daily_mort_basal); }
85inline double ADULT_OPT_C() { return static_cast<double>(load_config().adults.opt_c); }
88inline double ADULT_SIGMA() { return static_cast<double>(load_config().adults.sigma_c); }
91inline double ADULT_MORT_CAP() { return static_cast<double>(load_config().adults.mort_cap); }
94inline double ADULT_MORT_FLOOR() { return static_cast<double>(load_config().adults.mort_floor); }
98inline double NODATA_SENTINEL() { return static_cast<double>(load_config().ingest.nodata_sentinel); }
101inline double kEarthRadiusM() { return static_cast<double>(load_config().geodesy.earth_radius_m); }
104inline double kMetresPerDegLat() { return static_cast<double>(load_config().geodesy.metres_per_deg_lat); }
107inline std::string CONTRACT_VERSION() { return load_config().contracts.cogs_state; }
108
109
115
124
130
135
140
148
156
161 float disperse_prob = static_cast<float>(load_config().dispersal.adult_prob_day);
165 float disperse_max_m = static_cast<float>(load_config().dispersal.adult_max_m);
169};
170
175
188
193
199
203
211inline constexpr int STATE_BAND_DENSITY = 1;
214inline constexpr int STATE_BAND_SUITABILITY = 2;
217inline constexpr const char* STATE_BAND_NAMES[2] = {"adult_patch_count", "adult_cell_count"};
218
230inline constexpr const char* GENERATOR_VERSION = "proxy_habitat_v1";
231
237
249struct AOI {
251 double west = 0.0;
253 double south = 0.0;
255 double east = 0.0;
257 double north = 0.0;
259 std::string crs = "EPSG:4326";
261 std::string slug = "custom";
263 int32_t resolution_m = static_cast<int32_t>(
265 std::string scale = "regional";
266
269 int32_t cells_per_side() const noexcept;
270
272 std::array<double, 4> bbox() const noexcept { return {west, south, east, north}; }
273};
274
280 int64_t patch_id = 0;
282 int32_t row = 0;
284 int32_t col = 0;
286 bool activated = false;
287 float rain_d = 0.0f;
288 float temp_d = 25.0f;
292 float habitat_avail = 0.0f;
294 float k_habitat = 0.0f;
295 float salinity_ppt = 0.0f;
296};
297
307 int64_t patch_id = 0;
309 int32_t row = 0;
311 int32_t col = 0;
312 float potential = 0.0f;
313 double lon = 0.0;
314 double lat = 0.0;
315 int dynamics = 0;
316 // (dominant type; diagnostic only)
317};
318
323 std::vector<float> data;
325 int32_t h = 0;
327 int32_t w = 0;
328};
329
335 std::vector<float> data;
337 int32_t h = 0;
339 int32_t w = 0;
340};
341
347
363inline constexpr double kPi = 3.14159265358979323846;
364
365inline int32_t AOI::cells_per_side() const noexcept {
366 const double centroid_lat_rad = ((north + south) * 0.5) * (kPi / 180.0);
367 const double width_m = (east - west) * load_config().geodesy.metres_per_deg_lat * std::cos(centroid_lat_rad);
368 const double cells_d = width_m / static_cast<double>(resolution_m);
369 int32_t cells = static_cast<int32_t>(std::ceil(cells_d));
370 if (cells < 1) cells = 1;
371 return cells;
372}
373
374} // namespace mal_abm_fast
Definition wire.hpp:33
double NODATA_SENTINEL()
Definition wire.hpp:98
int HOST_SEEKING_STARVATION_DAYS()
Definition wire.hpp:65
double kEarthRadiusM()
Definition wire.hpp:101
constexpr const char * STATE_BAND_NAMES[2]
Definition wire.hpp:217
constexpr int STATE_BAND_SUITABILITY
Definition wire.hpp:214
double ADULT_DAILY_MORT_BASAL()
Definition wire.hpp:82
constexpr int STATE_BAND_DENSITY
Definition wire.hpp:211
double WIND_FLIGHT_SPEED_MS()
Definition wire.hpp:61
double EIP_THRESHOLD_GD()
Definition wire.hpp:40
double kMetresPerDegLat()
Definition wire.hpp:104
double ADULT_MORT_CAP()
Definition wire.hpp:91
double ADULT_MORT_FLOOR()
Definition wire.hpp:94
double WIND_SURVIVAL()
Definition wire.hpp:58
const ModelConfig & load_config()
std::string CONTRACT_VERSION()
Definition wire.hpp:107
constexpr const char * GENERATOR_VERSION
Definition wire.hpp:230
double LARVA_BH_ALPHA()
Definition wire.hpp:78
double OVIPOSITION_SCALE_M()
Definition wire.hpp:68
double ADULT_SIGMA()
Definition wire.hpp:88
constexpr double kPi
Definition wire.hpp:363
double ADULT_DISPERSE_SIGMA_M()
Definition wire.hpp:46
double WIND_FLIGHT_HOURS()
Definition wire.hpp:55
double OVIPOSITION_SEEKING_TIMEOUT_DAYS()
Definition wire.hpp:72
double ADULT_DISPERSE_MAX_M()
Definition wire.hpp:49
double LARVA_BH_S0()
Definition wire.hpp:75
double WIND_MIGRATION_PROB()
Definition wire.hpp:52
double EIP_BASE_C()
Definition wire.hpp:36
double ADULT_DISPERSE_PROB()
Definition wire.hpp:43
double ADULT_OPT_C()
Definition wire.hpp:85
Definition wire.hpp:249
double west
Western bbox edge, EPSG:4326 degrees.
Definition wire.hpp:251
std::string crs
CRS identifier of the bbox and the grids.
Definition wire.hpp:259
double north
Northern bbox edge, EPSG:4326 degrees.
Definition wire.hpp:257
double east
Eastern bbox edge, EPSG:4326 degrees.
Definition wire.hpp:255
int32_t cells_per_side() const noexcept
Definition wire.hpp:365
int32_t resolution_m
Ground size of one grid cell, in metres (default from ingest.cell_size_hint_m).
Definition wire.hpp:263
std::string scale
matches Scale.REGIONAL.value
Definition wire.hpp:265
double south
Southern bbox edge, EPSG:4326 degrees.
Definition wire.hpp:253
std::string slug
Short AOI name used in output file naming.
Definition wire.hpp:261
std::array< double, 4 > bbox() const noexcept
Bbox as (W, S, E, N) for GDAL/rasterio interop.
Definition wire.hpp:272
double sigma_c
Standard deviation (°C) of the survival Gaussian (adults.sigma_c).
Definition config.hpp:277
double mort_cap
Definition config.hpp:280
double mort_floor
Definition config.hpp:283
double opt_c
Definition config.hpp:275
double daily_mort_basal
Definition config.hpp:272
double larva_bh_s0
Definition config.hpp:508
double larva_bh_alpha
Definition config.hpp:512
std::string cogs_state
Definition config.hpp:52
Definition wire.hpp:321
std::vector< float > data
Row-major float32 adult counts, h * w entries (band 1).
Definition wire.hpp:323
int32_t w
Number of grid columns.
Definition wire.hpp:327
int32_t h
Number of grid rows.
Definition wire.hpp:325
double adult_sigma_m
Definition config.hpp:414
double adult_max_m
Definition config.hpp:417
double adult_prob_day
Definition config.hpp:411
double wind_survival
Definition config.hpp:425
double wind_migration_prob
Definition config.hpp:420
double wind_self_speed_ms
Definition config.hpp:428
double wind_flight_hours
Duration (h) of the wind-driven flight (dispersal.wind_flight_hours).
Definition config.hpp:422
double base_c
Definition config.hpp:291
double threshold_gd
Definition config.hpp:294
double earth_radius_m
Definition config.hpp:199
double metres_per_deg_lat
Definition config.hpp:203
Definition wire.hpp:305
int dynamics
0 = persistent offer, 1 = pluvial offer
Definition wire.hpp:315
int32_t col
Grid column index of the patch cell.
Definition wire.hpp:311
double lon
EPSG:4326 deg.
Definition wire.hpp:313
float potential
H_total in [0, 1].
Definition wire.hpp:312
double lat
EPSG:4326 deg.
Definition wire.hpp:314
int64_t patch_id
Runtime-assigned row-major index of the patch.
Definition wire.hpp:307
int32_t row
Grid row index of the patch cell.
Definition wire.hpp:309
int starvation_days
Definition config.hpp:453
double cell_size_hint_m
Definition config.hpp:232
double nodata_sentinel
Definition config.hpp:215
AquaticStagesCfg aquatic_stages
Definition config.hpp:583
AdultsCfg adults
The adults: section — the adult survival model.
Definition config.hpp:570
EipCfg eip
The eip: section — the degree-day incubation model.
Definition config.hpp:572
IngestCfg ingest
The ingest: section — input-side constants and thresholds.
Definition config.hpp:568
DispersalCfg dispersal
The dispersal: section — adult movement and the night window.
Definition config.hpp:576
HostSeekingCfg host_seeking
The host_seeking: section — host-seeking behaviour.
Definition config.hpp:578
OvipositionCfg oviposition
The oviposition: section — the breeding-site search.
Definition config.hpp:580
ContractsCfg contracts
The contracts: section — the frozen input/output contract versions.
Definition config.hpp:544
GeodesyCfg geodesy
Definition config.hpp:566
double scale_m
Definition config.hpp:482
int timeout_days
Definition config.hpp:494
Definition wire.hpp:278
int64_t patch_id
Identifier of the habitat patch this state refers to.
Definition wire.hpp:280
float temp_d
Definition wire.hpp:288
int32_t col
Grid column index of the patch cell.
Definition wire.hpp:284
bool activated
True when today's habitat availability reaches the activation threshold.
Definition wire.hpp:286
float habitat_avail
Definition wire.hpp:292
float rain_d
mm, today's daily rainfall at the cell
Definition wire.hpp:287
float salinity_ppt
env water salinity (psu); 0 = freshwater
Definition wire.hpp:295
int32_t row
Grid row index of the patch cell.
Definition wire.hpp:282
int habitat_dry_days
consecutive days below habitat.activation_min_engine
Definition wire.hpp:293
float k_habitat
daily Beverton-Holt capacity (absolute count)
Definition wire.hpp:294
Definition wire.hpp:159
float larva_bh_alpha
Definition wire.hpp:168
float disperse_max_m
Clipping radius of the dispersal step, in metres (overrides dispersal.adult_max_m).
Definition wire.hpp:165
float disperse_sigma_m
Gaussian sigma of the dispersal step, in metres (overrides dispersal.adult_sigma_m).
Definition wire.hpp:163
float disperse_prob
Daily adult dispersal probability, in 1/day (overrides dispersal.adult_prob_day).
Definition wire.hpp:161
Definition wire.hpp:333
std::vector< float > data
Row-major float32 adult counts, h * w entries (band 2).
Definition wire.hpp:335
int32_t w
Number of grid columns.
Definition wire.hpp:339
int32_t h
Number of grid rows.
Definition wire.hpp:337