Changeset 727 for configs/testing/python


Ignore:
Timestamp:
08/22/18 17:30:37 (6 years ago)
Author:
dubos
Message:

testing : compare output to reference outputs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • configs/testing/python/common.py

    r520 r727  
    4444        #        plt.yticks(np.arange(0, 10001, 1000)) 
    4545        plt.savefig('%s.png'%varname) 
     46        plt.close() 
    4647    lon, lat, Omega,T,u,Phi = getvars(nc, 'lon','lat','OMEGA', 'T', 'U', 'PHI') 
    4748    plot_var(nlon,nlat,llm, lon,Phi,Omega,'Omega') 
     
    6465        axis_latitude() 
    6566        plt.savefig('T850.png') 
     67        plt.close() 
    6668         
    67     def plot_dT(nlon,nlat,llm, lon,T,p,Phi): # perturbation temp, final time 
     69    def plot_dT(nlon,nlat,llm, lon,T_ref,T,p,Phi): # perturbation temp, final time 
    6870        # vertical slice at final time 
    6971        print 'Reading data ...' 
    70         T,p, Phi = T[-1,:,nlat/2,:], p[-1,:,nlat/2,:], Phi[-1,:,nlat/2,:] 
     72        T_ref,T,p,Phi = [ x[-1,:,nlat/2,:] for x in T_ref,T,p,Phi] 
    7173        print '... done.' 
    7274        N, Teq, peq = 0.01, 300., 1e5 
     
    8587        plt.yticks(np.arange(0, 10001, 1000)) 
    8688        plt.savefig('dT.png') 
     89        plt.close() 
     90 
     91        plt.figure(figsize=(12,6)) 
     92        plt.contourf(lon2,z,T-T_ref) 
     93        plt.colorbar()  
     94        plt.title('$T-T_{ref}$') 
     95        axis_longitude() 
     96        plt.ylabel('z (m)') 
     97        plt.yticks(np.arange(0, 10001, 1000)) 
     98        plt.savefig('dT_ref.png') 
     99        plt.close() 
    87100 
    88101    lon, lat, T850, T, Phi, p = getvars(nc, 'lon','lat','T850', 'T', 'PHI','P') 
    89     plot_dT(nlon,nlat,llm, lon,T,p,Phi) 
     102    T_ref, = getvars(nc_ref, 'T') 
     103    plot_dT(nlon,nlat,llm, lon,T_ref,T,p,Phi) 
     104#    plot_dT_ref(nlon,nlat,llm, lon,T_ref,T,p,Phi) 
    90105    plot_T850(lon,lat,T850) 
    91106 
     
    116131#--------------------------- MAIN ---------------------------- 
    117132 
    118 gridfile = 'netcdf/output_dcmip2016_regular.nc' 
    119 nc = cdf.Dataset(gridfile, "r") 
     133filename = 'output_dcmip2016_regular.nc' 
     134nc = cdf.Dataset('netcdf/%s'%filename, "r") 
     135nc_ref = cdf.Dataset('netcdf_ref/%s'%filename, "r") 
     136 
    120137llm, nlon, nlat, ntime = getdims(nc, 'lev','lon','lat','time_counter') 
    121138Cpd, kappa, g = 1004.5, 0.2857143, 9.80616 
Note: See TracChangeset for help on using the changeset viewer.