Usage

import matplotlib.pyplot as plt

import pymagicc
import scmdata
from pymagicc import rcps

results = []
for scen in rcps.groupby("scenario"):
    results_scen = pymagicc.run(scen)
    results.append(results_scen)

results = scmdata.run_append(results)

temperature_rel_to_1850_1900 = (
    results
    .filter(variable="Surface Temperature", region="World")
    .relative_to_ref_period_mean(year=range(1850, 1900 + 1))
)

temperature_rel_to_1850_1900.lineplot()
plt.title("Global Mean Temperature Projection")
plt.ylabel("°C over pre-industrial (1850-1900 mean)");
# Run `plt.show()` to display the plot when running this example
# interactively or add `%matplotlib inline` on top when in a Jupyter Notebook.
_images/example-plot.png

For more example usage see this Jupyter Notebook. Thanks to the Binder project the Notebook can be run and modified without installing anything locally.

Use an included scenario

from pymagicc.scenarios import rcp26

rcp26.head()

Read a MAGICC scenario file

from pymagicc.scenarios import read_scen_file

scenario = read_scen_file("PATHWAY.SCEN")

Run MAGICC for a scenario

import pymagicc
from pymagicc.scenarios import read_scen_file

scenario = read_scen_file("PATHWAY.SCEN")

results = pymagicc.run(scenario)

temperature_rel_to_1850_1900 = (
    results
    .filter(variable="Surface Temperature")
    .relative_to_ref_period_mean(year=range(1850, 1900 + 1))
)

Using a different MAGICC version

A custom version of MAGICC may be used with pymagicc using the MAGICC_EXECUTABLE_6 and MAGICC_EXECUTABLE_7 environment variables for MAGICC6 and MAGICC7 respectively. These environment variables should be set to the location of the magicc executable (either magicc for linux/mac or magicc.exe for Windows). For example, a custom MAGICC7 folder located at /tmp/magicc can be used on under Linux by setting MAGICC_EXECUTABLE_7 to /tmp/magicc/run/magicc.

Example usage in Bash:

MAGICC_EXECUTABLE_7=/tmp/magicc/run/magicc.exe make test

Or in a script:

#!/bin/bash
export MAGICC_EXECUTABLE_7=tmp/magicc/run/magicc.exe
make test