This script is a component of the parent project: IPCCAtlas2R.
This script downloads Copernicus’s gridded monthly climate projection dataset, the data underpinning the IPCC AR6 Interactive Atlas.
The commented code under the heading `SETUP` must be run once to ensure that you can pull the data. Follow the steps to create an account at Copernicus’ Climate Data Store (CDS), then paste your personal access token into the key variable and save it. The CDS credentials will be cached, and so this code should be commented out again after you have run it for the first time.
-
Set the RAST_FN variable to the desired name of the raster file. This will be placed in the DATA_DIR folder. It is recommended that the file name format is as follows: YOUR_ECOREGION_VARIABLE.rds.
``` R
BOUNDING_BOX <- list(
xmin = -18, # these are in decimal degrees
xmax = 3,
ymin = 34,
ymax = 50)
```
It is recommended to make this larger than the ecoregion itself to ensure correct plotting because the SST_investigations.R and pH_investigations.R plotting scripts overlay the shapefile of the ecoregion. The time series will be calculated from the ecoregion shapefile, and a larger bounding box ensures the whole ecoregion will be included in the maps and plots.
When downloading one scenario from CDS, you will have to change the variable in the request to the one you want downloaded.
``` R
req <- list(
dataset_short_name = CDS_DATASET,
origin = "cmip6",
experiment = scenario,
domain = "global",
variable = "monthly_mean_of_sea_surface_temperature", # SET THIS
#variable = 'monthly_mean_of_acidity_of_seawater', # ANOTHER COMMON SCENARIO
period = period,
target = basename(zip_dest)
)
```
The exact names of the variables can be found on the Copernicus site when you manually submit a request. After choosing a variable at the bottom, it will show the API request code, which contains the correct naming of the variable. At this time, the script is set for sea surface temperature, with pH commented out. Only run one variable at a time. If you do switch it to pH, you will have to change all instances of “sst” in the script and replace them with “ph”, or the variable you are downloading. I recommend using Command-F and then Replace All in RStudio.
After configuring, run the script by hitting Source at the top right of the source panel in RStudio. The data will be downloaded into the DATA_DIR folder as well as available in your environment with the name (variable name)_data. You can plot using (variable name)_data; however, the plotting scripts are set up to use the data in DATA_DIR, so you do not have to re-download every time. The initial download time will likely take over 20 minutes.
These scripts create a standard set of ecoregion-level figures that include time series, maps, and warming summary plots for the sea surface temperature or pH data downloaded by the prepare_data_exp.R script. This is done across all four SSP scenarios and during the time frame of 2015-2100. The baseline for these plots is 2015-2025, against which future projections are then compared. The SST_full_figures.R and pH_full_figures.R scripts contain the same workflow, only for the different variables. For this script to work well, you need to run prepare_data_exp.R first.
Copernicus gridded monthly climate projection dataset underpinning the IPCC AR6 Interactive Atlas that has been downloaded onto your computer by the script prepare_data_exp.R. The shapefile of the ecoregions is available on the ICES website (https://gis.ices.dk/shapefiles/ICES_ecoregions.zip), which is further described by the metadata (https://gis.ices.dk/geonetwork/srv/eng/catalog.search\#/metadata/4745e824-a612-4a1f-bc56-b540772166eb)
Change variable plot_dir to the name of the folder where you want the figures to be saved. Fill in the file path or the raster file names of the rasters that were stored in the folder made by DATA_DIR in prepare_data_exp.R. Write the file path or folder name for reading in the CMIP6 NetCDFs for the variable nc_dir; this will be used later to create point-range summary tables. This should be the same folder that the rasters that will be used for the time series and maps are stored in (DATA_DIR in prepare_data_exp.R).
Change the ecoregion saved from the shapefile to the one being plotted. This has to be done twice, once when loading in the shapefile and then when clipping the time series (this is in the “Ecoregion time series clipped” section of the script). The ecoregion names are as follows:
- Adriatic Sea
- Aegean-Levantine Sea
- Arctic Ocean
- Azores
- Baltic Sea
- Barents Sea
- Bay of Biscay and the Iberian Coast
- Black Sea
- Celtic Seas
- Faroes
- Greater North Sea
- Greenland Sea
- Icelandic Waters
- Ionian Sea and the Central Mediterranean Sea
- Norwegian Sea
- Oceanic Northeast Atlantic
- Western Mediterranean Sea
You will have to change the titles and the name of the image saved of the time series, maps, and warming summary to your desired naming structure. This can be done in RStudio by using Command-F or Control-F and searching YOUR ECOREGION NAME or YOUR_ECOREGION to find the instances where the figures need to be renamed.
In the end, there will be six time series, two maps, and a point range summary plot created in the folder you specified by the plot_dir variable when running either the SST or pH script.