Skip to content
Open
8 changes: 7 additions & 1 deletion doc/sphinx/source/recipes/recipe_radiation_budget.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ Diagnostics are stored in esmvaltool/diag_scripts/radiation_budget/
User settings in recipe
-----------------------

None
Users may specify the label to appear in the plot legend for each model, using the keyword ``alias`` in the dataset.
For example, the following dataset entry would label the model as "HadGEM3-GC3.1 N96ORCA1" in the plot legend:

.. code-block:: yaml

{dataset: HadGEM3-GC31-LL, alias: HadGEM3-GC3.1 N96ORCA1, project: ... }



Variables
Expand Down
21 changes: 13 additions & 8 deletions esmvaltool/diag_scripts/radiation_budget/radiation_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def load_obs_data():


def plot_data(
model_dataset,
model_data,
model_label,
model_period,
obs_names,
obs_unit,
Expand All @@ -307,11 +307,11 @@ def plot_data(

Parameters
----------
model_dataset : string
The name of the model.
model_data : list
Data values from the model for which this comparison plot is being
generated.
model_label : string
An identifier for the model dataset to be used in the plot legend.
model_period : string
The start and end years of the model dataset.
obs_names : list
Expand Down Expand Up @@ -341,7 +341,7 @@ def plot_data(
model_minus_ceres = np.array(model_data) - np.array(ceres_data)

figure, axes = plt.subplots(figsize=(12, 8))
title = f"Radiation budget for {model_dataset}"
title = f"Radiation budget for {model_label}"
y_label = f"Difference between model output and observations [{obs_unit}]"
y_lim = (-20, 20)
axes.set(title=title, ylabel=y_label, ylim=y_lim)
Expand All @@ -357,7 +357,7 @@ def plot_data(
bar_width,
alpha=opacity,
color="cornflowerblue",
label=f"{model_dataset} ({model_period}) - Stephens et al. (2012)",
label=f"{model_label} ({model_period}) - Stephens et al. (2012)",
yerr=stephens_error,
)
axes.bar(
Expand All @@ -367,7 +367,7 @@ def plot_data(
alpha=opacity,
color="orange",
label=(
f"{model_dataset} ({model_period}) - {ceres_dataset} "
f"{model_label} ({model_period}) - {ceres_dataset} "
f"({ceres_period})"
),
)
Expand All @@ -377,7 +377,7 @@ def plot_data(
bar_width,
alpha=opacity,
color="darkgrey",
label=f"{model_dataset} ({model_period}) - Demory et al. (2014)",
label=f"{model_label} ({model_period}) - Demory et al. (2014)",
)
axes.spines["bottom"].set_position(("data", 0))
axes.spines["top"].set_position(("data", 0))
Expand Down Expand Up @@ -442,17 +442,22 @@ def main(config):

for model_dataset, group in datasets.items():
# 'model_dataset' is the name of the model dataset.
# 'group' is a list of dictionaries containing metadata.
# 'group' is a list of dictionaries containing metadata for each variable.
logger.info("Processing data for %s", model_dataset)
filenames = [item["filename"] for item in group]
unordered_model_data = iris.load(filenames)
all_model_data = derive_additional_variables(unordered_model_data)
model_data = order_data(all_model_data, obs_names, obs_unit)
# An assumption has been made that the start_year and end_year
# from the first variable in the list (for a given dataset)
# is the same as all the others.
model_period = f"{group[0]['start_year']} - {group[0]['end_year']}"
model_label = group[0]["alias"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, we wanted to affect alias via CMEW by adding alias to a given dataset in the recipe. I'm debating whether we should, now that you have shared before and after images showing the introduction of the alias, specify the alias in the dataset so that the images are the same as before? πŸ€”

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, and this has nothing to do with what you have done, but group[0] is a bit dubious. An assumption has been made that the start_year and end_year from the first variable in the list (for a given dataset) is the same as all the others. This might be a reasonable assumption to make! We should either add a comment stating this assumption, or do a check to ensure that these values are consistent across variables (they really should be, and I don't know what we would do if they weren't!).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, we wanted to affect alias via CMEW by adding alias to a given dataset in the recipe. I'm debating whether we should, now that you have shared before and after images showing the introduction of the alias, specify the alias in the dataset so that the images are the same as before? πŸ€”

b7e7b8e

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, and this has nothing to do with what you have done, but group[0] is a bit dubious. An assumption has been made that the start_year and end_year from the first variable in the list (for a given dataset) is the same as all the others. This might be a reasonable assumption to make! We should either add a comment stating this assumption, or do a check to ensure that these values are consistent across variables (they really should be, and I don't know what we would do if they weren't!).

Done within the function:

1feb6ba

Do you want it documented elsewhere as well?

figure = plot_data(
model_dataset,
model_data,
model_period,
model_label,
obs_names,
obs_unit,
stephens_data,
Expand Down
8 changes: 4 additions & 4 deletions esmvaltool/recipes/recipe_radiation_budget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ documentation:
- hogan_emma

datasets:
- {dataset: HadGEM3-GC31-LL, project: CMIP6, exp: historical,
- {dataset: HadGEM3-GC31-LL, alias: HadGEM3-GC31-LL, project: CMIP6, exp: historical,
ensemble: r1i1p1f3, grid: gn, start_year: 1993, end_year: 2002}
- {dataset: UKESM1-0-LL, project: CMIP6, exp: historical,
- {dataset: UKESM1-0-LL, alias: UKESM1-0-LL, project: CMIP6, exp: historical,
ensemble: r5i1p1f3, grid: gn, start_year: 1993, end_year: 2002}

preprocessors:
Expand All @@ -40,7 +40,7 @@ preprocessors:

diagnostics:
single_value_radiation_budget:
description: Radiation budget for HadGEM3 vs UKESM1.
description: Radiation budget.
variables:
rss:
mip: Emon
Expand Down Expand Up @@ -92,7 +92,7 @@ diagnostics:
script: radiation_budget/radiation_budget.py

seasonal_radiation_budget:
description: Seasonal radiation budget for HadGEM3 vs UKESM1.
description: Seasonal radiation budget.
variables:
rss:
mip: Emon
Expand Down
Loading