In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = 16, 9
In [3]:
import pyhector
from pyhector import rcp26, rcp45, rcp60, rcp85
In [4]:
pyhector.__version__
Out[4]:
In [5]:
rcp26.columns
Out[5]:
In [6]:
rcp26.head()
Out[6]:
The units can also be looked up.
In [7]:
pyhector.units
Out[7]:
A plot of four categories in RCP 2.6.
In [8]:
emissions = ["ffi_emissions", "luc_emissions", "CH4_emissions", "N2O_emissions"]
rcp26[emissions].loc[:2150].plot(subplots=True);
plt.suptitle("RCP 2.6");
In [9]:
%time results = pyhector.run(rcp26)
By default pyhector
uses the default parameters from the INI files for the RCP runs in the Hector repository.
In [10]:
pyhector._default_config
Out[10]:
In [11]:
rcps = [rcp26, rcp45, rcp60, rcp85]
# For Hector output variables we need to address them as
# 'component.variable', to simplify this we define short cuts
SURFACE_TEMP = "temperature.Tgav"
CONCENTRATION_CO2 = "simpleNbox.Ca"
FORCING = "forcing.Ftot"
Let's plot the default output variables for the four RCPs:
In [12]:
temp = results[SURFACE_TEMP].loc[1850:2100] - results[SURFACE_TEMP].loc[1850:1900].mean()
temp.plot()
plt.title("RCP2.6: Global Mean Temperature Projection")
plt.ylabel("Deg. C over pre-industrial (1850-1900 mean)");
In [13]:
results[FORCING].loc[1850:2100].plot()
plt.title("RCP2.6: " + pyhector.output[FORCING]["description"])
plt.ylabel(pyhector.output[FORCING]["unit"]);
In [14]:
results[CONCENTRATION_CO2].loc[1850:2100].plot()
plt.title("RCP2.6: " + pyhector.output[CONCENTRATION_CO2]["description"])
plt.ylabel(pyhector.output[CONCENTRATION_CO2]["unit"]);
A comparison of global mean temperature for the four RCPs.
In [15]:
for rcp in rcps:
output = pyhector.run(rcp, {"core": {"endDate": 2100}})
temp = output[SURFACE_TEMP]
temp = temp.loc[1850:] - temp.loc[1850:1900].mean()
temp.plot(label=rcp.name.split("_")[0])
plt.title("Global mean temperature")
plt.ylabel("Deg. C over pre-industrial (1850-1900 mean)")
plt.legend(loc="best");
Let's change an input parameter and, as an example, change the equilibrium climate sensitivity.
In [16]:
low = pyhector.run(rcp45, {"temperature": {"S": 1.5}})
default = pyhector.run(rcp45, {"temperature": {"S": 3}})
high = pyhector.run(rcp45, {"temperature": {"S": 4.5}})
In [17]:
sel = slice(1850, 2100)
plt.fill_between(low[SURFACE_TEMP].loc[sel].index,
low[SURFACE_TEMP].loc[sel],
high[SURFACE_TEMP].loc[sel],
color="lightgray")
default[SURFACE_TEMP].loc[sel].plot()
plt.title("RCP 4.5 with equilibrium climate sensitivity set to 1.5, 3, and 4.5")
plt.ylabel("Deg. C");
In [ ]: