Building scenarios

Pymagicc offers the ability to join/merge scenarios to create custom scenarios. Here we show a minimal working example of how to do this.


In [1]:
# NBVAL_IGNORE_OUTPUT
from os.path import join
from datetime import datetime

import pandas as pd

from pymagicc import MAGICC6
from pymagicc.io import MAGICCData
from pymagicc.definitions import (
    convert_magicc7_to_openscm_variables, 
    PART_OF_SCENFILE_WITH_EMISSIONS_CODE_1
)

import expectexception

import matplotlib.pyplot as plt
plt.style.use('bmh') 
%matplotlib inline



In [2]:
DATA_DIR = join("..", "tests", "test_data")
DATA_MAGICC6_RUN = join("..", "pymagicc", "MAGICC6", "run")

We start by reading in our raw data. As the formats we're reading don't have any easily readable metadata, we set it using the columns argument.

Note: The model column refers to the model which generated the scenario (typically an integrated assessment model), with the climate_model column being saved for storing the climate model which was used to do climate projections.


In [3]:
rcp3pd = MAGICCData(
    join(DATA_DIR, "RCP3PD_EMISSIONS.DAT"),
    columns={
        "model": "IMAGE",
        "scenario": "RCP3PD"
    }
)
rcp3pd.head()


Out[3]:
time 1765-01-01 00:00:00 1766-01-01 00:00:00 1767-01-01 00:00:00 1768-01-01 00:00:00 1769-01-01 00:00:00 1770-01-01 00:00:00 1771-01-01 00:00:00 1772-01-01 00:00:00 1773-01-01 00:00:00 1774-01-01 00:00:00 ... 2491-01-01 00:00:00 2492-01-01 00:00:00 2493-01-01 00:00:00 2494-01-01 00:00:00 2495-01-01 00:00:00 2496-01-01 00:00:00 2497-01-01 00:00:00 2498-01-01 00:00:00 2499-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
IMAGE RCP3PD World Emissions|CO2|MAGICC Fossil and Industrial Gt C / yr MAGICC6.3.09, 25 November 2009 SET 0.003 0.003000 0.003000 0.003000 0.003000 0.003000 0.004000 0.004000 0.004000 0.004000 ... -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308
Emissions|CO2|MAGICC AFOLU Gt C / yr MAGICC6.3.09, 25 November 2009 SET 0.000 0.005338 0.010677 0.016015 0.021353 0.026691 0.032030 0.037368 0.042706 0.048045 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|CH4 Mt CH4 / yr MAGICC6.3.09, 25 November 2009 SET 0.000 1.963262 2.436448 2.911105 3.387278 3.865015 4.344362 4.825372 5.308094 5.792582 ... 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527
Emissions|N2O Mt N2ON / yr MAGICC6.3.09, 25 November 2009 SET 0.000 0.005191 0.010117 0.015043 0.019969 0.024896 0.029822 0.034750 0.039677 0.044605 ... 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823
Emissions|SOx Mt S / yr MAGICC6.3.09, 25 November 2009 SET 0.000 0.098883 0.116306 0.133811 0.151398 0.169070 0.186831 0.204683 0.222628 0.240670 ... 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552

5 rows × 736 columns

This data came from MAGICC6.3.09, in order to set it up for a new run, we have to strip out that information.


In [4]:
rcp3pd.set_meta("unspecified", "climate_model")
rcp3pd.head()


