Esempio n. 1
0
 def __init__(self, scheme='cam3', absorber_vmr=None, **kwargs):
     super(CliMTRad, self).__init__(**kwargs)
     self.r = climt.radiation(scheme=scheme)
     self.param['climt_scheme'] = scheme
     newinput = [
         'q',
         'flux_from_sfc',
         'cldf',
         'clwp',
         'absorber_vmr',
     ]
     self.add_input(newinput)
     #  absorbing gases
     if absorber_vmr is None:
         absorber_vmr = {
             'CO2': 350.,
             'N2O': 0.,
             'CH4': 0.,
             'CFC11': 0.,
             'CFC12': 0.
         }
     self.absorber_vmr = absorber_vmr
     #  cloud input
     self.cldf = 0. * self.Tatm
     self.clwp = 0. * self.Tatm
     #  upwelling surface radiation... should be set by parent process
     self.flux_from_sfc = 0. * self.Ts
     newdiags = [
         'flux_to_sfc',
         'flux_to_space',
     ]
     for name in newdiags:
         self.init_diagnostic(name)
Esempio n. 2
0
 def __init__(self, scheme='cam3', absorber_vmr=None, **kwargs):
     super(CliMTRad, self).__init__(**kwargs)
     self.r = climt.radiation(scheme=scheme)
     self.param['climt_scheme'] = scheme
     newinput = ['q',
                 'flux_from_sfc',
                 'cldf',
                 'clwp',
                 'absorber_vmr',]
     self.add_input(newinput)
     #  absorbing gases
     if absorber_vmr is None:
         absorber_vmr = {'CO2': 350.,
                         'N2O': 0.,
                         'CH4': 0.,
                         'CFC11': 0.,
                         'CFC12': 0.}
     self.absorber_vmr = absorber_vmr
     #  cloud input
     self.cldf = 0. * self.Tatm
     self.clwp = 0. * self.Tatm
     #  upwelling surface radiation... should be set by parent process
     self.flux_from_sfc = 0. * self.Ts
     newdiags = ['flux_to_sfc',
                 'flux_to_space',]
     for name in newdiags:
         self.init_diagnostic(name)
Esempio n. 3
0
def compute(scheme='cam3'):
    r = climt.radiation(scheme=scheme)
    r(**par)

    print 'Zenith angle: %f' % r['zen']
    print 'Insolation:   %f' % r['solin']
    print 'TOA SW CRF:  %6.2f %6.2f' % (r['SwToa'], r['SwToaCf'])
    print 'TOA LW CRF:  %6.2f %6.2f' % (r['LwToa'], r['LwToaCf'])
    # output
    print "lev    p     T       q      O3          lwflx         lwhr       swflx         swhr"
    for i in range(r.nlev):
        print "%3i %6.1f %6.1f %6.3f %10.3e %12.5f %12.5f %12.5f %12.5f" % \
              (i, r['p'][i], r['T'][i], r['q'][i], r['o3'][i], \
               r['lwflx'][i], r['lwhr'][i], r['swflx'][i], r['swhr'][i])
Esempio n. 4
0
def compute(scheme='cam3'):
    r=climt.radiation(scheme=scheme)
    r(**par)


    print 'Zenith angle: %f' % r['zen']
    print 'Insolation:   %f' % r['solin']
    print 'TOA SW CRF:  %6.2f %6.2f' % (r['SwToa'],r['SwToaCf'])
    print 'TOA LW CRF:  %6.2f %6.2f' % (r['LwToa'],r['LwToaCf'])
    # output
    print "lev    p     T       q      O3          lwflx         lwhr       swflx         swhr"
    for i in range(r.nlev):
        print "%3i %6.1f %6.1f %6.3f %10.3e %12.5f %12.5f %12.5f %12.5f" % \
              (i, r['p'][i], r['T'][i], r['q'][i], r['o3'][i], \
               r['lwflx'][i], r['lwhr'][i], r['swflx'][i], r['swhr'][i]) 
