This notebook reproduces and extends parts of the figures and products of the AR6-WGI Atlas. It is part of a notebook collection available at IPCC-WG1/Atlas for reproducibility and reusability purposes. This work is licensed under a Creative Commons Attribution 4.0 International License.

Creative Commons License >

Computing and visualizing regional climate change (temperature vs precipitation) for reference regions#

24/6/2021

M. Iturbide (Santander Meteorology Group. Institute of Physics of Cantabria, CSIC-UC, Santander, Spain).

This notebook reproduces and extends parts of the regional figures of the AR6-WGI Atlas chapter. In particular, the scatter plots of regional climate change temperature vs. precipitation for the AR6 reference regions using CMIP5 and CMIP6 datasets (Figures Atlas.13, 16 ,17, 21, 22, 24, 26 and 29). This notebook builds on other sections of the repository: 1) auxiliary scripts from reproducibility, and 2) CMIP5/6 - CORDEX datasets-aggregated-regionally for the WGI reference regions.

Load packages and functions#

This notebook is based on the R programming language and requires packages:

  • magrittr to pipe (%>%) sequences of operations

  • httr to handle URLs and HTTP

  • lattice and latticeExtra to produce the figures

  • gridExtra to produce the final panel of plots

library(magrittr)
library(httr)
library(lattice)
library(latticeExtra)
library(gridExtra)

The main function to generate the boxplots and scatterplots is computeFigures, which internally uses functions computeDeltas and computeOffset, all available in this repository. To load these functions in the working environment use the source R base function as follows.

source("../datasets-aggregated-regionally/scripts/computeDeltas.R")
source("../datasets-aggregated-regionally/scripts/computeFigures.R")
source("../datasets-aggregated-regionally/scripts/computeOffset.R")

The scripts are available for download:

Parameter setting#

We define next some parameters, such as the seasons to show in the Precipitation vs Temperature scatterplots. E.g. for boreal winter and summer define:

scatter.seasons <- list(c(12, 1, 2), 6:8)

Select baseline period (e.g. AR6 reference period in this example). Available years in the datasets are 1850-1900 and 1950-2100.

ref.period <- 1995:2014

Select the area, i.e. “land”, “sea” or “landsea”

area <- "land"

Select reference regions (see reference-regions in this repository). Use world to generate global results.

regions <- c("ECA", "EAS"); 

Select a CORDEX domain from the following options: SAM, CAM, NAM, AFR, WAS, EAS, AUS, ANT, ARC, SEA and EUR

cordex.domain <- "EAS"

Finally, select figure axes ranges (ylim for temperature, xlim for precipitation percentage). Leave it as NULL for automatic axes ranges

ylim <- NULL
xlim <- NULL

Compute delta changes and figures#

We are ready to apply the computeFigures function.

fig <- computeFigures(regions = regions,
                      cordex.domain = cordex.domain,
                      area = area, 
                      ref.period = ref.period, 
                      scatter.seasons = scatter.seasons,
                      xlim = xlim,
                      ylim = ylim)
Hide code cell output
[2023-05-07 16:59:44] Computing annual delta changes for the Boxplot of region ECA
[2023-05-07 16:59:44] Computing CMIP5..
[2023-05-07 16:59:45] Computing CMIP6..
[2023-05-07 16:59:47] Computing CORDEX..
[2023-05-07 17:00:02] Computing seasonal delta changes for the Scatterplots of region ECA
[2023-05-07 17:00:02] Computing CMIP5..
[2023-05-07 17:00:06] Computing CMIP6..
[2023-05-07 17:00:12] Computing CORDEX..
[2023-05-07 17:00:16] Computing annual delta changes for the Boxplot of region EAS
[2023-05-07 17:00:16] Computing CMIP5..
[2023-05-07 17:00:18] Computing CMIP6..
[2023-05-07 17:00:19] Computing CORDEX..
[2023-05-07 17:00:34] Computing seasonal delta changes for the Scatterplots of region EAS
[2023-05-07 17:00:34] Computing CMIP5..
[2023-05-07 17:00:38] Computing CMIP6..
[2023-05-07 17:00:44] Computing CORDEX..

