# create model instance. model =\ TwoLevel(sp,dt,ntrunc,efold=efold,tdiab=tdiab,tdrag=tdrag,jetexp=jetexp,umax=umax,moistfact=moistfact) # initial state is equilbrium jet + random noise. vg = np.zeros((sp.nlat, sp.nlon, 2), np.float32) ug = model.uref vrtspec, divspec = sp.getvrtdivspec(ug, vg, model.ntrunc) psispec = np.zeros(vrtspec.shape, vrtspec.dtype) psispec.real += npran.normal(scale=1.e4, size=(psispec.shape)) psispec.imag += npran.normal(scale=1.e4, size=(psispec.shape)) vrtspec = vrtspec + model.lap[:, np.newaxis] * psispec thetaspec = model.nlbalance(vrtspec) divspec = np.zeros(thetaspec.shape, thetaspec.dtype) model.vrt = sp.spectogrd(vrtspec) model.theta = sp.spectogrd(thetaspec) model.heat = np.zeros(model.theta.shape, model.theta.dtype) # animate vorticity from solution as it is running # first, create initial frame fig = plt.figure(figsize=(8, 10)) ax1 = fig.add_subplot(2, 1, 1) ax2 = fig.add_subplot(2, 1, 2) m = Basemap(projection='kav7', lon_0=0) lons1d = model.lons[0, :] * 180. / np.pi lats1d = model.lats[:, 0] * 180. / np.pi data1, lons1dx = addcyclic(model.vrt[:, :, 1], lons1d) data2, lons1dx = addcyclic(model.theta, lons1d) lons, lats = np.meshgrid(lons1dx, lats1d) x, y = m(lons, lats)