Esempio n. 1
0
# create model instance
model = TwoLevel(sp, dt)
print 'pole/equator temp diff = ', model.thetaref.max() - model.thetaref.min()

# vort, div initial conditions
psipert = np.zeros((2, model.nlat, model.nlon), np.float)
psipert[1, :, :] = 5.e6 * np.sin(
    (model.lons - np.pi))**12 * np.sin(2. * model.lats)**12
psipert = np.where(model.lons[np.newaxis, :, :] > 0., 0, psipert)
psipert[1, :, :] += np.random.normal(scale=1.e6, size=(sp.nlats, sp.nlons))
ug = np.zeros((2, model.nlat, model.nlon), np.float)
vg = np.zeros((2, model.nlat, model.nlon), np.float)
ug[1, :, :] = model.umax * np.sin(2. * model.lats)**model.jetexp
vrtspec, divspec = sp.getvrtdivspec(ug, vg)
vrtspec = vrtspec + model.lap * sp.grdtospec(psipert)
thetaspec = model.nlbalance(vrtspec)
divspec = np.zeros(thetaspec.shape, thetaspec.dtype)

# create netcdf file.
nc = Dataset(output_file, 'w', format='NETCDF4_CLASSIC')
nc.rsphere = rsphere
nc.gridtype = gridtype
nc.ntrunc = ntrunc
nc.dt = dt
atts = [
    'grav', 'omega', 'cp', 'rgas', 'p0', 'ptop', 'delth', 'efold', 'ndiss',
    'tdrag', 'tdiab', 'umax', 'jetexp'
]
for att in atts:
    nc.setncattr(att, model.__dict__[att])
lat = nc.createDimension('lat', sp.nlats)
Esempio n. 2
0
# create model instance
model = TwoLevel(sp,dt)
print 'pole/equator temp diff = ',model.thetaref.max()-model.thetaref.min()

# vort, div initial conditions
psipert = np.zeros((2,model.nlat,model.nlon),np.float)
psipert[1,:,:] = 5.e6*np.sin((model.lons-np.pi))**12*np.sin(2.*model.lats)**12
psipert = np.where(model.lons[np.newaxis,:,:] > 0., 0, psipert)
psipert[1,:,:] += np.random.normal(scale=1.e6,size=(sp.nlats,sp.nlons))
ug = np.zeros((2,model.nlat,model.nlon),np.float)
vg = np.zeros((2,model.nlat,model.nlon),np.float)
ug[1,:,:] = model.umax*np.sin(2.*model.lats)**model.jetexp
vrtspec, divspec = sp.getvrtdivspec(ug,vg)
vrtspec = vrtspec + model.lap*sp.grdtospec(psipert)
thetaspec = model.nlbalance(vrtspec)
divspec = np.zeros(thetaspec.shape, thetaspec.dtype)

# create netcdf file.
nc = Dataset(output_file,'w',format='NETCDF4_CLASSIC')
nc.rsphere = rsphere
nc.gridtype = gridtype
nc.ntrunc = ntrunc
nc.dt = dt
atts = ['grav','omega','cp','rgas','p0','ptop','delth','efold','ndiss','tdrag','tdiab','umax','jetexp']
for att in atts:
    nc.setncattr(att,model.__dict__[att])
lat = nc.createDimension('lat',sp.nlats)
lon = nc.createDimension('lon',sp.nlons)
layer = nc.createDimension('layer',2)
t = nc.createDimension('t',None)