Runs the daily time-step CUMBA simulation for one or more sites/experiments, computing tomato yield and Brix from weather inputs and irrigation options. The function validates inputs, converts a list-of-lists parameter object to a tibble of numeric values when needed, and prints a blue message indicating it is running in *experiment* mode.
Usage
cumba_experiment(
weather,
param,
estimateRad = TRUE,
estimateET0 = TRUE,
irrigation_df,
irrigationEfficiency = 0.9,
fullOut = FALSE,
verbose = FALSE
)Arguments
- weather
A
data.frame(or tibble) of daily weather by site with at leastSite,Tx,Tn,P,DATEand, based on flags, eitherLat(to estimate radiation) orRad(provided radiation). IfestimateET0 = FALSE, anET0column must be present.- param
Model parameters. Either:
a named list where each element is itself a list with fields
value,min,max,description; this form is automatically converted to a tibble of parameter values; ora tibble/data.frame already containing the required parameter values.
The object must contain (as names/columns) all of:
Tbase,Topt,Tmax,Theat,Tcold,FIntMax,CycleLength,TransplantingLag,FloweringLag,HalfIntGrowth,HalfIntSenescence,InitialInt,RUE,KcIni,KcMax,RootIncrease,RootDepthMax,RootDepthInitial,FieldCapacity,WiltingPoint,DepletionFraction,FloweringSlope,FloweringMax,k0,FruitWaterContentMin,FruitWaterContentMax,FruitWaterContentInc,FruitWaterContentDecreaseMax. Cardinal temperatures are validated so thatTmax > Topt > Tbase.- estimateRad
Logical. If
TRUE(default), solar radiation is estimated from temperature (Hargreaves) andLatmust be inweather. IfFALSE,weathermust includeRad.- estimateET0
Logical. If
TRUE(default), reference evapotranspiration (ET0) is estimated from temperature (Hargreaves). IfFALSE,weathermust include anET0column.- irrigation_df
A
data.framewith the irrigation schedule for each experiment/site, containing columnsID,Site,YEAR,DATE,WVOL.- irrigationEfficiency
Numeric (0-1). Fraction of the observed applied water (
WVOL) that effectively reaches the root zone. Default0.9(90%, typical for drip irrigation). Theirrigationcolumn in the output retains the original grossWVOLvalues; only the soil water balance uses the net fraction (WVOL * irrigationEfficiency). Set to1to disable the correction.- fullOut
Logical. If
FALSE(default) returns key outputs; ifTRUEreturns all internal variables.- verbose
Logical. If
TRUE, progress messages are printed to the console; defaultFALSE.
Value
A data.frame containing the input weather plus the
daily CUMBA outputs per site and date; the set of columns depends on
fullOut.
Details
On start, the function prints "CUMBA running in experiment mode" in
blue (via crayon). It checks that all required columns/elements are
present and throws informative errors if anything is missing. Sites are
inferred from the unique values of weather$Site.
If param is supplied as a list-of-lists with a value field,
it is converted internally with tibble::as_tibble(lapply(param, `[[`, "value")).
Required inputs
weather: must include columns Site, Tx, Tn,
P, DATE. Depending on the flags:
if
estimateRad = TRUE(default), columnLatis required;if
estimateRad = FALSE, columnRadis required;if
estimateET0 = FALSE, columnET0is required.
irrigation_df: must include columns ID, Site,
YEAR, DATE, WVOL.
Examples
data(tomatoFoggia)
data(cumbaParameters)
# Replay one growing season from the bundled field dataset
wx <- subset(tomatoFoggia$weather, format(DATE, "%Y") == "2018")
out <- cumba_experiment(wx, cumbaParameters,
irrigation_df = tomatoFoggia$irrigation)
head(out)
#> site year experiment doy p irrigation stage swc yield
#> 1 Foggia 2018 29 117 0.0 20 post-transplanting 30.00000 0
#> 2 Foggia 2018 29 118 0.0 0 post-transplanting 29.73897 0
#> 3 Foggia 2018 29 119 0.0 0 post-transplanting 29.50209 0
#> 4 Foggia 2018 29 120 0.0 0 post-transplanting 29.29649 0
#> 5 Foggia 2018 29 121 0.0 0 post-transplanting 29.25888 0
#> 6 Foggia 2018 29 122 24.8 0 vegetative 30.00000 0
#> brix
#> 1 0
#> 2 0
#> 3 0
#> 4 0
#> 5 0
#> 6 0