The output of the above call (fig) is a list of trellis class objects that can be easily arranged and displayed using the grid.arrange function from the gridExtra library.

do.call("grid.arrange", fig)
../_images/6123a56ef8d1a1b71916df3ed686f4090b322e7d6c182ed622002d551748bdc3.png

The legend and axis label information of these panels is the one shown in the AR6-WGI Atlas chapter figures. The first column shows the annual temperature delta changes. The second and third columns, the scatterplots of the seasonal temperature and precipitation changes. Each row corresponds to a different reference region (ECA and EAS in this worked example).

We can now export the Figure as PDF. There are other export options such as png (type ?pdf for help). The Cairo package provides other export options.

outfilename <- sprintf("%s_%s_baseperiod_%s_ATvsAP.pdf",
  cordex.domain, area, paste(range(ref.period), collapse = "-")
)

pdf(outfilename, width = (length(scatter.seasons)+1)*10/2*0.85, height = length(regions)*10/2*0.85)
  do.call("grid.arrange", fig)
dev.off()
png: 2

Play with arguments width and height to create different PDF sizes.

Set the object cordex.domain as FALSE to exclude CORDEX from the final figure. For example, in order to compute global delta changes, we can set:

regions <- c("world")
cordex.domain <- FALSE

fig.w <- computeFigures(regions = regions,
                      cordex.domain = cordex.domain,
                      area = area, 
                      ref.period = ref.period, 
                      scatter.seasons = scatter.seasons,
                      xlim = xlim,
                      ylim = ylim)
Hide code cell output
[2023-05-07 17:00:48] Computing annual delta changes for the Boxplot of region world
[2023-05-07 17:00:48] Computing CMIP5..
[2023-05-07 17:00:50] Computing CMIP6..
[2023-05-07 17:00:51] Computing CORDEX..
[2023-05-07 17:01:06] Computing seasonal delta changes for the Scatterplots of region world
[2023-05-07 17:01:06] Computing CMIP5..
[2023-05-07 17:01:10] Computing CMIP6..
[2023-05-07 17:01:16] Computing CORDEX..
do.call("grid.arrange", fig.w)
../_images/9bdeb65167cdf0d573f96123438e6e304441356e03e52223857ed4f6fc7af10d.png

We have easily reproduced parts of the AR6-WGI Atlas chapter figures using the function computeFigures. To extend the results shown in the Atlas chapter, just use different parameter settings above, e.g. additional seasons, alternative baselines, etc.

Furthermore, functions computeDeltas and computeOffset (which are internally applied by computeFigures) can also be applied directly to obtain the data behind the boxplots/scatterplots allowing for further plotting options, which we explore next.

Data matrices of delta changes#

In this last example, we will compute CMIP5 annual temperature changes for different Global Warming Levels. Therefore, the following parameters are set.

project <- "CMIP5" # other options are CMIP6 and CORDEX
experiment <- "rcp85" 
var <- "tas"
season <- 1:12
ref.period <- 1986:2005
periods <- c("1.5", "2", "3", "4") 
area <- "land"
region <- c("NSA", "SES")
cordex.domain <- "SAM"

WL.cmip5 <- computeDeltas(project = project, 
                          var = var, 
                          experiment = experiment, 
                          season = season, 
                          ref.period = ref.period, 
                          periods = periods, 
                          area = area, 
                          region = region, 
                          cordex.domain = cordex.domain)