Esempio n. 5
0
    def __init__(self,
                 Case1='uh0',
                 Case2='uh1',
                 FileNumber=0):

        self.Case1 = Case1
        self.Case2 = Case2
        self.FileNumber = FileNumber
        # init data server
        self.data = DataServer(Case1,Case2,FileNumber)
        # geometry
        self.cosphi = cos(self.data.lat*pi/180.)
        self.a   = 6.37122e6
        # radiation
        self.r = climt.radiation(scheme='cam3')
        # fixed params
        self.Fixed={}
        self.Fixed['ch4'] = 7.6e-7 * 1.e6
        self.Fixed['n2o'] = 2.6e-7 * 1.e6
        self.Fixed['cfc11'] = 1.e-32
        self.Fixed['cfc12'] = 1.e-32
        self.Fixed['scon'] = 1365.
        # compute
        self.compute()
Esempio n. 6
0
# import pdb; pdb.set_trace()
# set whether this is a global average or not
global_average = True

# a useful function
def sigdig(x, digits=1):
    if x: x = copysign(round(x, -int(floor(log10(abs(x)))) + (digits - 1)), x)
    return x

sys.stderr.write(json.dumps(model_data))

# if it's a global average, make the first run a night-time case
if global_average:
    
    lw_model = climt.radiation(scheme='rrtm', do_sw=0, **model_data)
    
    fluxes = {
        'swuflx': numpy.array(lw_model['swuflx']),
        'swdflx': numpy.array(lw_model['swdflx']),
        'lwuflx': numpy.array([sigdig(float(f), 3) for f in lw_model['lwuflx']]),
        'lwdflx': numpy.array([sigdig(float(f), 3) for f in lw_model['lwdflx']]),
        'LwToa': sigdig(float(lw_model['LwToa']), 3),
        'SwToa': 0.
    }
    
    number_of_divisions = 20
    for n in range(number_of_divisions):
        model_data['zen'] = acos((n + .5)/number_of_divisions) * 180 / pi
        sw_model = climt.radiation(scheme = 'rrtm', do_lw=0, **model_data)
        fluxes['swuflx'] += numpy.array(sw_model['swuflx']) / (2 * number_of_divisions)
Esempio n. 7
0
par['calday']   =  83.333333
par['lat']      = 0.
par['lon']      = 0.
par['Cpd']      = 1004.64
par['epsilon']  = 0.622
par['g']        = 9.80616
par['p']        = p
par['T']        = T
par['q']        = q * 1.e3
par['o3']       = o3
par['cldf']     = cldf
par['clwp']     = clwp


import climt
r=climt.radiation(scheme='ccm3')
r(**par)


print 'Zenith angle: %f' % r.State['zen']
print 'Insolation:   %f' % r.State['solin']

# output
lw=r.lwflx
ql=r.lwhr*86400.
sw=r.swflx
qs=r.swhr*86400.
print "lev    p     T       q      O3          lwflx         lwhr       swflx         swhr"
for i in range(r.nlev):
    print "%3i %6.1f %6.1f %6.3f %10.3e %12.5f %12.5f %12.5f %12.5f" % (i, p[i], T[i], q[i], r.o3[i], lw[i], ql[i], sw[i], qs[i]) 
Esempio n. 8
0
par['avg'] = 'inst'
par['calday'] = 83.333333
par['lat'] = 0.
par['lon'] = 0.
par['Cpd'] = 1004.64
par['epsilon'] = 0.622
par['g'] = 9.80616
par['p'] = p
par['T'] = T
par['q'] = q * 1.e3
par['o3'] = o3
par['cldf'] = cldf
par['clwp'] = clwp

import climt
r = climt.radiation(scheme='ccm3')
r(**par)

print 'Zenith angle: %f' % r.State['zen']
print 'Insolation:   %f' % r.State['solin']

# output
lw = r.lwflx
ql = r.lwhr * 86400.
sw = r.swflx
qs = r.swhr * 86400.
print "lev    p     T       q      O3          lwflx         lwhr       swflx         swhr"
for i in range(r.nlev):
    print "%3i %6.1f %6.1f %6.3f %10.3e %12.5f %12.5f %12.5f %12.5f" % (
        i, p[i], T[i], q[i], r.o3[i], lw[i], ql[i], sw[i], qs[i])
