source: configs/testing/python/post_DCMIP31.py @ 502

Last change on this file since 502 was 502, checked in by dubos, 7 years ago

configs/testing : towards first working version

File size: 1.4 KB
Line 
1from common import *
2
3def plot_T850(lon,lat,T850):  # T850 at final time
4    print 'Reading data ...'
5    lon, lat, T850 = lon[:], lat[:], T850[-1, :, :]
6    print '... done.'
7    plt.figure(figsize=(12,6))
8    plt.contourf(lon,lat,T850)
9    plt.colorbar() 
10    plt.title('T850')
11    axis_longitude()
12    axis_latitude()
13    plt.savefig('T850.png')
14
15def plot_dT(nlon,nlat,llm, lon,T,Phi): # perturbation temp, final time
16    # vertical slice at final time
17    print 'Reading data ...'
18    T, Phi =T[-1,:,nlat/2,:], Phi[-1,:,nlat/2,:]
19    print '... done.'
20    Cpd, kappa, g = 1004.5, 0.2857143, 9.80616
21    N, Teq, peq = 0.01, 300., 1e5
22    N2, g2 = N*N, g*g
23    G = g2/(N2*Cpd)
24
25    lon2, z = np.zeros((llm,nlon)), np.zeros((llm,nlon))
26    for lev in range(llm):
27        z[lev,:] = (.5/g)*(Phi[lev,:]+Phi[lev+1,:]) # average from interfaces to full levels
28        lon2[lev,:] = lon[:]
29
30    Tb = G + (Teq-G)*np.exp(N2*z/g) # background temperature
31    plt.figure(figsize=(12,6))
32    plt.contourf(lon2,z,T-Tb, levels=np.arange(-0.08,0.12,0.02) )
33    plt.colorbar() 
34    plt.title('T-Tb')
35    axis_longitude()
36    plt.ylabel('z (m)')
37    plt.yticks(np.arange(0, 10001, 1000))
38    plt.savefig('dT.png')
39
40gridfile = 'netcdf/output_dcmip2016_regular.nc'
41nc = cdf.Dataset(gridfile, "r")
42llm, nlon, nlat, ntime = getdims(nc, 'lev','lon','lat','time_counter')
43lon, lat, T850, T, Phi = getvars(nc, 'lon','lat','T850', 'T', 'PHI')
44plot_dT(nlon,nlat,llm, lon,T,Phi)
45plot_T850(lon,lat,T850)
Note: See TracBrowser for help on using the repository browser.