Skip to content

Commit 1a79a37

Browse files
NParsonsMOehogan
andauthored
Radiation budget: labelling plots with alias (#4292)
Co-authored-by: Emma Hogan <ehogan@users.noreply.github.com>
1 parent 6e3d065 commit 1a79a37

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

doc/sphinx/source/recipes/recipe_radiation_budget.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ Available recipes and diagnostics
2222

2323
Recipes are stored in esmvaltool/recipes/
2424

25-
* recipe_radiation_budget.yml
25+
* recipe_radiation_budget.yml
2626

2727
Diagnostics are stored in esmvaltool/diag_scripts/radiation_budget/
2828

29-
* radiation_budget.py: Plot the global radiation budget.
30-
* seasonal_radiation_budget.py: Write the global climatological seasonal radiation budget to a text file.
29+
* radiation_budget.py: Plot the global radiation budget.
30+
* seasonal_radiation_budget.py: Write the global climatological seasonal radiation budget to a text file.
3131

3232

3333

3434
User settings in recipe
3535
-----------------------
3636

37-
None
37+
Users may specify the label to appear in the plot legend for each model, using the keyword ``alias`` in the dataset.
38+
For example, the following dataset entry would label the model as "HadGEM3-GC3.1 N96ORCA1" in the plot legend:
39+
40+
.. code-block:: yaml
41+
42+
{dataset: HadGEM3-GC31-LL, alias: HadGEM3-GC3.1 N96ORCA1, project: ... }
43+
3844
3945
4046
Variables

esmvaltool/diag_scripts/radiation_budget/radiation_budget.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ def load_obs_data():
291291

292292

293293
def plot_data(
294-
model_dataset,
295294
model_data,
295+
model_label,
296296
model_period,
297297
obs_names,
298298
obs_unit,
@@ -307,11 +307,11 @@ def plot_data(
307307
308308
Parameters
309309
----------
310-
model_dataset : string
311-
The name of the model.
312310
model_data : list
313311
Data values from the model for which this comparison plot is being
314312
generated.
313+
model_label : string
314+
An identifier for the model dataset to be used in the plot legend.
315315
model_period : string
316316
The start and end years of the model dataset.
317317
obs_names : list
@@ -341,7 +341,7 @@ def plot_data(
341341
model_minus_ceres = np.array(model_data) - np.array(ceres_data)
342342

343343
figure, axes = plt.subplots(figsize=(12, 8))
344-
title = f"Radiation budget for {model_dataset}"
344+
title = f"Radiation budget for {model_label}"
345345
y_label = f"Difference between model output and observations [{obs_unit}]"
346346
y_lim = (-20, 20)
347347
axes.set(title=title, ylabel=y_label, ylim=y_lim)
@@ -357,7 +357,7 @@ def plot_data(
357357
bar_width,
358358
alpha=opacity,
359359
color="cornflowerblue",
360-
label=f"{model_dataset} ({model_period}) - Stephens et al. (2012)",
360+
label=f"{model_label} ({model_period}) - Stephens et al. (2012)",
361361
yerr=stephens_error,
362362
)
363363
axes.bar(
@@ -367,7 +367,7 @@ def plot_data(
367367
alpha=opacity,
368368
color="orange",
369369
label=(
370-
f"{model_dataset} ({model_period}) - {ceres_dataset} "
370+
f"{model_label} ({model_period}) - {ceres_dataset} "
371371
f"({ceres_period})"
372372
),
373373
)
@@ -377,7 +377,7 @@ def plot_data(
377377
bar_width,
378378
alpha=opacity,
379379
color="darkgrey",
380-
label=f"{model_dataset} ({model_period}) - Demory et al. (2014)",
380+
label=f"{model_label} ({model_period}) - Demory et al. (2014)",
381381
)
382382
axes.spines["bottom"].set_position(("data", 0))
383383
axes.spines["top"].set_position(("data", 0))
@@ -442,16 +442,20 @@ def main(config):
442442

443443
for model_dataset, group in datasets.items():
444444
# 'model_dataset' is the name of the model dataset.
445-
# 'group' is a list of dictionaries containing metadata.
445+
# 'group' is a list of dictionaries containing metadata for each variable.
446446
logger.info("Processing data for %s", model_dataset)
447447
filenames = [item["filename"] for item in group]
448448
unordered_model_data = iris.load(filenames)
449449
all_model_data = derive_additional_variables(unordered_model_data)
450450
model_data = order_data(all_model_data, obs_names, obs_unit)
451+
# An assumption has been made that the start_year, end_year and alias
452+
# from the first variable in the list (for a given dataset)
453+
# is the same as all the others.
451454
model_period = f"{group[0]['start_year']} - {group[0]['end_year']}"
455+
model_label = group[0]["alias"]
452456
figure = plot_data(
453-
model_dataset,
454457
model_data,
458+
model_label,
455459
model_period,
456460
obs_names,
457461
obs_unit,

esmvaltool/recipes/recipe_radiation_budget.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ documentation:
1818
- hogan_emma
1919

2020
datasets:
21-
- {dataset: HadGEM3-GC31-LL, project: CMIP6, exp: historical,
21+
- {dataset: HadGEM3-GC31-LL, alias: HadGEM3-GC31-LL, project: CMIP6, exp: historical,
2222
ensemble: r1i1p1f3, grid: gn, start_year: 1993, end_year: 2002}
23-
- {dataset: UKESM1-0-LL, project: CMIP6, exp: historical,
23+
- {dataset: UKESM1-0-LL, alias: UKESM1-0-LL, project: CMIP6, exp: historical,
2424
ensemble: r5i1p1f3, grid: gn, start_year: 1993, end_year: 2002}
2525

2626
preprocessors:
@@ -40,7 +40,7 @@ preprocessors:
4040

4141
diagnostics:
4242
single_value_radiation_budget:
43-
description: Radiation budget for HadGEM3 vs UKESM1.
43+
description: Radiation budget.
4444
variables:
4545
rss:
4646
mip: Emon
@@ -92,7 +92,7 @@ diagnostics:
9292
script: radiation_budget/radiation_budget.py
9393

9494
seasonal_radiation_budget:
95-
description: Seasonal radiation budget for HadGEM3 vs UKESM1.
95+
description: Seasonal radiation budget.
9696
variables:
9797
rss:
9898
mip: Emon

0 commit comments

Comments
 (0)