Esempio n. 9
0
# 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']     = 'radconv.nc'
# 2) If RestartFile is not given, then initial values for prognostic
#    fields must be explicitly given, e.g.
nlev = climt.get_nlev()
kwargs['q'] = zeros(nlev) + 1.e-9
kwargs['T'] = zeros(nlev) + 250. #(kwargs['solin']/2./climt.parameters.Parameters()['stebol'])**0.25
kwargs['Ts'] = 250.

# -- Instantiate components and federation
rad = climt.radiation(UpdateFreq=kwargs['dt']*50)
con = climt.convection(scheme='emanuel')
dif = climt.turbulence()
ice = climt.seaice()
ins = climt.insolation(lat=85.,avg='daily')

kwargs['Hslab']=50.
kwargs['Pr']=100.
#kwargs['do_srf_lat_flx']=0
#kwargs['do_srf_sen_flx']=0

T0,q0 = climt.thermodyn.moistadiabat(rad['p'],273.,273.-90,.1)
kwargs['T'],kwargs['q'] = T0,q0

fed = climt.federation(dif, rad, ice, con, ins, **kwargs)
Esempio n. 10
0
 def __init__(self, scheme='cam3', **kwargs):
     super(CliMTRad, self).__init__(**kwargs)
     self.r = climt.radiation(scheme=scheme)
     self.param['climt_scheme'] = scheme
Esempio n. 11
0
            # write x label only if subplot does not have other subplot underneath
            if Subplot in ["111", "212", "223", "224"]:
                pylab.xlabel(AxisName[1])
            pylab.ylabel(AxisName[0])
            self.handle.set_norm(None)

        # Title
        self.TitleTemplate = "%s  [%s]" % (FieldKey, KnownFields[FieldKey][1]) + " %6.2f days"
        if len(AxisName) == 2:
            self.TitleTemplate = self.TitleTemplate + "\n min=%g max=%g"
        day = Component.State.ElapsedTime / 86400.0
        try:
            TitleText = self.TitleTemplate % day
        except:
            TitleText = self.TitleTemplate % (day, min(ravel(Field)), max(ravel(Field)))
        self.title = pylab.title(TitleText)
        self.title.set_fontsize(12)


if __name__ == "__main__":

    import climt

    r = climt.radiation(lat=arange(0.0, 90.0, 10.0))
    m = Monitor(r, MonitorFields=["T", "Ts"])
    for i in range(10):
        r.step()
        m.refresh(r)

    show()
Esempio n. 12
0
import climt
import pylab as pl
import numpy as np
from numpy import arange

pl.ioff()

# co2 = [0.,100.,1000.,10000.,100000.]
c = 0.
#--- instantiate radiation module
r = climt.radiation(scheme='cam3')

#--- initialise T,q
# Surface temperature
Ts = 273.15 + 30.                         
# Strospheric temp
Tst = 273.15 - 80.                         
# Surface pressure
ps = 1000.
# Equispaced pressure levels
p = ( arange(r.nlev)+ 0.5 )/r.nlev * ps
# Return moist adiabat with 70% rel hum
(T,q) = climt.thermodyn.moistadiabat(p, Ts, Tst, 1.)


# 
# cam3 = climt.radiation(scheme='cam3')
# cam3(co2=co2, p=p, ps=ps, T=T, Ts=Ts, q=q)
# # pl.plot(cam3['lwdflx'], cam3['p'])
# 
# chou = climt.radiation(scheme='chou')
Esempio n. 13
0
Ndays         = 5.  # Total length of run (days)

kwargs={}
kwargs['lat']            = ['1.','2.']
kwargs['solin']            = ['300.','310.']
kwargs['dt']              = 60.*10.
#kwargs['RestartFile']     = 'two_column.nc'
kwargs['OutputFile']      = 'two_column.nc'
kwargs['OutputFreq']      = 60*10.
#kwargs['MonitorFields']   = ['U','T','q']
#kwargs['MonitorFreq']     = 60 *60.*4.