Out[4]:
time 1765-01-01 00:00:00 1766-01-01 00:00:00 1767-01-01 00:00:00 1768-01-01 00:00:00 1769-01-01 00:00:00 1770-01-01 00:00:00 1771-01-01 00:00:00 1772-01-01 00:00:00 1773-01-01 00:00:00 1774-01-01 00:00:00 ... 2491-01-01 00:00:00 2492-01-01 00:00:00 2493-01-01 00:00:00 2494-01-01 00:00:00 2495-01-01 00:00:00 2496-01-01 00:00:00 2497-01-01 00:00:00 2498-01-01 00:00:00 2499-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
IMAGE RCP3PD World Emissions|CO2|MAGICC Fossil and Industrial Gt C / yr unspecified SET 0.003 0.003000 0.003000 0.003000 0.003000 0.003000 0.004000 0.004000 0.004000 0.004000 ... -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308 -0.9308
Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.000 0.005338 0.010677 0.016015 0.021353 0.026691 0.032030 0.037368 0.042706 0.048045 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|CH4 Mt CH4 / yr unspecified SET 0.000 1.963262 2.436448 2.911105 3.387278 3.865015 4.344362 4.825372 5.308094 5.792582 ... 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527 142.0527
Emissions|N2O Mt N2ON / yr unspecified SET 0.000 0.005191 0.010117 0.015043 0.019969 0.024896 0.029822 0.034750 0.039677 0.044605 ... 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823 5.2823
Emissions|SOx Mt S / yr unspecified SET 0.000 0.098883 0.116306 0.133811 0.151398 0.169070 0.186831 0.204683 0.222628 0.240670 ... 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552 6.4552

5 rows × 736 columns


In [5]:
rcp85 = MAGICCData(
    join(DATA_MAGICC6_RUN, "RCP85.SCEN"),
    columns={
        "model": "MESSAGE",
        "scenario": "RCP85"
    }
)
rcp85.set_meta("unspecified", "climate_model")
rcp85.head()


Out[5]:
time 2000-01-01 00:00:00 2001-01-01 00:00:00 2002-01-01 00:00:00 2003-01-01 00:00:00 2004-01-01 00:00:00 2005-01-01 00:00:00 2006-01-01 00:00:00 2007-01-01 00:00:00 2010-01-01 00:00:00 2020-01-01 00:00:00 ... 2249-01-01 00:00:00 2250-01-01 00:00:00 2255-01-01 00:00:00 2260-01-01 00:00:00 2275-01-01 00:00:00 2300-01-01 00:00:00 2350-01-01 00:00:00 2400-01-01 00:00:00 2450-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
MESSAGE RCP85 World|Bunkers Emissions|CO2|MAGICC Fossil and Industrial Gt C / yr unspecified SET 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|CH4 Mt CH4 / yr unspecified SET 0.4325 0.4422 0.4520 0.4618 0.4717 0.4817 0.4879 0.4940 0.5123 0.5462 ... 0.6568 0.6569 0.6572 0.6576 0.6588 0.6607 0.6637 0.6662 0.6683 0.6702
Emissions|N2O Mt N2ON / yr unspecified SET 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|SOx Mt S / yr unspecified SET 5.5390 5.5824 5.6207 5.6587 5.6964 5.7337 5.7032 5.6723 5.5780 3.0584 ... 1.9600 1.9600 1.9600 1.9600 1.9600 1.9600 1.9600 1.9600 1.9600 1.9600

5 rows × 31 columns

To join the data, we first have to do a little bit of preparation. Specifically, we must make sure that the metadata for the timeseries we want to prepare is the same which means re-writing the model and scenario columns.


In [6]:
my_scen_hist = rcp3pd.copy()
my_scen_hist.set_meta("idealised", "model")
my_scen_hist.set_meta("custom", "scenario")

my_scen_future = rcp85.copy()
my_scen_future.set_meta("idealised", "model")
my_scen_future.set_meta("custom", "scenario")

my_scen_future.tail()


