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

Create scatterplots for the REF #3923

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f02e295
Update seaborn diagnostics for scatter plot
aytacpacal Nov 5, 2024
d51c422
Add ORCID link for author Pacal, Aytac in config-references.yml
aytacpacal Nov 7, 2024
d8de7fd
fix reset_true and diagnostic comment
debe-kevin Nov 18, 2024
f0f727f
fix codacy issues, tested output plots
diegokam Jan 8, 2025
343a533
Merge branch 'main' into seaborn-scatter
diegokam Jan 8, 2025
dbd04da
add scatter plots and histograms for clt, lwcre, swcre, draft documen…
diegokam Jan 17, 2025
c5a66a2
add CMIP6 models for single scatter plots clt/lwcre, clt/swcre
diegokam Jan 20, 2025
c006051
clean recipe, test timerange 1982/2000 for all models/obs, rollback s…
diegokam Jan 21, 2025
01dc137
Merge branch 'main' into seaborn-scatter
diegokam Jan 21, 2025
d16c4d6
extend timerange to 1982/2002
diegokam Jan 21, 2025
3ed215d
add plots, update draft documentation
diegokam Jan 21, 2025
5cf99f1
Merge branch 'main' into seaborn-scatter
diegokam Jan 24, 2025
a1b14c0
rm old plots, add reviewed recipe_scatterplot
diegokam Jan 24, 2025
7f33b00
Merge branch 'seaborn-scatter' of https://github.com/ESMValGroup/ESMV…
diegokam Jan 24, 2025
8c1f84e
add scatterplot clt/swcre
diegokam Jan 27, 2025
1863688
test plots labels in recipe, remove old plscatterot, sadd new plscatt…
diegokam Jan 28, 2025
b352583
rename new scatterplots
diegokam Jan 28, 2025
4965c66
update documentation
diegokam Jan 28, 2025
8c923c6
Merge branch 'main' into seaborn-scatter
diegokam Jan 28, 2025
27bef07
Merge remote-tracking branch 'public/main' into seaborn-scatter
LisaBock Feb 18, 2025
368adc9
create recipe
LisaBock Feb 21, 2025
612dd4e
add docu
LisaBock Feb 21, 2025
8f4a394
remove unneeded files
LisaBock Feb 21, 2025
9d33393
undo changes
LisaBock Feb 21, 2025
0d0707c
Merge remote-tracking branch 'public/main' into ref_scatter
LisaBock Feb 21, 2025
8901fc7
Update doc/sphinx/source/recipes/recipe_ref.rst
LisaBock Feb 21, 2025
603faba
remove old changes
LisaBock Feb 21, 2025
bd04f0d
Update esmvaltool/diag_scripts/seaborn_diag.py
LisaBock Feb 21, 2025
0fee03a
Update esmvaltool/recipes/ref/recipe_ref_scatterplot.yml
LisaBock Feb 21, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion doc/sphinx/source/recipes/recipe_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ Available recipes
Recipes are stored in recipes/ref

* recipe_ref_cre.yml:
Maps and zonal means of longwave and shortwave cloud radiative effect
Maps and zonal means of longwave and shortwave cloud radiative effect.

* recipe_ref_scatterplot.yml
2D histograms with focus on clouds.


Example plots:
Expand All @@ -36,3 +39,17 @@ Example plots:
Zonal averages of the climatological mean longwave cloud radiative
effect from CERES-EBAF Ed4.2 (solid black), ESACCI-CLOUD (dashed black),
ISCCP-FH (dotted black) and the MPI-ESM1-2-LR model (blue).

.. _fig_ref_3:
.. figure:: /recipes/figures/ref/seaborn_jointplot.png
:align: center

2D histogram of total cloud fraction and longwave cloud radiative
effect from CESM2-WACCM for the years 2002-2014 with 1D histograms attached.

.. _fig_ref_4:
.. figure:: /recipes/figures/ref/seaborn_displot.png
:align: center

