Skip to contents

A unified helper that executes any epicrop model (e.g., bacterial_blight(), brown_spot(), leaf_blast(), sheath_blight(), tungro(), modified_kim_leaf_blast(), modified_kim_sheath_blight(), leaf_rust(), or s_tritici_blotch()) over a set of emergence dates, using a list of per-year weather data.tables. Handles within-year and cross-year windows without globally binding weather.

Usage

run_epicrop_model(
  model_fun,
  emergence_dates,
  wth_list,
  window_days = 120L,
  output = "audpc",
  ...
)

Arguments

model_fun

Function. An epicrop model function (e.g., bacterial_blight()).

emergence_dates

Vector of dates (character "YYYY-MM-DD", Date, or IDate).

wth_list

Named list of weather data.table::data.tables with one per year; names(wth_list) must be year strings (e.g., "2001"). Each table must have a YYYYMMDD column (Date/IDate/ISO/"YYYYMMDD").

window_days

Integer. Days after emergence to include (default 120L). The slicer returns exactly window_days rows when data are available.

output

Character. "audpc" (compact summary using get_audpc()) or "full" (return full model outputs per date, with emergence added). Defaults to "audpc".

...

Additional arguments forwarded to model_fun.

Value

A data.table::data.table. When output = "audpc": columns emergence (IDate) and AUDPC (numeric). When output = "full": full model output columns plus emergence, and an AUDPC column preserved per emergence date.

See also

fetch_epicrop_weather_list, build_epicrop_emergence

Author

Adam H. Sparks, adamhsparks@gmail.com

Examples

years <- 2001:2003
month_day <- c("-06-01", "-06-14", "-06-30")
lonlat <- c(121.255669, 14.16742)
duration <- 120L
emergence <- build_epicrop_emergence(years, month_day)

wth_list <- fetch_epicrop_weather_list(years,
                                       lonlat,
                                       start_date = month_day,
                                       duration = duration)
#> Error in .norm_locations(lonlat): `lonlat` numeric vector must have even length.
#>  You provided length 3
#>  Expected pairs of (longitude, latitude)

# AUDPC for bacterial blight
run_epicrop_model(bacterial_blight,
                  emergence,
                  wth_list,
                  window_days = 120L,
                  output = "audpc")
#> Error in seir(wth = wth, emergence = emergence, RcA = RcA %||% .RcA_bacterial_blight,     RcT = RcT %||% .RcT_bacterial_blight, onset = 20L, duration = 120L,     rhlim = 90L, rainlim = 5L, H0 = 100L, I0 = 1L, RcOpt = 0.87,     p = 5L, i = 30L, Sx = 3200L, a = 4L, simple_wetness = TRUE,     age_driver = "day", ...): formal argument "duration" matched by multiple actual arguments