# Set up federation
dyn  = climt.dynamics(scheme='two_column')
tur  = climt.turbulence()
rad  = climt.radiation(scheme='cam3')
con  = climt.convection(scheme='hard')
oce  = climt.ocean()
fed  = climt.federation(dyn,tur,rad,con,oce, **kwargs)

# Run
fed.step(Ndays*86400.)

try:
    from matplotlib.pylab import *
    show()
except:
    pass

Esempio n. 14
0
# 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):
    # With a line like the following, it is possible to manipulate
    # field values each time step (the example here resets humidity
    # to an almost dry value everywhere at each timestep)
    #fed.State['q']=zeros(rad.nlev)+1.e-9
    # The following code adds a uniform 1 K/day cooling rate to
    # the internally-computed tendencies
Esempio n. 15
0
## Automatically adapted for numpy.oldnumeric Feb 01, 2008 by -c

import climt,numpy.oldnumeric as Numeric

# instantiate radiation module
r=climt.radiation(scheme='gray')

# initialise T,q to moist adiabat with 70% RH
ps   = 1020. # surface pressure
q0   = 15.   # surface moisture
T0   = 300.  # surface temp
the0 = climt.thetae(T0,ps,q0)
p    = ( Numeric.arange(r.nlev,typecode='d')+ 0.5 ) * ps/r.nlev
T    = Numeric.zeros(r.nlev,typecode='d')
q    = Numeric.zeros(r.nlev,typecode='d')
for k in range(r.nlev):
    T[k] = climt.tmoistadiab(the0,p[k]) 
    if (T[k] < 273.15-80.): T[k]=273.15-80.
    q[k] = climt.qsflatau(T[k],p[k],1)*0.7
    if (p[k] < 100.): q[k]=1.e-9

# compute radiative fluxes and heating rates
r(p=p,ps=ps,T=T,Ts=T0,q=q)

# output
lw = r['lwflx']
ql = r['lwhr']

print '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'Testing grey gas radiation module ...'
Esempio n. 16
0
    cldf[:, i] = getProfile(nlayers, kcentral, 3, nz)
zen = arange(ny) * 5. + 5.
print zen

inputs = {}
inputs['Ts'] = zeros((ny, nx)) + Ts
inputs['ps'] = zeros((ny, nx)) + ps
inputs['solin'] = zeros((ny, nx)) + 400.
inputs['zen'] = zeros((ny, nx)) + zen[::-1, None]
inputs['p'] = zeros((nz, ny, nx)) + p[:, None, None]
inputs['T'] = zeros((nz, ny, nx)) + T[:, None, None]
inputs['q'] = zeros((nz, ny, nx)) + q[:, None, None]
inputs['clwp'] = zeros((nz, ny, nx)) + 15.
inputs['cldf'] = zeros((nz, ny, nx)) + cldf[:, None, :]

r = climt.radiation(scheme='cam3', do_lw=0)

LoCldf = 0.01
HiCldf = 0.99
LoTime = 1.
HiTime = 1.
LoWeight = LoTime / (LoTime + HiTime)
HiWeight = HiTime / (LoTime + HiTime)

Mean = LoCldf * LoWeight + HiCldf * HiWeight

inputs['cldf'] *= LoCldf
r(**inputs)
Lo = r['SwToaCf']

inputs['cldf'] *= HiCldf / LoCldf
Esempio n. 17
0
## Automatically adapted for numpy.oldnumeric Feb 01, 2008 by -c

import climt, numpy.oldnumeric as Numeric

# instantiate radiation module
r = climt.radiation(scheme='chou')

