Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recreate perfmetrics portrait plot in python #3551

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
bc2a6b2
example variables and models
lukruh Mar 14, 2024
b74414f
added some datasets for fixed calendar
lukruh Mar 14, 2024
f78d2e5
first approach group gaps WIP
lukruh Mar 20, 2024
93c5544
imagegrid for grouping, labels, colorbar, docstring
lukruh Mar 20, 2024
db30131
WIP triangle overlays
lukruh Mar 20, 2024
215ee95
added CMIP6 experiments
diegokam Mar 21, 2024
b4f8238
WIP split by reference
lukruh Mar 21, 2024
5c30d4a
added icon example
lukruh Mar 21, 2024
07e676a
Merge branch 'perfmetric_python' of github.com:ESMValGroup/ESMValTool…
lukruh Mar 21, 2024
42fdd81
split square feature, xarray instead of nested dicts
lukruh Mar 27, 2024
4ab76cb
3 recipe examples
lukruh Mar 27, 2024
32ad034
fix config overwrite
lukruh Mar 27, 2024
d66e5e2
legend for multiple references
lukruh Mar 28, 2024
e1bb9c4
Merge branch 'main' into perfmetric_python
lukruh Apr 2, 2024
30541be
pre-commit
lukruh Apr 2, 2024
5eb01f2
Merge branch 'perfmetric_python' of github.com:ESMValGroup/ESMValTool…
lukruh Apr 2, 2024
d6a541f
add normalization for metrics
lukruh Apr 2, 2024
7fb8a10
codacy fixes
lukruh Apr 3, 2024
eba93db
WIP Documentation
lukruh Apr 3, 2024
ffee698
adding myself to list of authors
diegokam Apr 3, 2024
54ad3d8
number of local vars, alphabetical sorting by x labels
lukruh Apr 5, 2024
7cbcf86
add dpi option and plot legend only for multiple splits
lukruh Apr 16, 2024
f7b6c87
WIP recreate example perfmetric recipe
lukruh Apr 16, 2024
39df74e
add optional calculation of distance metrics
lukruh May 2, 2024
a896ce6
fix bug for non default "split" facet
lukruh May 2, 2024
62086aa
recipe CMIP5 python, new python script creating netcdf file
diegokam Nov 4, 2024
8c9aa90
comparison script NetCDF files
diegokam Nov 4, 2024
9b20ac3
fixed pp heights, name changed, add provenance
lukruh Nov 5, 2024
db01441
format recipe (pre commit)
lukruh Nov 5, 2024
efc026a
simplify recipe p1
lukruh Nov 6, 2024
af917bc
MM stats as first columns (wip)
lukruh Nov 6, 2024
d25290e
simpler cmip5 vs cmip6 plot
lukruh Nov 6, 2024
9ae502c
provenance update, non-scalar error
lukruh Nov 19, 2024
666837c
don't overwrite users default_split
lukruh Nov 19, 2024
ac0e95e
remove experimental/dev recipes
lukruh Nov 19, 2024
0492849
remove first compare script
lukruh Nov 19, 2024
946cb00
fix minor codacy issues
lukruh Nov 19, 2024
7242b23
setting trivial doc string to imperative to make codacy finally happy
lukruh Nov 19, 2024
bc6d237
simplify docstring
lukruh Nov 19, 2024
4712895
recipe documentation
lukruh Nov 20, 2024
5e337b3
fix rst error
lukruh Nov 20, 2024
bf61ccf
set msissing facets to "unknown"
lukruh Nov 20, 2024
78a8146
seperate portrait from performance metrics folder/docs
lukruh Nov 21, 2024
6d39ff6
Merge branch 'main' into perfmetric_python
lukruh Nov 21, 2024
6fe20a1
fix rst style issues and documentation links
lukruh Nov 21, 2024
d9ba763
Merge branch 'perfmetric_python' of github.com:ESMValGroup/ESMValTool…
lukruh Nov 21, 2024
e592aa3
remove preproc distance metrics call from diagnostic
lukruh Nov 21, 2024
05c03eb
remove old comments
lukruh Nov 21, 2024
051513c
add test recipe, removed comment
lukruh Nov 21, 2024
9863272
grammar
lukruh Nov 21, 2024
c8f2136
typo
lukruh Nov 21, 2024
216a7af
remove comment, change yaml formatting for dataset
lukruh Nov 21, 2024
fb73bac
clearify docs about example vs diag feature
lukruh Nov 21, 2024
22e1c5d
grammar
lukruh Nov 21, 2024
5df02db
seperate save_netcdf from plot()
lukruh Nov 21, 2024
4cb1154
Merge branch 'main' into perfmetric_python
lukruh Nov 21, 2024
11fc9d9
rephrase first paragraph
lukruh Nov 22, 2024
2b5781b
phrasing
lukruh Nov 22, 2024
9707d29
more grammar and typos
lukruh Nov 22, 2024
e80f39e
Merge branch 'perfmetric_python' of github.com:ESMValGroup/ESMValTool…
lukruh Nov 22, 2024
0f5af79
remove distance metric parameter, change name
lukruh Nov 22, 2024
404ad27
more typos
lukruh Nov 22, 2024
7484d5a
more typos
lukruh Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Plot performance metrics of multiple datasets vs up to four references
======================================================================