Out[6]:
time 2000-01-01 00:00:00 2001-01-01 00:00:00 2002-01-01 00:00:00 2003-01-01 00:00:00 2004-01-01 00:00:00 2005-01-01 00:00:00 2006-01-01 00:00:00 2007-01-01 00:00:00 2010-01-01 00:00:00 2020-01-01 00:00:00 ... 2249-01-01 00:00:00 2250-01-01 00:00:00 2255-01-01 00:00:00 2260-01-01 00:00:00 2275-01-01 00:00:00 2300-01-01 00:00:00 2350-01-01 00:00:00 2400-01-01 00:00:00 2450-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
idealised custom World Emissions|HFC134a kt HFC134a / yr unspecified SET 75.0394 84.0409 94.7162 101.4157 113.9297 120.9334 121.0747 129.6222 152.5132 265.0801 ... 720.2033 720.2523 720.5811 720.9509 722.1158 723.8553 726.7471 729.1334 731.1840 731.1840
Emissions|HFC143a kt HFC143a / yr unspecified SET 6.2341 7.4947 8.7389 9.9776 11.2136 12.4483 15.3187 18.1628 26.5373 35.0666 ... 48.7474 48.7507 48.7729 48.7980 48.8768 48.9946 49.1903 49.3518 49.4906 49.4906
Emissions|HFC227ea kt HFC227ea / yr unspecified SET 1.9510 1.6450 2.5080 3.3410 4.2690 4.8900 6.2176 7.5465 11.5413 1.1594 ... 0.1179 0.1179 0.1180 0.1180 0.1182 0.1185 0.1190 0.1194 0.1197 0.1197
Emissions|HFC245fa kt HFC245fa / yr unspecified SET 17.9257 19.7183 21.5109 23.3034 25.0960 26.8886 38.6318 50.3750 85.6048 148.2227 ... 133.8877 133.8968 133.9579 134.0267 134.2432 134.5666 135.1042 135.5478 135.9290 135.9290
Emissions|SF6 kt SF6 / yr unspecified SET 5.5382 5.6990 5.8596 6.0202 6.1806 6.3408 6.4710 6.6012 7.0443 8.0812 ... 0.9043 0.9043 0.9043 0.9043 0.9043 0.9043 0.9043 0.9043 0.9043 0.9043

5 rows × 31 columns

To then join the data, we can simply filter the data and then append one onto the other.


In [7]:
# NBVAL_IGNORE_OUTPUT
my_scen_hist.filter(year=range(1, 2006)).head()


Out[7]:
time 1765-01-01 00:00:00 1766-01-01 00:00:00 1767-01-01 00:00:00 1768-01-01 00:00:00 1769-01-01 00:00:00 1770-01-01 00:00:00 1771-01-01 00:00:00 1772-01-01 00:00:00 1773-01-01 00:00:00 1774-01-01 00:00:00 ... 1996-01-01 00:00:00 1997-01-01 00:00:00 1998-01-01 00:00:00 1999-01-01 00:00:00 2000-01-01 00:00:00 2001-01-01 00:00:00 2002-01-01 00:00:00 2003-01-01 00:00:00 2004-01-01 00:00:00 2005-01-01 00:00:00
model scenario region variable unit climate_model todo
idealised custom World Emissions|CO2|MAGICC Fossil and Industrial Gt C / yr unspecified SET 0.003 0.003000 0.003000 0.003000 0.003000 0.003000 0.004000 0.004000 0.004000 0.004000 ... 6.510000 6.619000 6.588000 6.569000 6.7350 6.8959 6.9490 7.2860 7.6719 7.9710
Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.000 0.005338 0.010677 0.016015 0.021353 0.026691 0.032030 0.037368 0.042706 0.048045 ... 1.251103 1.218140 1.214843 1.182789 1.1488 1.1320 1.2317 1.2257 1.2429 1.1955
Emissions|CH4 Mt CH4 / yr unspecified SET 0.000 1.963262 2.436448 2.911105 3.387278 3.865015 4.344362 4.825372 5.308094 5.792582 ... 316.378140 312.335330 308.292520 304.249710 300.2069 303.4092 306.5788 309.7164 312.8240 315.9027
Emissions|N2O Mt N2ON / yr unspecified SET 0.000 0.005191 0.010117 0.015043 0.019969 0.024896 0.029822 0.034750 0.039677 0.044605 ... 7.652064 7.909753 7.895726 7.526985 7.4566 7.5030 7.5487 7.5942 7.6394 7.6841
Emissions|SOx Mt S / yr unspecified SET 0.000 0.098883 0.116306 0.133811 0.151398 0.169070 0.186831 0.204683 0.222628 0.240670 ... 57.891852 56.879189 55.866526 54.853863 53.8412 54.4191 54.9961 55.5716 56.1461 56.7195

