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". required year weather is missing; if FALSE, skip that date with cli::cli_warn().

...

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` must be c(lon, lat), a 2-column matrix/data.frame, or arg list
#> of length-2 numerics.

# AUDPC for bacterial blight
run_epicrop_model(bacterial_blight,
                  emergence,
                  wth_list,
                  window_days = 120L,
                  output = "audpc")
#> Error: object 'wth_list' not found