A :doc:`documented <recipe_portrait>` example recipe to use this diagnostic
is provided as `recipes/recipe_portrait_CMIP.yml`.

.. automodule:: esmvaltool.diag_scripts.portrait_plot
1 change: 1 addition & 0 deletions doc/sphinx/source/api/esmvaltool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Diagnostic Scripts
esmvaltool.diag_scripts.ocean
esmvaltool.diag_scripts.psyplot_diag
esmvaltool.diag_scripts.seaborn_diag
esmvaltool.diag_scripts.portrait_plot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/sphinx/source/recipes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Climate metrics
:maxdepth: 1

recipe_perfmetrics
recipe_portrait
recipe_smpi

Future projections
Expand Down
93 changes: 72 additions & 21 deletions doc/sphinx/source/recipes/recipe_perfmetrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@
Performance metrics for essential climate parameters
====================================================

.. note::
Some of the results of this diagnostics can also be rproduced utilizing
lukruh marked this conversation as resolved.
Show resolved Hide resolved
python diagnostics:
Portrait plot: :ref:`recipe_portrait`
Monitoring: :ref:`recipe_monitor`

Overview
--------

The goal is to create a standard recipe for the calculation of performance metrics to quantify the ability of the models to reproduce the climatological mean annual cycle for selected "Essential Climate Variables" (ECVs) plus some additional corresponding diagnostics and plots to better understand and interpret the results.
The goal is to create a standard recipe for the calculation of performance
metrics to quantify the ability of the models to reproduce the climatological
mean annual cycle for selected "Essential Climate Variables" (ECVs) plus some
additional corresponding diagnostics and plots to better understand and
interpret the results.

The recipe can be used to calculate performance metrics at different vertical
levels (e.g., 5, 30, 200, 850 hPa as in
`Gleckler et al. (2008) <http://dx.doi.org/10.1029/2007JD008972>`_) and in
different regions. As an additional reference, we consider
`Righi et al. (2015) <https://doi.org/10.5194/gmd-8-733-2015>`_.