5 rows × 241 columns


In [8]:
# NBVAL_IGNORE_OUTPUT
rcp3pd_up_to_2005 = my_scen_hist.filter(year=range(1, 2006))
rcp85_2006_onwards = my_scen_future.filter(year=range(2006, 30000))
# TODO: fix openscm method so it checks for duplicate time points, not duplicate index...
my_scen = rcp3pd_up_to_2005.append(rcp85_2006_onwards, duplicate_msg="warn")
my_scen["time"].head()


Out[8]:
0    1765-01-01 00:00:00
1    1766-01-01 00:00:00
2    1767-01-01 00:00:00
3    1768-01-01 00:00:00
4    1769-01-01 00:00:00
Name: time, dtype: object

In [9]:
# NBVAL_IGNORE_OUTPUT
my_scen["time"].tail()


Out[9]:
261    2300-01-01 00:00:00
262    2350-01-01 00:00:00
263    2400-01-01 00:00:00
264    2450-01-01 00:00:00
265    2500-01-01 00:00:00
Name: time, dtype: object

Note that appending in this way keeps all of the available data. This means that we still have regional data over the future.


In [10]:
# NBVAL_IGNORE_OUTPUT
my_scen.filter(region="World", keep=False).head()


Out[10]:
time 2006-01-01 00:00:00 2007-01-01 00:00:00 2010-01-01 00:00:00 2020-01-01 00:00:00 2030-01-01 00:00:00 2040-01-01 00:00:00 2050-01-01 00:00:00 2060-01-01 00:00:00 2070-01-01 00:00:00 2080-01-01 00:00:00 ... 2249-01-01 00:00:00 2250-01-01 00:00:00 2255-01-01 00:00:00 2260-01-01 00:00:00 2275-01-01 00:00:00 2300-01-01 00:00:00 2350-01-01 00:00:00 2400-01-01 00:00:00 2450-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
idealised custom World|Bunkers Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.0000 0.0000 0.0000 0.0000 0.000 0.000 0.000 0.000 0.000 0.000 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
World|R5ASIA Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.4317 0.4182 0.3776 0.2973 0.191 0.168 0.141 0.117 0.088 0.059 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
World|R5LAM Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.3360 0.3315 0.3177 0.3379 0.328 0.283 0.245 0.203 0.152 0.092 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
World|R5MAF Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.2230 0.2188 0.2060 0.1955 0.186 0.177 0.163 0.148 0.133 0.114 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
World|R5OECD Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.1197 0.1136 0.0951 0.0436 -0.012 -0.016 -0.016 -0.020 -0.023 -0.025 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

5 rows × 25 columns

We can remove this by simply filtering our scenario once again.


In [11]:
# NBVAL_IGNORE_OUTPUT
my_scen_world = my_scen.filter(region="World")
my_scen_world.head()


