forked from PecanProject/pecan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidation_report.qmd
More file actions
80 lines (70 loc) · 1.92 KB
/
Copy pathValidation_report.qmd
File metadata and controls
80 lines (70 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
title: "PEcAn Validation Benchmark Report"
author: "PEcAn Validation Toolkit"
format:
html:
theme: cosmo
toc: true
toc-depth: 3
embed-resources: true
params:
benchmark_results: null
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(ggplot2)
```
## Executive Summary
The following scorecard summarizes the validation metrics computed during the benchmark run.
```{r scorecard}
# Quarto execute_params passes strings. If it's a file path, load the RDS.
if (is.character(params$benchmark_results) && file.exists(params$benchmark_results)) {
results <- readRDS(params$benchmark_results)
} else {
results <- params$benchmark_results
}
if (!is.null(results) && !is.null(results$metrics)) {
# Check if knitr is available to use kable
if (requireNamespace("knitr", quietly = TRUE)) {
knitr::kable(results$metrics, digits = 3)
} else {
print(results$metrics)
}
} else {
cat("No metrics data provided.\n")
}
```
## Visual Diagnostics
```{r plots, results='asis', fig.width=10, fig.height=6}
if (!is.null(results) && !is.null(results$plots)) {
plots <- results$plots
# if plots is a flat list of ggplot objects
if (inherits(plots[[1]], "ggplot")) {
for (p_name in names(plots)) {
cat(sprintf("\n### %s\n\n", p_name))
print(plots[[p_name]])
cat("\n\n")
}
} else {
# If plots are nested by variable: plots[[var_name]]$timeseries
for (var in names(plots)) {
cat(sprintf("\n### Variable: %s\n\n", var))
var_plots <- plots[[var]]
if (!is.null(var_plots$timeseries)) {
print(var_plots$timeseries)
cat("\n\n")
}
if (!is.null(var_plots$scatter)) {
print(var_plots$scatter)
cat("\n\n")
}
if (!is.null(var_plots$residual)) {
print(var_plots$residual)
cat("\n\n")
}
}
}
} else {
cat("No plots provided.\n")
}
```