# initialise T,q to moist adiabat with 70% RH
ps = 1020.  # surface pressure
q0 = 15.  # surface moisture
T0 = 300.  # surface temp
the0 = climt.thetae(T0, ps, q0)
p = (Numeric.arange(r.nlev, typecode='d') + 0.5) * ps / r.nlev
T = Numeric.zeros(r.nlev, typecode='d')
q = Numeric.zeros(r.nlev, typecode='d')
for k in range(r.nlev):
    T[k] = climt.tmoistadiab(the0, p[k])
    if (T[k] < 273.15 - 80.): T[k] = 273.15 - 80.
    q[k] = climt.qsflatau(T[k], p[k], 1) * 0.7
    if (p[k] < 100.): q[k] = 1.e-9

# compute radiative fluxes and heating rates
r(p=p, ps=ps, T=T, Ts=T0, q=q)

# output
lw = r['lwflx']
ql = r['lwhr']
sw = r['swflx']
qs = r['swhr']
o3 = r['o3']
Esempio n. 18
0
RH_control     = 0
T0_RH          = 20. + 273.15

Drop_size      = 10.
Cloud_frac_hi  = 0.
Cloud_frac_lo  = 0.
Cloud_water_hi = 0. 
Cloud_water_lo = 0.

zen = 60.

if Cloud_water_lo == 0.: Cloud_frac_lo  = 0.
if Cloud_water_hi == 0.: Cloud_frac_hi  = 0.

# instantiate radiation objects, get number of levels
r=climt.radiation(scheme=scheme)
nlev=r.nlev

# define some fixed profiles
SurfPres = 1000.
Pressure  = ( arange(nlev)+ 0.5 ) * SurfPres/nlev
cldf = zeros( nlev, 'd')  # Cloud frac
clwp = zeros( nlev, 'd')  # Cloud liquid water path
cloud_lev_hi = int(nlev*0.2)  # put high cloud roughly at 200 mb
cloud_lev_lo = int(nlev*0.8)  # put low cloud roughly at 800 mb
cldf[cloud_lev_lo] = Cloud_frac_lo
cldf[cloud_lev_hi] = Cloud_frac_hi
clwp[cloud_lev_lo] = Cloud_water_lo
clwp[cloud_lev_hi] = Cloud_water_hi

# dictionary for input into rad call
Esempio n. 19
0
            if Subplot in ['111', '212', '223', '224']:
                pylab.xlabel(AxisName[0])
            pylab.ylabel(AxisName[1])
            self.handle.set_norm(None)

        # Title
        self.TitleTemplate = '%s  [%s]' % (
            FieldKey, KnownFields[FieldKey][1]) + ' %6.2f days'
        if len(AxisName) == 2:
            self.TitleTemplate = self.TitleTemplate + '\n min=%g max=%g'
        day = Component.State.ElapsedTime / 86400.
        try:
            TitleText = self.TitleTemplate % day
        except:
            TitleText = self.TitleTemplate % (day, min(
                ravel(plot_field)), max(ravel(plot_field)))
        self.title = pylab.title(TitleText)
        self.title.set_fontsize(12)


if __name__ == '__main__':

    import climt
    r = climt.radiation(lat=arange(0., 90., 10.))
    m = Monitor(r, MonitorFields=['T', 'Ts'])
    for i in range(10):
        r.step()
        m.refresh(r)

    show()
Esempio n. 20
0
RH_control = 0
T0_RH = 20. + 273.15

Drop_size = 10.
Cloud_frac_hi = 0.
Cloud_frac_lo = 0.
Cloud_water_hi = 0.
Cloud_water_lo = 0.

zen = 60.

if Cloud_water_lo == 0.: Cloud_frac_lo = 0.
if Cloud_water_hi == 0.: Cloud_frac_hi = 0.

# instantiate radiation objects, get number of levels
r = climt.radiation(scheme=scheme)
nlev = r.nlev

# define some fixed profiles
SurfPres = 1000.
Pressure = (arange(nlev) + 0.5) * SurfPres / nlev
cldf = zeros(nlev, 'd')  # Cloud frac
clwp = zeros(nlev, 'd')  # Cloud liquid water path
cloud_lev_hi = int(nlev * 0.2)  # put high cloud roughly at 200 mb
cloud_lev_lo = int(nlev * 0.8)  # put low cloud roughly at 800 mb
cldf[cloud_lev_lo] = Cloud_frac_lo
cldf[cloud_lev_hi] = Cloud_frac_hi
clwp[cloud_lev_lo] = Cloud_water_lo
clwp[cloud_lev_hi] = Cloud_water_hi