Out[11]:
time 1765-01-01 00:00:00 1766-01-01 00:00:00 1767-01-01 00:00:00 1768-01-01 00:00:00 1769-01-01 00:00:00 1770-01-01 00:00:00 1771-01-01 00:00:00 1772-01-01 00:00:00 1773-01-01 00:00:00 1774-01-01 00:00:00 ... 2249-01-01 00:00:00 2250-01-01 00:00:00 2255-01-01 00:00:00 2260-01-01 00:00:00 2275-01-01 00:00:00 2300-01-01 00:00:00 2350-01-01 00:00:00 2400-01-01 00:00:00 2450-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
idealised custom World Emissions|CO2|MAGICC AFOLU Gt C / yr unspecified SET 0.000 0.005338 0.010677 0.016015 0.021353 0.026691 0.032030 0.037368 0.042706 0.048045 ... 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Emissions|CO2|MAGICC Fossil and Industrial Gt C / yr unspecified SET 0.003 0.003000 0.003000 0.003000 0.003000 0.003000 0.004000 0.004000 0.004000 0.004000 ... 2.0880 2.0459 2.0670 2.1246 2.0815 1.9941 1.8886 1.7632 1.6171 1.4845
Emissions|BC Mt BC / yr unspecified SET 0.000 0.106998 0.133383 0.159847 0.186393 0.213024 0.239742 0.266550 0.293450 0.320446 ... 4.2497 4.2497 4.2497 4.2497 4.2497 4.2497 4.2497 4.2497 4.2497 4.2497
Emissions|CH4 Mt CH4 / yr unspecified SET 0.000 1.963262 2.436448 2.911105 3.387278 3.865015 4.344362 4.825372 5.308094 5.792582 ... 904.7895 904.8603 905.3349 905.8686 907.5502 910.0611 914.2354 917.6800 920.6400 923.1946
Emissions|CO Mt CO / yr unspecified SET 0.000 9.050221 12.960844 16.876539 20.797465 24.723782 28.655658 32.593264 36.536778 40.486382 ... 690.2832 690.2832 690.2832 690.2832 690.2832 690.2832 690.2832 690.2832 690.2832 690.2832

5 rows × 266 columns

We can check the results as shown.


In [12]:
var_to_plot = "Emissions|CO2|MAGICC Fossil and Industrial"

ax = rcp3pd.filter(
    variable=var_to_plot,
    region="World"
).line_plot(x="time", label="RCP3PD", lw=6.0, figsize=(16, 9))
rcp85.filter(
    variable=var_to_plot,
    region="World"
).line_plot(x="time", label="RCP85", lw=6.0, ax=ax)
my_scen_world.filter(
    variable=var_to_plot
).line_plot(x="time", label="my_scen", lw=6.0, linestyle=":", ax=ax)
ax.set_xlim([datetime(2000, 1, 1), datetime(2011, 1, 1)])
ax.set_ylim([6.5, 9]);


If we put our scenario into a MAGICCData object, we can run it using Pymagicc.

Note that Pymagicc automatically only uses the variables which are in SCEN files.


In [13]:
with MAGICC6() as magicc:
    results = magicc.run(my_scen_world)


/home/jupyter-znicholls/pymagicc/pymagicc/io.py:1823: UserWarning: Ignoring input data which is not required for .SCEN file
  warnings.warn("Ignoring input data which is not required for .SCEN file")

In [14]:
results.filter(
    variable="Surface Temperature",
    region="World"
).line_plot(x="time", figsize=(16, 9));


If we wish, we can also MAGICCData's resample method to join our timeseries together with a linear interpolation over a given period. This allows us to use some base scenario, overwrite with a multitude of other scenarios but ensure they all have a common historical period and some roughly smooth transition. (At the moment the resample and interpolate methods are the only options, a far more complete solution would be to use the Aneris package but this would also be far more difficult.)


In [15]:
rcp3pd_up_to_2005 = my_scen_hist.filter(year=range(1, 2006))
rcp85_2015_onwards = my_scen_future.filter(year=range(2015, 30000))
# TODO: fix openscm method so it checks for duplicate time points, not duplicate index...
# TODO: work out why resample and interpolate are so slow...
target_times = [datetime(y, 1, 1) for y in range(2000, 2501)]
linear_scen = rcp3pd_up_to_2005.append(
    rcp85_2015_onwards, duplicate_msg="warn"
).filter(region="World")#.interpolate(target_times)

In [16]:
var_to_plot = "Emissions|CO2|MAGICC Fossil and Industrial"

ax = rcp3pd.filter(
    variable=var_to_plot,
    region="World"
).line_plot(x="time", label="RCP3PD", lw=6.0, figsize=(16, 9))
rcp85.filter(
    variable=var_to_plot,
    region="World"
).line_plot(x="time", label="RCP85", lw=6.0, ax=ax)
linear_scen.filter(
    variable=var_to_plot
).line_plot(x="time", label="my_scen", lw=6.0, linestyle=":", ax=ax)
ax.set_xlim([datetime(2000, 1, 1), datetime(2031, 1, 1)])
ax.set_ylim([6.5, 15]);



