Skip to content

Commit 407e97e

Browse files
authored
Merge pull request #4046 from Tejas7007/GH-ilamb-scorecard
Add ILAMB scorecard generation and hosting (follow-on to #4038)
2 parents a3e5e9a + 906b021 commit 407e97e

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
99
## Unreleased
1010

1111
### Added
12+
- Added `make_scorecard.sh` and documentation to `inst/ilamb/` in PEcAn.benchmark for generating and serving the ILAMB HTML scorecard.
1213
- New function `PEcAn.utils::netcdf2df()` flattens all dims and vars of a netCDF into a dataframe,
1314
with units attached as an attribute.
1415
- New package `PEcAn.RothC` runs the RothC soil carbon model.

modules/benchmark/inst/ilamb/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,21 @@ score relative to the other variables, and the `weight` on each dataset block
296296
sets how much that dataset counts within its variable. Both are relative
297297
weights, not percentages. See the inline comments in the config for the full
298298
per-field reference.
299+
300+
## Generating the scorecard
301+
302+
ILAMB produces an interactive HTML scorecard alongside the numeric scores. To
303+
generate it for a window, run `make_scorecard.sh` against that window's model
304+
root (built by the pipeline above):
305+
306+
```bash
307+
export ILAMB_ROOT=/path/to/ILAMB_ROOT
308+
./make_scorecard.sh 2012_2014
309+
./make_scorecard.sh 2015_2023
310+
```
311+
312+
Each run writes a self-contained static site (`index.html` plus assets) to a
313+
build directory, which can be served directly by copying it under a web
314+
server's document root. The scorecard uses the clean model roots, so it lists
315+
PEcAn alongside the individual CMIP6 and TRENDY models and the ensemble means,
316+
rather than the 100 individual PEcAn members used for the spread analysis.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
#
3+
# Generate the ILAMB HTML scorecard for a PEcAn benchmarking window.
4+
#
5+
# Runs ilamb-run against a window's model root (PEcAn, the individual CMIP6
6+
# and TRENDY models, and the ensemble means) to produce the interactive HTML
7+
# scorecard ILAMB writes to the build directory. This is the public-facing
8+
# comparison view; it uses the clean model roots (no individual PEcAn members),
9+
# so the scorecard lists PEcAn alongside the models rather than 100 member rows.
10+
#
11+
# Prerequisites:
12+
# - ILAMB installed and on PATH (ilamb-run).
13+
# - ILAMB_ROOT set, with the benchmark datasets under $ILAMB_ROOT/DATA.
14+
# - The window model root already built (see build_window_ensembles.py),
15+
# e.g. ilamb_models_2012_2014 / ilamb_models_2015_2023.
16+
#
17+
# Usage:
18+
# ./make_scorecard.sh <window> [model_root] [build_dir]
19+
#
20+
# window Required. A label for the run, e.g. 2012_2014 or 2015_2023.
21+
# model_root Optional. Directory of model entities to score.
22+
# Default: ilamb_models_<window>.
23+
# build_dir Optional. Output directory for the HTML scorecard.
24+
# Default: ilamb_scorecard_<window>.
25+
#
26+
# Example:
27+
# export ILAMB_ROOT=/path/to/ILAMB_ROOT
28+
# ./make_scorecard.sh 2012_2014
29+
# ./make_scorecard.sh 2015_2023
30+
#
31+
# The generated build directory (index.html plus assets) is a self-contained
32+
# static site that can be served directly, for example by copying it under a
33+
# web server's document root.
34+
35+
set -euo pipefail
36+
37+
WINDOW="${1:?usage: make_scorecard.sh <window> [model_root] [build_dir]}"
38+
MODEL_ROOT="${2:-ilamb_models_${WINDOW}}"
39+
BUILD_DIR="${3:-ilamb_scorecard_${WINDOW}}"
40+
CONFIG="$(dirname "$0")/pecan_ilamb.cfg"
41+
42+
if [ -z "${ILAMB_ROOT:-}" ]; then
43+
echo "ERROR: ILAMB_ROOT is not set." >&2
44+
exit 1
45+
fi
46+
if [ ! -d "$MODEL_ROOT" ]; then
47+
echo "ERROR: model root '$MODEL_ROOT' not found. Build it first." >&2
48+
exit 1
49+
fi
50+
51+
echo "Generating scorecard for window '$WINDOW'"
52+
echo " model root: $MODEL_ROOT"
53+
echo " build dir: $BUILD_DIR"
54+
55+
ilamb-run --config "$CONFIG" \
56+
--model_root "$MODEL_ROOT" \
57+
--build_dir "$BUILD_DIR" \
58+
--regions global
59+
60+
echo "Done. Open $BUILD_DIR/index.html, or serve $BUILD_DIR as a static site."

0 commit comments

Comments
 (0)