OMS-NetZero / FAIR

Finite-amplitude Impulse Response simple climate model
https://docs.fairmodel.net
Apache License 2.0
123 stars 62 forks source link

allow concentration-driven runs #39

Closed chrisroadmap closed 6 years ago

chrisroadmap commented 6 years ago

Does what it says on the tin. Calling fair_scm with the C keyword set to an array of GHG concentrations (size (nt, 31)) and emissions_driven=False will run FaIR in concentrations driven mode. The examples have been updated to include examples of CO2-only and multigas concentration runs.

There are too many if/else statements in here and it would be useful to separate the CO2, multigas and concentration driven cases into separate functions, but I haven't figured out how this will look yet.

Also, some refactoring has been performed, so emissions to concentrations and forcing to temperature calculations are now in functions. This means it is actually possible to run FaIR in forcing driven mode too by bypassing the fair_scm interface. For example, to run forcing-only for Meinshausen's RCP4.5:

from fair.forward import forc_to_temp
from fair.RCPs import rcp45
import numpy as np
q = np.array([0.33,0.41])
d = np.array([239,4.1])
f = rcp45.Forcing.total
t = np.zeros((736,2))
for i in range(1,736):
    # slow and fast components are calculated here
    t[i,:] = forc_to_temp(t[i-1,:], q, d, f[i])
T = np.sum(t, axis=1)

A couple of extra bugs zapped: one in the historical scaling factors time series, and a consistency update for RCP namings in the MAGICC scenario file reader.