Hide code cell output
ACCESS1-0_r1i1p1.......rcp85------
ACCESS1-3_r1i1p1.......rcp85------
bcc-csm1-1_r1i1p1.......rcp85------
bcc-csm1-1-m_r1i1p1.......rcp85------
CanESM2_r1i1p1.......rcp85------
CCSM4_r1i1p1.......rcp85------
CESM1-BGC_r1i1p1.......rcp85------
CMCC-CM_r1i1p1.......rcp85------
CMCC-CMS_r1i1p1.......rcp85------
CNRM-CM5_r1i1p1.......rcp85------
CSIRO-Mk3-6-0_r1i1p1.......rcp85------
EC-EARTH_r12i1p1.......rcp85------
GFDL-CM3_r1i1p1.......rcp85------
GFDL-ESM2G_r1i1p1.......rcp85------
GFDL-ESM2G_r1i1p1.......rcp85------NO period
GFDL-ESM2M_r1i1p1.......rcp85------
GFDL-ESM2M_r1i1p1.......rcp85------NO period
HadGEM2-CC_r1i1p1.......rcp85------
HadGEM2-ES_r1i1p1.......rcp85------
inmcm4_r1i1p1.......rcp85------
inmcm4_r1i1p1.......rcp85------NO period
IPSL-CM5A-LR_r1i1p1.......rcp85------
IPSL-CM5A-MR_r1i1p1.......rcp85------
IPSL-CM5B-LR_r1i1p1.......rcp85------
MIROC-ESM_r1i1p1.......rcp85------
MIROC-ESM-CHEM_r1i1p1.......rcp85------
MIROC5_r1i1p1.......rcp85------
MIROC5_r1i1p1.......rcp85------NO period
MPI-ESM-LR_r1i1p1.......rcp85------
MPI-ESM-MR_r1i1p1.......rcp85------
MRI-CGCM3_r1i1p1.......rcp85------
MRI-CGCM3_r1i1p1.......rcp85------NO period
NorESM1-M_r1i1p1.......rcp85------
NorESM1-M_r1i1p1.......rcp85------NO period

The cordex.domain parameter will be ignored unless the project is CORDEX (project <- "CORDEX").

The output of the computeDeltas function is a list of matrices, each corresponding to a different reference region. Each column of the matrix corresponds to the warming levels set before. E.g. for the SES region:

WL.cmip5$SES
Hide code cell output
A matrix: 28 Ă— 4 of type dbl
rcp85rcp85rcp85rcp85
ACCESS1-0_r1i1p10.94832921.42998752.4607463.316342
ACCESS1-3_r1i1p11.14704171.51177082.4271083.273229
bcc-csm1-1_r1i1p10.39477921.05462921.9674923.097608
bcc-csm1-1-m_r1i1p10.70281110.86855001.7734252.922742
CanESM2_r1i1p11.00218151.45462082.7521463.829083
CCSM4_r1i1p10.62100131.16693752.1273873.339333
CESM1-BGC_r1i1p10.68457921.16760002.0623293.313937
CMCC-CM_r1i1p10.74094581.35611252.2780213.326538
CMCC-CMS_r1i1p10.97055001.44020422.3707083.405425
CNRM-CM5_r1i1p10.83661671.39810832.1898423.274875
CSIRO-Mk3-6-0_r1i1p11.06700421.57952922.8442883.816117
EC-EARTH_r12i1p10.53818330.88342921.8760962.958067
GFDL-CM3_r1i1p10.98360421.64512502.6918793.626942
GFDL-ESM2G_r1i1p11.22339581.72530832.800908 NA
GFDL-ESM2M_r1i1p11.05235001.60826252.808379 NA
HadGEM2-CC_r1i1p11.03378671.45127842.5910493.326278
HadGEM2-ES_r1i1p10.87435341.24265342.1043033.121641
inmcm4_r1i1p11.26226671.89539582.734242 NA
IPSL-CM5A-LR_r1i1p10.63812261.04540422.1648873.292792
IPSL-CM5A-MR_r1i1p10.60282921.26328752.4623963.771575
IPSL-CM5B-LR_r1i1p10.69075001.15360421.9700872.876000
MIROC-ESM_r1i1p10.87567921.46301672.2418833.352113
MIROC-ESM-CHEM_r1i1p10.97148331.42551252.3990293.431421
MIROC5_r1i1p11.06686671.35307082.071171 NA
MPI-ESM-LR_r1i1p10.66445831.16441252.4017373.817287
MPI-ESM-MR_r1i1p10.79451671.35262922.5871583.999304
MRI-CGCM3_r1i1p10.86607921.43048332.233550 NA
NorESM1-M_r1i1p10.99282501.57232082.492021 NA

