Usage¶
1 | |
simpest couples two stages: a SIMPLACE/Lintul5 crop growth run
(simpest.models.simplace) and a disease/fungicide
simulation (simpest.models.franchestyn). You can
run the full pipeline, or run the disease/fungicide stage on its own against
crop-model output produced elsewhere.
Stage 1 — Crop growth (SIMPLACE)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
project_row carries the selected project's metadata (location, start/end
dates, sowing option) plus a yearly_sowing_doy mapping extracted from the
SIMPLACE project data.
Converting SIMPLACE output for the disease/fungicide stage¶
1 2 3 4 5 6 7 8 9 10 | |
export_crop_model_datawrites the daily light interception, biomass, yield, and thermal-time series the crop damage mechanisms need.convert_weatherreshapes the SIMPLACE weather file (units, humidity derived from vapour pressure) into the expected columns.build_managementwrites one row per simulated year with the sowing day-of-year (and any fungicide treatment columns you add).
Stage 2 — Disease, pest, and fungicide simulation¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
weather_df, management_df, crop_model_df, and ref_df are plain
DataFrames — run_franchestyn writes them to temporary CSVs internally, so
any source that produces DataFrames with the expected columns works, not
just the SIMPLACE conversion helpers above.
Daily output fields¶
Each record in result["outputs"]["simulation"] has one row per simulated
day, including Date, GrowingSeason, DaysAfterSowing,
GrowingDegreeDays, CycleCompletionPercentage, attainable/actual light
interception (LightInterception, LightIntHealthy), attainable/actual
biomass and yield (AGBattainable, AGBactual, YieldAttainable,
YieldActual), the SEIR compartments (Susceptible, Latent,
Sporulating, Affected, Dead), DiseaseSeverity, FungicideEfficacy,
and the day's weather (Tmax, Tmin, RHx, RHn, TotalPrec, TotalRad,
TotalLW).
Season summary and saved outputs¶
1 2 | |
build_season_summary groups the daily output by growing season and reports
AUDPC (trapezoidal integral of disease severity over time), peak disease
severity, peak attainable/actual yield and biomass, absolute and percentage
yield loss, and season-level weather aggregates.
Convenience writers save these to CSV under
<output_root>/SimulationExperimentTemplate/:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Calibration¶
Setting is_calibration=True (the default) runs a multi-start Nelder–Mead
search over every parameter flagged for calibration in the crop/disease
parameter JSON files, scoped by calibration_variable. n_restarts and
max_iter control the search; crop_disabled_params /
disease_disabled_params (or deactivate_calibration) exclude specific
parameters:
1 2 3 4 5 6 | |
For a fixed-parameter run (no search), set is_calibration=False; the model
runs once with the JSON defaults (or with crop_parameters /
disease_parameters values you've edited in place).
Choosing the optimizer¶
optimizer selects the search strategy:
"nelder-mead"(default) — the built-in multi-start Nelder–Mead simplex search described above, controlled byn_restarts,max_iter, andftol."scipy-nelder-mead"— the same algorithm run throughscipy.optimize.minimize, also multi-start and sharing then_restarts/max_iter/ftolknobs. Useful as a maintained reference to cross-check the built-in optimizer."optuna"— an Optuna TPE (Bayesian) search, controlled byn_trials(number of parameter sets to evaluate) and an optionaloptuna_timeout(seconds). It keeps every candidate inside the parameter bounds and tends to handle the noisy objective surface with fewer evaluations than restart-heavy Nelder–Mead.
seed makes any of the searches reproducible.
1 2 3 4 5 6 | |
Screening parameters before calibration¶
When many parameters are flagged for calibration it is worth checking which
ones actually move the objective. run_morris_sensitivity runs a Morris
elementary-effects screen over the same parameters calibration would use
(flagged for calibration, within calibration_variable scope, minus the
disabled ones):
1 2 3 4 5 6 7 8 9 10 | |
The table has one row per parameter with mu_star (mean absolute effect on the
run's RMSE — higher is more influential), sigma (spread — high relative to
mu_star means non-linear or interacting), and mu_star_conf (bootstrap CI on
mu_star). The screen costs about n_trajectories * (k + 1) model runs for k
parameters.
Then freeze the parameters whose effect is indistinguishable from zero and calibrate the rest:
1 2 3 | |
Crop-only or disease-only runs¶
disease_type=Noneskips the epidemiological model entirely (disease severity stays 0), giving a crop-only run.fungicide_type=Noneskips the fungicide step; only set it when treatments are actually scheduled in the management data, otherwise they are ignored.
Notes on cycle progress and day alignment¶
use_gddcontrols how crop cycle completion is derived from the external crop-model series:False(default) interpolates linearly over calendar days within a cycle;Truescales by accumulated thermal time (GDD) instead. UseTruewhen the reference crop-model run itself completes its cycle based on thermal time rather than a fixed calendar length, otherwise the two can drift out of sync.use_prev_day_alignment(defaultTrue) compares each simulated day to the next day's reference observation during calibration/RMSE scoring (sim[d-1]vsref[d]); setFalsefor same-day alignment.
See the API Reference for the full parameter and return-value
documentation, and
examples/1_Run Simpest.ipynb /
examples/2_Plot.ipynb for a complete, runnable
walkthrough.