Generate Your Future Forcing#
Let us do some research now, with help of the CMIP6 dataset. We will look how our model fares with historical CMIP data and their climate models that predict future scenarios. I have setup some possible climate change models for you to use, you have to fill in your camel ID and think of a research question!
We like the sentence:
To understand [environment issue] in [region] we will study te impact of [verb/noun] on [hydrological variable].
But feel free to come up with your own! Some hints:
Maybe look at a smaller time period.
What do certain climate changes do to your region.
In This Notebook: Generate CMIP Forcing#
We will generate the forcing in this notebook, this is done because this usually takes a bit longer and you only want to do this once. RUN THIS NOTEBOOK ONCE
Importing and setting up#
# Ignore user warnings :)
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
# Required dependencies
from pathlib import Path
from cartopy.io import shapereader
import pandas as pd
import numpy as np
from rich import print
import xarray as xr
import shutil
import json
import ewatercycle
import ewatercycle.forcing
You can change the folder structure as well, but note that you will have to change that in upcoming notebooks as well!
# Load settings
# Read from the JSON file
with open("settings.json", "r") as json_file:
settings = json.load(json_file)
camel_id = settings["caravan_id"]
# Defining path for catchment shape file
central_path = "/data/shared/climate-data/camels_africa/ghana/camel_data"
path_to_save = Path.home() / "my_data/workshop_ghana"
path_to_save.mkdir(exist_ok=True, parents=True)
shape_file = central_path + "/shapefiles" + f"/{str(camel_id[:-2])}" + f"/{str(camel_id[:-2])}.shp"
data_file_nc = central_path + (f"/{camel_id}.nc")
my_data_nc = xr.open_dataset(data_file_nc, engine="netcdf4")
# Defining destination path for CMIP data
forcing_path_CMIP = path_to_save / "CMIP_forcing"
forcing_path_CMIP.mkdir(exist_ok=True)
Gathering CMIP data#
historical_start = "1975-01-01"
historical_end = "1979-12-31"
future_start_data = "2026-01-01"
future_end_data = "2099-12-31"
# Let us also look at the historical data of CMIP
cmip_historical = {
'project': 'CMIP6',
'exp': 'historical',
'dataset': 'MPI-ESM1-2-HR',
"ensemble": 'r1i1p1f1',
'grid': 'gn'
}
CMIP_forcing = ewatercycle.forcing.sources["LumpedMakkinkForcing"].generate(
dataset=cmip_historical,
start_time=historical_start+"T00:00:00Z",
end_time=historical_end+"T00:00:00Z",
shape=shape_file,
directory=forcing_path_CMIP / "historical",
)
Downloading the climate scenarios#
CMIP datasets can be found here, sometimes their servers are unreachable. CMIP has these climate scenarios based on carbon emmisions, go here (or here) to find out more! Here I setup SSP1, 2 and 5:
SSP1: The sustainable and “green” pathway describes an increasingly sustainable world. Global commons are being preserved, the limits of nature are being respected. The focus is more on human well-being than on economic growth. Income inequalities between states and within states are being reduced. Consumption is oriented towards minimizing material resource and energy usage.
SSP2: The “Middle of the road” or medium pathway extrapolates the past and current global development into the future. Income trends in different countries are diverging significantly. There is a certain cooperation between states, but it is barely expanded. Global population growth is moderate, leveling off in the second half of the century. Environmental systems are facing a certain degradation.
SSP3: Regional rivalry. A revival of nationalism and regional conflicts pushes global issues into the background. Policies increasingly focus on questions of national and regional security. Investments in education and technological development are decreasing. Inequality is rising. Some regions suffer drastic environmental damage.
SSP4: Inequality. The chasm between globally cooperating developed societies and those stalling at a lower developmental stage with low income and a low level of education is widening. Environmental policies are successful in tackling local problems in some regions, but not in others.
SSP5: Fossil-fueled Development. Global markets are increasingly integrated, leading to innovations and technological progress. The social and economic development, however, is based on an intensified exploitation of fossil fuel resources with a high percentage of coal and an energy-intensive lifestyle worldwide. The world economy is growing and local environmental problems such as air pollution are being tackled successfully.
The numbers behind the SSP1xx mean extra radiative forcing of \(x.x\) \(W/m^2\) by the year 2100. They come in at \(1.9\), \(2.6\), \(3.4\), \(4.5\), \(6.0\), \(7.0\) and \(8.5\) \(W/m^2\), more info.
It is also possible to pick just one scenario and use different ensembles to reach a statistically better result!
Since we are saving it to their respective folder (so if you change them, keep track of the folders) we only have to run the data gathering ONCE.
# We will need to generate CMIP data and save it, to use it later.
# ONLY RUN THIS ONCE
# DO this for every experiment you want to do!
# Generate SSP126 data and save it in the correct directory
cmip_dataset = {
'project': 'CMIP6',
'activity': 'ScenarioMIP',
'exp': 'ssp126',
'mip': 'day',
'dataset': 'MPI-ESM1-2-HR',
'ensemble': 'r1i1p1f1',
'institute': 'DKRZ',
'grid': 'gn'
}
CMIP_forcing = ewatercycle.forcing.sources["LumpedMakkinkForcing"].generate(
dataset=cmip_dataset,
start_time=future_start_data+"T00:00:00Z",
end_time=future_end_data+"T00:00:00Z",
shape=shape_file,
directory=forcing_path_CMIP / "SSP126",
)
# Generate SSP245 data and save it in the correct directory
cmip_dataset = {
'project': 'CMIP6',
'activity': 'ScenarioMIP',
'exp': 'ssp245',
'mip': 'day',
'dataset': 'MPI-ESM1-2-HR',
'ensemble': 'r1i1p1f1',
'institute': 'DKRZ',
'grid': 'gn'
}
CMIP_forcing = ewatercycle.forcing.sources["LumpedMakkinkForcing"].generate(
dataset=cmip_dataset,
start_time=future_start_data+"T00:00:00Z",
end_time=future_end_data+"T00:00:00Z",
shape=shape_file,
directory=forcing_path_CMIP / "SSP245",
)
# Generate SSP585 data and save it in the correct directory
cmip_dataset = {
'project': 'CMIP6',
'activity': 'ScenarioMIP',
'exp': 'ssp585',
'mip': 'day',
'dataset': 'MPI-ESM1-2-HR',
'ensemble': 'r1i1p1f1',
'institute': 'DKRZ',
'grid': 'gn'
}
CMIP_forcing = ewatercycle.forcing.sources["LumpedMakkinkForcing"].generate(
dataset=cmip_dataset,
start_time=future_start_data+"T00:00:00Z",
end_time=future_end_data+"T00:00:00Z",
shape=shape_file,
directory=forcing_path_CMIP / "SSP585",
)