gotPylab = True
except:
    gotPylab = False

def getProfile(nlayers, kcentral, kmin, kmax):
    # returns profile with N layers centered on layer k
    x = zeros(kmax,'d')
    k1 = max(kmin, kcentral-nlayers/2-1)
    k2 = min(kmax, kcentral+nlayers/2)
    x[k1:k2] = 1.
    return x

#--- initialise data
nx    = 7
ny    = 10
nz    = climt.get_nlev()
ps    = 1020.                                # Surface pressure
Ts    = 273.15 + 30.                         # Surface temperature
Tst   = 273.15 - 80.                         # 'Strospheric' temp
p     = ( arange(nz)+0.5 ) * ps/nz 
(T,q) = climt.thermodyn.moistadiabat(p, Ts, Tst, 0.7)
cldf = zeros((nz,nx),'d')
for i in range(nx):
    kcentral = 11
    nlayers = 2*i+3
    print getProfile(nlayers, kcentral, 3, nz)
    cldf[:,i] = getProfile(nlayers, kcentral, 3, nz)
zen = arange(ny)*5. + 5.
print zen

inputs = {}
Example #2
0
# exists, it will be overwritten. If OutputFile is not given,
# no output will be written to file. Output will be written every
# OutputFreq seconds
kwargs['OutputFile'] = 'radconv.nc'
kwargs['OutputFreq'] = 86400. * 10.

# Initial conditions can be specified in 2 ways:
# 1) by specifying a restart file, whose format is identical to
#    that of an output file. If the file contains a time series,
#    the model will initialize from the last time step in the file.
#    If RestartFile and OutputFile are the same, then output will be
#    appended to the restart file (ie. a continuation run).
#kwargs['RestartFile']     = 'restart.nc'
# 2) If RestartFile is not given, then initial values for prognostic
#    fields must be explicitly given, e.g.
nlev = climt.get_nlev()
stebol = climt.Parameters()['stebol']
kwargs['q'] = zeros(nlev) + 1.e-9
kwargs['T'] = zeros(nlev) + (kwargs['solin'] / 2. / stebol)**0.25

# -- Instantiate components and federation
rad = climt.radiation(UpdateFreq=kwargs['dt'] * 50, scheme='cam3')
con = climt.convection(scheme='emanuel')
dif = climt.turbulence()
oce = climt.ocean()
fed = climt.federation(dif, rad, oce, con, **kwargs)

# Main timestepping loop
RunLength = 2000.  # Total length of run (days)
NSteps = int(RunLength * 86400. / fed['dt'])
for i in range(NSteps):
Example #3
0
# Results are available directly from the object, which can be indexed like a dictionary.
# E.g. this is the OLR:
print r['LwToa'] #  note that all fluxes are defined positive downward, so OLR is negative

# To compute radiative fluxes with non-default paramaters, specify them in input.
# Eg. for 900 ppm CO2:
print ''
r(co2=900.)
print r['LwToa']

# Non-default profiles can also be passed in, but they must be correctly dimensioned.
# The number of grid points in the vertical is specified at compile time as variable KM in setup.py
# and can be retrieved with the get_nlev command:
print ''
nlev = climt.get_nlev()
T = numpy.zeros(nlev) + 273. # isothermal profile; for a more realistic example, see basic_radiation.py
r(T=T)
print r['LwToa']

# You can also pass in an array of profiles; radiative fluxes will be computed for
# each columns in the array:
print ''
T = numpy.array([[T,T],[T,T]]).transpose()
r(T=T)
print r['LwToa']

# Important climt gotcha: each time the object is called, all parameters and fields not explicitly
# passed in are reset to their default values:
print ''
r(co2=900.)
Example #4
0
    gotPylab = False


def getProfile(nlayers, kcentral, kmin, kmax):
    # returns profile with N layers centered on layer k
    x = zeros(kmax, 'd')
    k1 = max(kmin, kcentral - nlayers / 2 - 1)
    k2 = min(kmax, kcentral + nlayers / 2)
    x[k1:k2] = 1.
    return x


#--- initialise data
nx = 7
ny = 10
nz = climt.get_nlev()
ps = 1020.  # Surface pressure
Ts = 273.15 + 30.  # Surface temperature
Tst = 273.15 - 80.  # 'Strospheric' temp
p = (arange(nz) + 0.5) * ps / nz
(T, q) = climt.thermodyn.moistadiabat(p, Ts, Tst, 0.7)
cldf = zeros((nz, nx), 'd')
for i in range(nx):
    kcentral = 11
    nlayers = 2 * i + 3
    print getProfile(nlayers, kcentral, 3, nz)
    cldf[:, i] = getProfile(nlayers, kcentral, 3, nz)
zen = arange(ny) * 5. + 5.
print zen

inputs = {}