inst/doc/cumba-experiment.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment  = "#>",
  fig.width = 7, fig.height = 5,
  message = FALSE, warning = FALSE
)

## ----run----------------------------------------------------------------------
library(cumba)
library(dplyr)
library(ggplot2)

data(tomatoFoggia)
data(cumbaParameters)

out <- cumba_experiment(
  weather              = tomatoFoggia$weather,
  param                = cumbaParameters,
  irrigation_df        = tomatoFoggia$irrigation,
  estimateRad          = TRUE,
  estimateET0          = TRUE,
  irrigationEfficiency = 0.9,
  fullOut              = FALSE
)

head(out)

## ----harvest------------------------------------------------------------------
harvest <- out |>
  group_by(site, year, experiment) |>
  slice_tail(n = 1) |>
  ungroup() |>
  select(site, year, experiment, yield, brix)

harvest

## ----compare------------------------------------------------------------------
production <- tomatoFoggia$production

cmp <- harvest |>
  mutate(experiment = as.integer(experiment)) |>
  inner_join(production, by = c("experiment" = "ID")) |>
  mutate(yield_t = yield / 10)

ggplot(cmp, aes(yield_ref, yield_t)) +
  geom_abline(slope = 1, intercept = 0, linetype = 2, colour = "grey50") +
  geom_smooth(method = "lm", se = TRUE, colour = "#d6604d",
              fill = "#f4a582", linewidth = 0.8) +
  geom_point(size = 3, colour = "#2166ac", alpha = 0.85) +
  labs(x = "Observed yield (t ha⁻¹)",
       y = "Simulated yield (t ha⁻¹)",
       title = "CUMBA — yield validation") +
  theme_bw(base_size = 12)

ggplot(cmp, aes(brix_ref, brix)) +
  geom_abline(slope = 1, intercept = 0, linetype = 2, colour = "grey50") +
  geom_smooth(method = "lm", se = TRUE, colour = "#4dac26",
              fill = "#b8e186", linewidth = 0.8) +
  geom_point(size = 3, colour = "#762a83", alpha = 0.85) +
  labs(x = "Observed Brix (°Brix)",
       y = "Simulated Brix (°Brix)",
       title = "CUMBA — Brix validation") +
  theme_bw(base_size = 12)

## ----full, eval = FALSE-------------------------------------------------------
# out_full <- cumba_experiment(
#   weather              = tomatoFoggia$weather,
#   param                = cumbaParameters,
#   irrigation_df        = tomatoFoggia$irrigation,
#   estimateRad          = TRUE,
#   estimateET0          = TRUE,
#   fullOut              = TRUE
# )
# 
# names(out_full)

Try the cumba package in your browser

Any scripts or data that you put into this service are public.

cumba documentation built on Nov. 19, 2026, 5:11 p.m.