2D histogram of total cloud fraction and longwave cloud radiative
effect from CESM2-WACCM and ESACCI-CLOUD for the years 2002-2014.
9 changes: 9 additions & 0 deletions esmvaltool/diag_scripts/seaborn_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def _create_plot(
plot_func_str,
_get_str_from_kwargs(plot_kwargs),
)

plot_obj = plot_func(data=data_frame, **plot_kwargs)

# Adjust plot appearance
Expand Down Expand Up @@ -443,6 +444,14 @@ def _set_legend_title(plot_obj, legend_title: str) -> None:
legend = plot_obj.get_legend()
elif hasattr(plot_obj, 'legend'): # FacetGrid, PairGrid
legend = plot_obj.legend
elif isinstance(plot_obj, sns.axisgrid.JointGrid): # JointGrid
# Manually create a legend if needed in JointGrid
handles, labels = plot_obj.ax_joint.get_legend_handles_labels()
if handles and labels:
legend = plot_obj.ax_joint.legend(handles=handles, labels=labels,
title=legend_title)
else:
legend = None
else:
raise ValueError(
f"Cannot set legend title, `{type(plot_obj).__name__}` does not "
Expand Down
113 changes: 113 additions & 0 deletions esmvaltool/recipes/ref/recipe_ref_scatterplot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# ESMValTool
---
documentation:
title: Model evaluation with focus on clouds.
description: >
Plot scatter plots of two different variables using the Seaborn diagnostic
in ESMValTool.
authors:
- bock_lisa
- lauer_axel
maintainer:
- bock_lisa

timerange_for_models: &time_period
timerange: '2005/2014' # can be specified, this is just an example

diagnostics:
plot_joint_clt_lwcre:
description: Scatterplot clt vs lwcre.
variables:
clt:
mip: Amon
exp: historical
ensemble: r1i1p1
<<: *time_period
lwcre:
mip: Amon
derive: true
force_derivation: false
exp: historical
ensemble: r1i1p1
<<: *time_period
additional_datasets:
- {dataset: CESM2-WACCM, project: CMIP6, grid: gn, ensemble: r1i1p1f1}
scripts:
plot:
script: seaborn_diag.py
seaborn_func: jointplot
title:
seaborn_kwargs:
kind: hist
x: clt
y: lwcre
bins: 20 # Adjust binning for histograms
stat: probability
cmap: YlGnBu
marginal_ticks: True
marginal_kws:
color: darkturquoise
bins: 20
fill: True
stat: probability
add_aux_coords: true
dropna_kwargs:
axis: 0
how: any
plot_object_methods:
set_axis_labels:
xlabel: 'clt [%]'
ylabel: 'lwcre [W m-2]'
seaborn_settings:
style: ticks
rc:
axes.titlepad: 15.0

plot_hist_with_ref_clt_lwcre:
description: Scatterplot clt vs swcre with reference.
variables:
clt:
mip: Amon
exp: historical
ensemble: r1i1p1
<<: *time_period
lwcre:
mip: Amon
derive: true
force_derivation: false
exp: historical
ensemble: r1i1p1
<<: *time_period
additional_datasets:
- {dataset: ESACCI-CLOUD, project: OBS, type: sat, version: AVHRR-AMPM-fv3.0, tier: 2, alias: ESACCI-CLOUD}
- {dataset: CESM2-WACCM, project: CMIP6, grid: gn, ensemble: r1i1p1f1, alias: CESM2-WACCM}
scripts:
plot:
script: seaborn_diag.py
seaborn_func: displot
seaborn_kwargs:
kind: hist
col: alias # Creates side-by-side plots for each dataset
x: clt
y: lwcre
bins: 20 # Adjust binning for histograms
height: 5 # Set height of each subplot
aspect: 1.2 # Set aspect ratio
stat: probability
common_norm: True
cmap: YlGnBu
cbar: True # Includes a color bar
cbar_kws:
label: "Probability"
add_aux_coords: true
dropna_kwargs:
axis: 0
how: any
plot_object_methods:
set_axis_labels:
xlabel: 'clt [%]'
ylabel: 'swcre [W m-2]'
seaborn_settings:
style: ticks
rc:
axes.titlepad: 15.0