In [17]:
with MAGICC6() as magicc:
    results = magicc.run(linear_scen)


/home/jupyter-znicholls/pymagicc/pymagicc/io.py:1823: UserWarning: Ignoring input data which is not required for .SCEN file
  warnings.warn("Ignoring input data which is not required for .SCEN file")

In [18]:
results.filter(
    variable="Surface Temperature",
    region="World"
).line_plot(x="time", figsize=(16, 9));


Warning

If you try to merge data which has no overlapping indices, you'll end up with np.nan in your output. For example, if we set our "todo" column to "N/A" in base (for an explanation of what this "todo" column is, see file conventions).

As a user, you have to check carefully that the merging has actually happened as intended (pull requests with convenience functions that can help automate these checks are most welcome!!). One easy way to do this is to simply see if any of the data in the output is null.


In [19]:
rcp85_2015_onwards_world = my_scen_future.filter(
    year=range(2015, 30000), 
    region="World",
)
rcp3pd_up_to_2005_world = my_scen_hist.filter(
    year=range(1, 2006), 
    region="World",
)

null_output = rcp3pd_up_to_2005_world.append(rcp85_2015_onwards_world, duplicate_msg="warn").timeseries()
null_output.isnull().any().any()


Out[19]:
True

There are still null values, we can see where they are with something like this.


In [20]:
null_output[null_output.isnull().any(axis=1)]


Out[20]:
time 1765-01-01 00:00:00 1766-01-01 00:00:00 1767-01-01 00:00:00 1768-01-01 00:00:00 1769-01-01 00:00:00 1770-01-01 00:00:00 1771-01-01 00:00:00 1772-01-01 00:00:00 1773-01-01 00:00:00 1774-01-01 00:00:00 ... 2249-01-01 00:00:00 2250-01-01 00:00:00 2255-01-01 00:00:00 2260-01-01 00:00:00 2275-01-01 00:00:00 2300-01-01 00:00:00 2350-01-01 00:00:00 2400-01-01 00:00:00 2450-01-01 00:00:00 2500-01-01 00:00:00
model scenario region variable unit climate_model todo
idealised custom World Emissions|CCl4 kt CCl4 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CFC11 kt CFC11 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CFC113 kt CFC113 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CFC114 kt CFC114 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CFC115 kt CFC115 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CFC12 kt CFC12 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CH3Br kt CH3Br / yr unspecified SET 157.267 157.267 157.267 157.267 157.267 157.267 157.267 157.267 157.267 157.267 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CH3CCl3 kt CH3CCl3 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|CH3Cl kt CH3Cl / yr unspecified SET 3100.211 3100.211 3100.211 3100.211 3100.211 3100.211 3100.211 3100.211 3100.211 3100.211 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|HCFC141b kt HCFC141b / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|HCFC142b kt HCFC142b / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|HCFC22 kt HCFC22 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|Halon1202 kt Halon1202 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|Halon1211 kt Halon1211 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|Halon1301 kt Halon1301 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Emissions|Halon2402 kt Halon2402 / yr unspecified SET 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

16 rows × 263 columns

This makes it clear that all of the non-SCEN gases have np.nan values into the future, which makes sense as the SCEN file does not define them.

If we drop these variables first, i.e. do the merge carefully, none of the null values appear.


In [21]:
rcp85_2015_onwards_world = my_scen_future.filter(year=range(2015, 30000), region="World")
rcp3pd_up_to_2005_world_careful = my_scen_hist.filter(
    year=range(1, 2006), 
    region="World",
    variable=rcp85_2015_onwards_world["variable"],
)

no_nulls = rcp3pd_up_to_2005_world_careful.append(rcp85_2015_onwards_world, duplicate_msg="warn")
no_nulls.timeseries().isnull().any().any()


Out[21]:
False

As a side effect, running MAGICC with this scenario does not produce any warning about ignoring data.


In [22]:
with MAGICC6() as magicc:
    results = magicc.run(linear_scen)