# dictionary for input into rad call
Esempio n. 21
0
# set whether this is a global average or not
global_average = True


# a useful function
def sigdig(x, digits=1):
    if x: x = copysign(round(x, -int(floor(log10(abs(x)))) + (digits - 1)), x)
    return x


sys.stderr.write(json.dumps(model_data))

# if it's a global average, make the first run a night-time case
if global_average:

    lw_model = climt.radiation(scheme='rrtm', do_sw=0, **model_data)

    fluxes = {
        'swuflx': numpy.array(lw_model['swuflx']),
        'swdflx': numpy.array(lw_model['swdflx']),
        'lwuflx':
        numpy.array([sigdig(float(f), 3) for f in lw_model['lwuflx']]),
        'lwdflx':
        numpy.array([sigdig(float(f), 3) for f in lw_model['lwdflx']]),
        'LwToa': sigdig(float(lw_model['LwToa']), 3),
        'SwToa': 0.
    }

    number_of_divisions = 20
    for n in range(number_of_divisions):
        model_data['zen'] = acos((n + .5) / number_of_divisions) * 180 / pi
Esempio n. 22
0
## Automatically adapted for numpy.oldnumeric Feb 01, 2008 by -c

import climt, numpy.oldnumeric as Numeric

# instantiate radiation module
r = climt.radiation(scheme='gray')

# initialise T,q to moist adiabat with 70% RH
ps = 1020.  # surface pressure
q0 = 15.  # surface moisture
T0 = 300.  # surface temp
the0 = climt.thetae(T0, ps, q0)
p = (Numeric.arange(r.nlev, typecode='d') + 0.5) * ps / r.nlev
T = Numeric.zeros(r.nlev, typecode='d')
q = Numeric.zeros(r.nlev, typecode='d')
for k in range(r.nlev):
    T[k] = climt.tmoistadiab(the0, p[k])
    if (T[k] < 273.15 - 80.): T[k] = 273.15 - 80.
    q[k] = climt.qsflatau(T[k], p[k], 1) * 0.7
    if (p[k] < 100.): q[k] = 1.e-9

# compute radiative fluxes and heating rates
r(p=p, ps=ps, T=T, Ts=T0, q=q)

# output
lw = r['lwflx']
ql = r['lwhr']

print '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'Testing grey gas radiation module ...'
Esempio n. 23
0
Ndays = 5.0  # Total length of run (days)

kwargs = {}
kwargs["lat"] = ["1.", "2."]
kwargs["solin"] = ["300.", "310."]
kwargs["dt"] = 60.0 * 10.0
# kwargs['RestartFile']     = 'two_column.nc'
kwargs["OutputFile"] = "two_column.nc"
kwargs["OutputFreq"] = 60 * 10.0
# kwargs['MonitorFields']   = ['U','T','q']
# kwargs['MonitorFreq']     = 60 *60.*4.

# Set up federation
dyn = climt.dynamics(scheme="two_column")
tur = climt.turbulence()
rad = climt.radiation(scheme="cam3")
con = climt.convection(scheme="hard")
oce = climt.ocean()
fed = climt.federation(dyn, tur, rad, con, oce, **kwargs)

# Run
fed.step(Ndays * 86400.0)

try:
    from matplotlib.pylab import *

    show()
except:
    pass
Esempio n. 24
0
 def __init__(self, scheme='cam3', **kwargs):
     super(CliMTRad, self).__init__(**kwargs)
     self.r = climt.radiation(scheme=scheme)
     self.param['climt_scheme'] = scheme
Esempio n. 25
0
## Automatically adapted for numpy.oldnumeric Feb 01, 2008 by -c

import climt,numpy.oldnumeric as Numeric