The recipe can be used to calculate performance metrics at different vertical levels (e.g., 5, 30, 200, 850 hPa as in `Gleckler et al. (2008) <http://dx.doi.org/10.1029/2007JD008972>`_ and in different regions. As an additional reference, we consider `Righi et al. (2015) <https://doi.org/10.5194/gmd-8-733-2015>`_.

Available recipes and diagnostics
-----------------------------------
Expand All @@ -21,12 +36,19 @@ Recipes are stored in recipes/

Diagnostics are stored in diag_scripts/perfmetrics/

* main.ncl: calculates and (optionally) plots annual/seasonal cycles, zonal means, lat-lon fields and time-lat-lon fields. The calculated fields can also be plotted as difference w.r.t. a given reference dataset. main.ncl also calculates RMSD, bias and taylor metrics. Input data have to be regridded to a common grid in the preprocessor. Each plot type is created by a separated routine, as detailed below.
* main.ncl: calculates and (optionally) plots annual/seasonal cycles, zonal
means, lat-lon fields and time-lat-lon fields. The calculated fields can also
be plotted as difference w.r.t. a given reference dataset. main.ncl also
calculates RMSD, bias and taylor metrics. Input data have to be regridded to
a common grid in the preprocessor. Each plot type is created by a separated
routine, as detailed below.
* cycle.ncl: creates an annual/seasonal cycle plot.
* zonal.ncl: creates a zonal (lat-pressure) plot.
* latlon.ncl: creates a lat-lon plot.
* cycle_latlon.ncl: precalculates the metrics for a time-lat-lon field, with different options for normalization.
* collect.ncl: collects and plots the metrics previously calculated by cycle_latlon.ncl.
* cycle_latlon.ncl: precalculates the metrics for a time-lat-lon field, with
different options for normalization.
* collect.ncl: collects and plots the metrics previously calculated by
cycle_latlon.ncl.

User settings in recipe
-----------------------
Expand All @@ -37,9 +59,12 @@ User settings in recipe

*Required settings (scripts)*

* plot_type: cycle (time), zonal (plev, lat), latlon (lat, lon), cycle_latlon (time, lat, lon), cycle_zonal (time, plev, lat)
* plot_type: cycle (time), zonal (plev, lat), latlon (lat, lon), cycle_latlon
(time, lat, lon), cycle_zonal (time, plev, lat)
* time_avg: type of time average (monthlyclim, seasonalclim, annualclim)
* region: selected region (global, trop, nhext, shext, nhtrop, shtrop, nh, sh, nhmidlat, shmidlat, nhpolar, shpolar, eq)
* region: selected region (global, trop, nhext, shext, nhtrop, shtrop, nh,
sh, nhmidlat, shmidlat, nhpolar, shpolar, eq)


*Optional settings (scripts)*

Expand All @@ -51,9 +76,12 @@ User settings in recipe
* projection: map projection for plot_type latlon (default: CylindricalEquidistant)
* plot_diff: draws difference plots (default: False)
* calc_grading: calculates grading metrics (default: False)
* stippling: uses stippling to mark statistically significant differences (default: False = mask out non-significant differences in gray)
* show_global_avg: diplays the global avaerage of the input field as string at the top-right of lat-lon plots (default: False)
* annots: choose the annotation style, e.g. ```alias``` which would display the alias of the dataset as title (applies to plot_type zonal and cycle_zonal)
* stippling: uses stippling to mark statistically significant differences
(default: False = mask out non-significant differences in gray)
* show_global_avg: displays the global avaerage of the input field as string
at the top-right of lat-lon plots (default: False)
* annots: choose the annotation style, e.g. ```alias``` which would display
the alias of the dataset as title (applies to plot_type zonal and cycle_zonal)
* metric: chosen grading metric(s) (if calc_grading is True)
* normalization: metric normalization (for RMSD and BIAS metrics only)
* abs_levs: list of contour levels for absolute plot
Expand Down Expand Up @@ -114,8 +142,8 @@ User settings in recipe

*Optional settings (scripts)*

* label_lo: adds lower triange for values outside range
* label_hi: adds upper triange for values outside range
* label_lo: adds lower triangle for values outside range
* label_hi: adds upper triangle for values outside range
* cm_interval: min and max color of the color table
* cm_reverse: reverses the color table
* sort: sorts datasets in alphabetic order (excluding MMM)
Expand Down Expand Up @@ -157,14 +185,21 @@ Variables
Observations and reformat scripts
---------------------------------

The following list shows the currently used observational data sets for this recipe with their variable names and the reference to their respective reformat scripts in parentheses. Please note that obs4MIPs data can be used directly without any reformating. For non-obs4MIPs data use `esmvaltool data info DATASET` or see headers of cmorization scripts (in `/esmvaltool/cmorizers/data/formatters/datasets/
<https://github.com/ESMValGroup/ESMValTool/blob/main/esmvaltool/cmorizers/data/formatters/datasets/>`_) for downloading and processing instructions.
The following list shows the currently used observational data sets for this
recipe with their variable names and the reference to their respective reformat
scripts in parentheses. Please note that obs4MIPs data can be used directly
without any reformatitng. For non-obs4MIPs data use `esmvaltool data info DATASET`
or see headers of cmorization scripts (in `/esmvaltool/cmorizers/data/formatters/datasets/
<https://github.com/ESMValGroup/ESMValTool/blob/main/esmvaltool/cmorizers/data/formatters/datasets/>`_)
for downloading and processing instructions.

#. recipe_perfmetrics_CMIP5.yml

* AIRS (hus - obs4MIPs)
* CERES-EBAF (rlut, rlutcs, rsut, rsutcs - obs4MIPs)
* ERA-Interim (tas, ta, ua, va, zg, hus - esmvaltool/cmorizers/data/formatters/datasets/era-interim.py)
* ESACCI-AEROSOL (od550aer, od870aer, od550abs, od550lt1aer - esmvaltool/cmorizers/data/formatters/datasets/esacci-aerosol.ncl)
* ESACCI-AEROSOL (od550aer, od870aer, od550abs, od550lt1aer -
esmvaltool/cmorizers/data/formatters/datasets/esacci-aerosol.ncl)
* ESACCI-CLOUD (clt - esmvaltool/cmorizers/data/formatters/datasets/esacci-cloud.ncl)
* ESACCI-OZONE (toz - esmvaltool/cmorizers/data/formatters/datasets/esacci-ozone.ncl)
* ESACCI-SOILMOISTURE (sm - esmvaltool/cmorizers/data/formatters/datasets/esacci_soilmoisture.ncl)
Expand All @@ -190,27 +225,38 @@ The following list shows the currently used observational data sets for this rec
References
----------

* Gleckler, P. J., K. E. Taylor, and C. Doutriaux, Performance metrics for climate models, J. Geophys. Res., 113, D06104, doi: 10.1029/2007JD008972 (2008).
* Gleckler, P. J., K. E. Taylor, and C. Doutriaux, Performance metrics for climate models, J.
Geophys. Res., 113, D06104, doi: 10.1029/2007JD008972 (2008).

* Righi, M., Eyring, V., Klinger, C., Frank, F., Gottschaldt, K.-D., Jöckel, P.,
and Cionni, I.: Quantitative evaluation of oone and selected climate parameters in a set of EMAC simulations,
lukruh marked this conversation as resolved.
Show resolved Hide resolved
Geosci. Model Dev., 8, 733, doi: 10.5194/gmd-8-733-2015 (2015).

* Righi, M., Eyring, V., Klinger, C., Frank, F., Gottschaldt, K.-D., Jöckel, P., and Cionni, I.: Quantitative evaluation of oone and selected climate parameters in a set of EMAC simulations, Geosci. Model Dev., 8, 733, doi: 10.5194/gmd-8-733-2015 (2015).

Example plots
-------------

.. figure:: /recipes/figures/perfmetrics/perfmetrics_fig_1.png
:width: 90%

Annual cycle of globally averaged temperature at 850 hPa (time period 1980-2005) for different CMIP5 models (historical simulation) (thin colored lines) in comparison to ERA-Interim (thick yellow line) and NCEP-NCAR-R1 (thick black dashed line) reanalysis data.
Annual cycle of globally averaged temperature at 850 hPa (time period 1980-2005)
for different CMIP5 models (historical simulation) (thin colored lines) in comparison to
ERA-Interim (thick yellow line) and NCEP-NCAR-R1 (thick black dashed line) reanalysis data.

.. figure:: /recipes/figures/perfmetrics/perfmetrics_fig_2.png
:width: 90%

Taylor diagram of globally averaged temperature at 850 hPa (ta) and longwave cloud radiative effect (lwcre) for different CMIP5 models (historical simulation, 1980-2005). Reference data (REF) are ERA-Interim for temperature (1980-2005) and CERES-EBAF (2001-2012) for longwave cloud radiative effect.
Taylor diagram of globally averaged temperature at 850 hPa (ta) and longwave cloud
radiative effect (lwcre) for different CMIP5 models (historical simulation, 1980-2005).
Reference data (REF) are ERA-Interim for temperature (1980-2005) and CERES-EBAF (2001-2012)
for longwave cloud radiative effect.

.. figure:: /recipes/figures/perfmetrics/perfmetrics_fig_3.png
:width: 90%

Difference in annual mean of zonally averaged temperature (time period 1980-2005) between the CMIP5 model MPI-ESM-MR (historical simulation) and ERA-Interim. Stippled areas indicdate differences that are statistically significant at a 95% confidence level.
Difference in annual mean of zonally averaged temperature (time period 1980-2005) between the
CMIP5 model MPI-ESM-MR (historical simulation) and ERA-Interim. Stippled areas indicdate
differences that are statistically significant at a 95% confidence level.

.. figure:: /recipes/figures/perfmetrics/perfmetrics_fig_4.png
:width: 90%
Expand All @@ -221,4 +267,9 @@ Example plots
:width: 90%
:align: center

Relative space-time root-mean-square deviation (RMSD) calculated from the climatological seasonal cycle of CMIP5 simulations. A relative performance is displayed, with blue shading indicating better and red shading indicating worse performance than the median of all model results. A diagonal split of a grid square shows the relative error with respect to the reference data set (lower right triangle) and the alternative data set (upper left triangle). White boxes are used when data are not available for a given model and variable.
Relative space-time root-mean-square deviation (RMSD) calculated from the climatological
seasonal cycle of CMIP5 simulations. A relative performance is displayed, with blue shading
indicating better and red shading indicating worse performance than the median of all model results.
A diagonal split of a grid square shows the relative error with respect to the reference data set
(lower right triangle) and the alternative data set (upper left triangle).
White boxes are used when data are not available for a given model and variable.
95 changes: 95 additions & 0 deletions doc/sphinx/source/recipes/recipe_portrait.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.. _recipe_portrait:

Portrait plot
=============


Overview
--------
Portrait plots are a flexible way to visualize performance metrics for multiple
datasets and up to four references. In this recipe `recipe_portrait_CMIP.yml`
the normalized Root Mean Squared Deviation (RMSD) of global mean seasonal
climatologies is shown for a selection of CMIP models is plotted.
lukruh marked this conversation as resolved.
Show resolved Hide resolved
For each variable up to two observation based datasets are used as reference.
lukruh marked this conversation as resolved.
Show resolved Hide resolved
See :ref:`variables` for complete list of references.




User settings in recipe
-----------------------

This plot expects a scalar value in each input file and at most one input
file for each subset of metadata that belongs to a cell or part of cell in
the figure.
lukruh marked this conversation as resolved.
Show resolved Hide resolved
By default cells are plotted for combinations of `short_name`,
`dataset`, `project` and `split`.
Where `split` is an optional extra_facet for variables.
lukruh marked this conversation as resolved.
Show resolved Hide resolved
However, all this can be customized using the `x_by`,
lukruh marked this conversation as resolved.
Show resolved Hide resolved
`y_by`, `group_by` and `split_by` script settings.
For a complete and detailed list of settings see the
lukruh marked this conversation as resolved.
Show resolved Hide resolved
:ref:`API documentation <api.esmvaltool.diag_scripts.perfmetrics.portrait_plot>`.
While this allows very flexible use for any kind of data, there are some
limitations as well: The grouping (separated
plots in the figure) and normalization is always applied along the x-axis.
lukruh marked this conversation as resolved.
Show resolved Hide resolved
With default settings this means normalizing all metrics for each variable
and grouping all datasets by project.

To plot distance metrics like RMSE, pearson R, bias etc. the
:func:`distance_metrics <esmvalcore.preprocessor.derive>` preprocessor or
custom diagnostics can be used.



.. _variables:

Variables and Datasets
------------------------

.. note::

The recipe generally works for any variable that is preprocessed correctly.
To use different preprocessors or reference datasets it could be useful
to create different variable groups and link them with the same extra_facet
like `variable_name` See recipe for examples. Below listed are the variables
lukruh marked this conversation as resolved.
Show resolved Hide resolved
used to produce the example figure.


The following list shows which observational dataset is used as reference for
each variable in this recipe. All variables are atmospheric monthly means.
For 3D variables the selected pressure level is given in parentheses.
lukruh marked this conversation as resolved.
Show resolved Hide resolved

* clt (Ref1: ESACCI-CLOUD, Ref2: PATMOS-x)
* pr (Ref1: GPCP-V2.2)
* rlut, rsut (Ref1: CERES-EBAF)
* tas (Ref1: ERA-Interim, Ref2: NCEP-NCAR-R1)
* ts (Ref1: ESACCI-SST, Ref2: HadISST)
* ua (200 hPa, Ref1: ERA-Interim, Ref2: NCEP-NCAR-R1)
* zg (500 hPa, Ref1: ERA-Interim, Ref2: NCEP-NCAR-R1)


References
----------

* Gleckler, P. J., K. E. Taylor, and C. Doutriaux, Performance metrics for climate models, J.
Geophys. Res., 113, D06104, doi: 10.1029/2007JD008972 (2008).

* Righi, M., Eyring, V., Klinger, C., Frank, F., Gottschaldt, K.-D., Jöckel, P.,
and Cionni, I.: Quantitative evaluation of oone and selected climate parameters in a set of EMAC simulations,
lukruh marked this conversation as resolved.
Show resolved Hide resolved
Geosci. Model Dev., 8, 733, doi: 10.5194/gmd-8-733-2015 (2015).


Example plots
-------------

.. _fig_portrait_plot:

.. figure:: /recipes/figures/portrait/portrait_plot.png
:width: 90%
:align: center


Relative space-time root-mean-square deviation (RMSD) calculated from the climatological
seasonal cycle of CMIP5 and CMIP6 simulations. A relative performance is displayed, with blue shading
indicating better and red shading indicating worse performance than the median of all model results.
A diagonal split of a grid square shows the relative error with respect to the reference data set
lukruh marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions esmvaltool/config-references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ authors:
institute: DLR, Germany
email: [email protected]
orcid:
cammarano_diego:
name: Cammarano, Diego
institute: DLR, Germany
email: [email protected]
github: diegokam
debeire_kevin:
name: Debeire, Kevin
institute: DLR, Germany
Expand Down
Loading