Let’s plot the results for this region and each CMIP5 model.

par(mar=c(4, 4, 0, 15), xpd=TRUE) # make room for the legend
plot(NA, xlim=c(1.5, 4), ylim=c(0,4), xlab = "GWL", ylab = "Temperature change in SES (deg. C)", type = "n")
model.names <- row.names(WL.cmip5$SES)
n.models <- length(model.names)
line.colors <- rainbow(n.models)
gwls <- as.numeric(periods)
for (i in 1:n.models){
    lines(gwls, WL.cmip5$SES[i,], col = line.colors[i])
    points(gwls, WL.cmip5$SES[i,], col = line.colors[i], pch=16)
}
legend("topright", legend=model.names, pch=16, lty=1, col=line.colors, inset=c(-1,0))
../_images/f1624904bb9079b23e2230b1cc8301e931eec0fc6abe9dcec6cedbd191df0c1c.png

Once the data is obtained, the user is free to apply any additional operations. For instance, in the next cell we will compute the ensemble mean for the SES region using the apply function.

WL.cmip5.mean <- apply(WL.cmip5$SES, 2, mean, na.rm = T)
plot(gwls, WL.cmip5.mean, type = "b")
../_images/1545cda5506caf1048a862dc387a338275f6e30a47a6a3d21e7abe1a96ff40aa.png

Use a for or a lapply loop to apply the same operation for all available regions:

WL.cmip5.mean <- lapply(WL.cmip5, function(x) apply(x, 2, mean, na.rm = T))

Convert from list to data.frame and add WL names:

df <- data.frame("WL" = gwls, WL.cmip5.mean)
df
A data.frame: 4 Ă— 3
WLNSASES
<dbl><dbl><dbl>
1.51.0805620.8659782
2.01.6731091.3608302
3.02.9623342.3530096
4.04.3077003.3858477

We can use this data frame to illustrate the lattice plotting functionalities.

xyplot(WL~SES + NSA, data = df, 
       xlab = "Regional temperature change (deg. C)", ylab = "GWL",
       type = "b",
       auto.key = TRUE)
../_images/1eccff3dcc70060ff5f2426f25b3a80823632344a1e1177cec127f7ab0555699.png

Session Information#

Hide code cell content
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Fedora Linux 38 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /home/phanaur/mambaforge/envs/tfg/lib/libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_ES.UTF-8        LC_COLLATE=es_ES.UTF-8    
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gridExtra_2.3       latticeExtra_0.6-29 lattice_0.20-44    
[4] httr_1.4.2          magrittr_2.0.1     

loaded via a namespace (and not attached):
 [1] uuid_0.1-4         R6_2.5.0           jpeg_0.1-8.1       rlang_0.4.11      
 [5] fansi_0.4.2        tools_3.6.3        grid_3.6.3         gtable_0.3.0      
 [9] png_0.1-7          utf8_1.2.1         htmltools_0.5.1.1  ellipsis_0.3.2    
[13] digest_0.6.27      lifecycle_1.0.0    crayon_1.4.1       IRdisplay_1.0     
[17] RColorBrewer_1.1-2 repr_1.1.3         base64enc_0.1-3    vctrs_0.3.8       
[21] IRkernel_1.2       evaluate_0.14      pbdZMQ_0.3-5       compiler_3.6.3    
[25] pillar_1.6.1       jsonlite_1.7.2