Skip to content

Commit

Permalink
Merge branch 'rgieseke-float-division'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroadmap committed Jan 21, 2018
2 parents fd5ad6d + 0d6104c commit bf77a3b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fair/forcing/aerosols.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import numpy as np
from ..constants import molwt

Expand Down
2 changes: 2 additions & 0 deletions fair/forcing/bc_snow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

def linear(emissions, E_ref=8.09, F_ref=0.04):
E_BC = emissions[:,9]
return E_BC * F_ref/E_ref
2 changes: 2 additions & 0 deletions fair/forcing/contrails.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import numpy as np
from ..constants import molwt

Expand Down
2 changes: 2 additions & 0 deletions fair/forcing/ghg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import numpy as np

def etminan(C, Cpi, F2x=3.74):
Expand Down
2 changes: 2 additions & 0 deletions fair/forcing/h2o_st.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import numpy as np

def linear(F_CH4, ratio=0.15):
Expand Down
2 changes: 2 additions & 0 deletions fair/forcing/ozone_st.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import numpy as np
from ..constants import cl_atoms, br_atoms, fracrel

Expand Down
2 changes: 2 additions & 0 deletions fair/forward.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import inspect
import numpy as np
from scipy.optimize import root
Expand Down
22 changes: 20 additions & 2 deletions tests/test_fair.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def test_ten_GtC_pulse():
other_rf = np.zeros(emissions.size)
for x in range(0,emissions.size):
other_rf[x] = 0.5*np.sin(2*np.pi*(x)/14.0)

C,F,T = fair.forward.fair_scm(emissions=emissions, other_rf=other_rf)

datadir = os.path.join(os.path.dirname(__file__), 'ten_GtC_pulse/')
C_expected = np.load(datadir + 'C.npy')
F_expected = np.load(datadir + 'F.npy')
Expand Down Expand Up @@ -104,3 +104,21 @@ def test_rcp85():
assert np.allclose(C, C_expected)
assert np.allclose(F, F_expected)
assert np.allclose(T, T_expected)


def test_division():
# Ensure parameters given as integers are treated as floats when dividing
# (Python2 compatibility).
_, _, T = fair.forward.fair_scm(
emissions=fair.RCPs.rcp6.Emissions.emissions,
useMultigas=True,
d=np.array([239.0, 4.0]),
tcr_dbl=70.0
)
_, _, T_int_params = fair.forward.fair_scm(
emissions=fair.RCPs.rcp6.Emissions.emissions,
useMultigas=True,
d=np.array([239, 4]),
tcr_dbl=70
)
assert (T == T_int_params).all()

0 comments on commit bf77a3b

Please sign in to comment.