Skip to content

Commit

Permalink
Restored the convenience methods to compute heat transport as a diagn…
Browse files Browse the repository at this point in the history
…ostic in EBMs. Updated version number to 0.2.8
  • Loading branch information
brian-rose committed Apr 20, 2015
1 parent 12857ec commit cc0bb27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion climlab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.2.7'
__version__ = '0.2.8'

# This list defines all the modules that will be loaded if a user invokes
# from climLab import *
Expand Down
58 changes: 33 additions & 25 deletions climlab/model/ebm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,40 +69,47 @@ def _compute_heating_rates(self):
ASR = (1-albedo) * insolation
self.heating_rate['Ts'] = ASR
self.diagnostics['ASR'] = ASR
self.diagnostics['net_radiation'] = (ASR -
self.diagnostics['net_radiation'] = (ASR -
self.subprocess['LW'].diagnostics['OLR'])

def global_mean_temperature(self):
'''Convenience method to compute the global mean surface temperature.'''
'''Convenience method to compute global mean surface temperature.'''
return global_mean(self.state['Ts'])

def inferred_heat_transport( self ):
'''Returns the inferred heat transport (in PW) by integrating the TOA energy imbalance from pole to pole.'''
def inferred_heat_transport(self):
'''Returns the inferred heat transport (in PW)
by integrating the TOA energy imbalance from pole to pole.'''
phi = np.deg2rad(self.lat)
energy_in = np.squeeze(self.diagnostics['net_radiation'])
return ( 1E-15*2* np.math.pi*const.a**2 *
integrate.cumtrapz(np.cos(phi)*energy_in,
x=phi, initial=0. ) )
return (1E-15 * 2 * np.math.pi * const.a**2 *
integrate.cumtrapz(np.cos(phi)*energy_in, x=phi, initial=0.))

# def heat_transport(self):
# '''Returns instantaneous heat transport in units on PW,
# on the staggered grid.'''
# return self.diffusive_heat_transport()
#
# def diffusive_heat_transport( self ):
# '''Compute instantaneous diffusive heat transport in units of PW, on the staggered grid.'''
# #return ( 1E-15 * -2 * np.math.pi * np.cos(self.phi_stag) * const.cp * const.ps * const.mb_to_Pa / const.g * self.K *
# # np.append( np.append( 0., np.diff( self.T ) ), 0.) / self.dphi )
# return ( 1E-15 * -2 * np.math.pi * np.cos(self.phi_stag) * const.a**2 * self.K *
# np.append( np.append( 0., np.diff( self.T ) ), 0.) / self.dphi )
#
# def heat_transport_convergence( self ):
# '''Returns instantaneous convergence of heat transport in units of W / m^2.'''
# return ( -1./(2*np.math.pi*const.a**2*np.cos(self.phi)) * np.diff( 1.E15*self.heat_transport() )
# / np.diff(self.phi_stag) )
#
def heat_transport(self):
'''Returns instantaneous heat transport in units on PW,
on the staggered grid.'''
return self.diffusive_heat_transport()

def diffusive_heat_transport(self):
'''Compute instantaneous diffusive heat transport in units of PW
on the staggered grid.'''
phi = np.deg2rad(self.lat)
phi_stag = np.deg2rad(self.lat_bounds)
D = self.param['D']
T = np.squeeze(self.Ts)
dTdphi = np.diff(T) / np.diff(phi)
dTdphi = np.append(dTdphi, 0.)
dTdphi = np.insert(dTdphi, 0, 0.)
return (1E-15*-2*np.math.pi*np.cos(phi_stag)*const.a**2*D*dTdphi)

def heat_transport_convergence(self):
'''Returns instantaneous convergence of heat transport
in units of W / m^2.'''
phi = np.deg2rad(self.lat)
phi_stag = np.deg2rad(self.lat_bounds)
H = 1.E15*self.heat_transport()
return (-1./(2*np.math.pi*const.a**2*np.cos(phi)) *
np.diff(H)/np.diff(phi_stag))



class EBM_seasonal(EBM):
def __init__(self, a0=0.33, a2=0.25, ai=None, **kwargs):
Expand All @@ -126,6 +133,7 @@ def __init__(self, a0=0.33, a2=0.25, ai=None, **kwargs):
self.add_subprocess('albedo',
albedo.StepFunctionAlbedo(state=self.state, **self.param))


class EBM_annual(EBM_seasonal):
def __init__(self, **kwargs):
'''This EBM uses realistic daily insolation.
Expand Down

0 comments on commit cc0bb27

Please sign in to comment.