run_benchmark() is a simple entry point that takes model output and
observations dataframes, aligns them by time, computes metrics, and returns a plot.
Both input dataframes must have the following two columns:
time — timestamp (POSIXct, e.g. 2020-01-01 00:00:00)value — numeric variable valuelibrary(PEcAn.benchmark)
# Assuming model_df and obs_df are loaded data.frames
res <- run_benchmark(
model_df = model_df,
obs_df = obs_df
)
# View metrics
print(res$metrics)
# metric value
# 1 RMSE 0.1322876
# 2 MAE 0.1250000
# View plot
res$plot
model_df — data.frame containing model outputobs_df — data.frame containing observationsmetrics — vector of metrics to compute: "RMSE", "MAE" (default: both)tolerance_secs — max time difference for matching (default: 3600 seconds)PEcAn Functions Used for Benchmarking
You can install the development version of PEcAn.benchmark from r-universe like so:
# Enable repository from pecanproject
options(repos = c(
pecanproject = 'https://pecanproject.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install PEcAn.benchmark in R
install.packages('PEcAn.benchmark')
Or you can install directly from GitHub with the remotes package like so:
library(remotes)
install_github('pecanproject/pecan', subdir = "modules/benchmark")
This is a basic example which shows you how to solve a common problem:
library(PEcAn.benchmark)
## basic example code