# instantiate radiation module
r=climt.radiation(scheme='chou')

# initialise T,q to moist adiabat with 70% RH
ps   = 1020. # surface pressure
q0   = 15.   # surface moisture
T0   = 300.  # surface temp
the0 = climt.thetae(T0,ps,q0)
p    = ( Numeric.arange(r.nlev,typecode='d')+ 0.5 ) * ps/r.nlev
T    = Numeric.zeros(r.nlev,typecode='d')
q    = Numeric.zeros(r.nlev,typecode='d')
for k in range(r.nlev):
    T[k] = climt.tmoistadiab(the0,p[k]) 
    if (T[k] < 273.15-80.): T[k]=273.15-80.
    q[k] = climt.qsflatau(T[k],p[k],1)*0.7
    if (p[k] < 100.): q[k]=1.e-9

# compute radiative fluxes and heating rates
r(p=p,ps=ps,T=T,Ts=T0,q=q)

# output
lw=r['lwflx']
ql=r['lwhr']
sw=r['swflx']
qs=r['swhr']
o3=r['o3']
Esempio n. 26
0
                    extent=(xmin, xmax, ymin, ymax),\
                    interpolation='bilinear')
               pylab.setp(pylab.gca(), 'xlim',[xmin,xmax], 'ylim',[ymin,ymax])
            # write x label only if subplot does not have other subplot underneath
            if Subplot in ['111','212','223','224']: pylab.xlabel(AxisName[1])
            pylab.ylabel(AxisName[0])
            self.handle.set_norm(None)

        # Title
        self.TitleTemplate = '%s  [%s]' % (FieldKey,KnownFields[FieldKey][1]) + ' %6.2f days' 
        if len(AxisName) == 2: self.TitleTemplate = self.TitleTemplate + '\n min=%g max=%g' 
        day = Component.State.ElapsedTime/86400.
        try:
            TitleText = self.TitleTemplate % day
        except:
            TitleText = self.TitleTemplate % (day, min(ravel(Field)), max(ravel(Field)))
        self.title = pylab.title(TitleText)
        self.title.set_fontsize(12)


if __name__=='__main__':

    import climt
    r=climt.radiation(lat=arange(0.,90.,10.))    
    m=Monitor(r, MonitorFields=['T','Ts'])
    for i in range(10):
        r.step()
        m.refresh(r)

    show()
    cldf[:,i] = getProfile(nlayers, kcentral, 3, nz)
zen = arange(ny)*5. + 5.
print zen

inputs = {}
inputs['Ts']    = zeros((ny,nx))    + Ts
inputs['ps']    = zeros((ny,nx))    + ps
inputs['solin'] = zeros((ny,nx))    + 400.
inputs['zen']   = zeros((ny,nx))    + zen[::-1,None]
inputs['p']     = zeros((nz,ny,nx)) + p[:,None,None]  
inputs['T']     = zeros((nz,ny,nx)) + T[:,None,None]  
inputs['q']     = zeros((nz,ny,nx)) + q[:,None,None]  
inputs['clwp']  = zeros((nz,ny,nx)) + 15.
inputs['cldf']  = zeros((nz,ny,nx)) + cldf[:,None,:]

r = climt.radiation(scheme='cam3', do_lw=0)

LoCldf = 0.01
HiCldf = 0.99
LoTime =1.
HiTime =1.
LoWeight = LoTime/(LoTime+HiTime)
HiWeight = HiTime/(LoTime+HiTime)

Mean = LoCldf*LoWeight + HiCldf*HiWeight

inputs['cldf'] *= LoCldf
r(**inputs)
Lo = r['SwToaCf']

inputs['cldf'] *= HiCldf/LoCldf
# 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):
    # With a line like the following, it is possible to manipulate
    # field values each time step (the example here resets humidity
    # to an almost dry value everywhere at each timestep)
    #fed.State['q']=zeros(rad.nlev)+1.e-9
    # The following code adds a uniform 1 K/day cooling rate to 
    # the internally-computed tendencies