In [1]:
# NBVAL_IGNORE_OUTPUT
from datetime import datetime
from pymagicc.core import MAGICC6, MAGICC7
In [2]:
%matplotlib inline
from matplotlib import pyplot as plt
plt.style.use('ggplot')
In [3]:
with MAGICC6() as magicc:
# you can tweak whatever parameters you want in
# MAGICC6/run/MAGCFG_DEFAULTALL.CFG, here's a few
# examples that might be of interest
results = magicc.diagnose_tcr_ecs_tcre(
CORE_CLIMATESENSITIVITY=2.75,
CORE_DELQ2XCO2=3.65,
CORE_HEATXCHANGE_LANDOCEAN=1.5,
)
print("TCR is {tcr:.4f}, ECS is {ecs:.4f} and TCRE is {tcre:.6f}".format(**results))
If we wish, we can alter the MAGICC instance's parameters before calling the diagnose_tcr_ecs method.
In [4]:
with MAGICC6() as magicc:
results_default = magicc.diagnose_tcr_ecs_tcre()
results_low_ecs = magicc.diagnose_tcr_ecs_tcre(
CORE_CLIMATESENSITIVITY=1.5
)
results_high_ecs = magicc.diagnose_tcr_ecs_tcre(
CORE_CLIMATESENSITIVITY=4.5
)
print("Default TCR is {tcr:.4f}, ECS is {ecs:.4f} and TCRE is {tcre:.6f}".format(**results_default))
print("Low TCR is {tcr:.4f}, ECS is {ecs:.4f} and TCRE is {tcre:.6f}".format(**results_low_ecs))
print("High TCR is {tcr:.4f}, ECS is {ecs:.4f} and TCRE is {tcre:.6f}".format(**results_high_ecs))
In [5]:
join_year = 1900
pdf = (
results["timeseries"]
.filter(region="World")
.to_iamdataframe()
.swap_time_for_year()
.data
)
for variable, df in pdf.groupby("variable"):
fig, axes = plt.subplots(1, 2, sharey=True, figsize=(16, 4.5))
unit = df["unit"].unique()[0]
for scenario, scdf in df.groupby("scenario"):
scdf.plot(x="year", y="value", ax=axes[0], label=scenario)
scdf.plot(x="year", y="value", ax=axes[1], label=scenario)
axes[0].set_xlim([1750, join_year])
axes[0].set_ylabel("{} ({})".format(variable, unit))
axes[1].set_xlim(left=join_year)
axes[1].legend_.remove()
fig.tight_layout()
In [6]:
# NBVAL_IGNORE_OUTPUT
results["timeseries"].filter(scenario="abrupt-2xCO2", region="World", year=range(1795, 1905)).timeseries()
Out[6]: