|
| 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