New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
plot_psi.py in NEMO/branches/2019/dev_r11085_ASINTER-05_Brodeau_Advanced_Bulk/tests/ISOMIP/EXPREF – NEMO

source: NEMO/branches/2019/dev_r11085_ASINTER-05_Brodeau_Advanced_Bulk/tests/ISOMIP/EXPREF/plot_psi.py @ 13894

Last change on this file since 13894 was 7715, checked in by flavoni, 7 years ago

#1850 commit new list of REFERENCE CONFIGURATIONS, and SETTE tests

File size: 1.5 KB
Line 
1from netCDF4 import Dataset
2import numpy as np
3from numpy import ma
4import argparse
5import matplotlib.pyplot as plt
6
7parser = argparse.ArgumentParser()
8parser.add_argument("-f" , metavar='file_name'   , help="names of input files" , type=str  , nargs="+", required=True )
9parser.add_argument("-v" , metavar='var_name'    , help="variable list"        , type=str  , nargs=1  , required=True )
10args = parser.parse_args()
11
12# read mesh_mask
13ncid   = Dataset('mesh_mask.nc')
14lat2d  = ncid.variables['gphit'    ][  :,:].squeeze()
15lon2d  = ncid.variables['glamt'    ][  :,:].squeeze()
16msk    = ncid.variables['tmaskutil'][0,:,:].squeeze()
17ncid.close()
18
19plt.figure(figsize=np.array([210,210]) / 25.4)
20
21# read psi.nc
22ncid   = Dataset(args.f[0])
23var2d  = ncid.variables[args.v[0]][-1,:,:].squeeze() 
24var2dm = ma.masked_where(msk==0.0,var2d)
25# convert in Sv
26var2dm = var2dm / 1e6
27ncid.close()
28 
29# define colorbar
30vlevel=np.arange(0.00,0.36,0.02)
31pcol = plt.contourf(lon2d,lat2d,var2dm,levels=vlevel)
32plt.clf()
33
34# plot contour
35ax = plt.subplot(1, 1, 1)
36ax.contour(lon2d,lat2d,var2dm,levels=vlevel)
37ax.grid()
38ax.set_title('PSI ISOMIP (Sv)')
39ax.set_ylabel('Latitude',fontsize=14)
40ax.set_xlabel('Longitude',fontsize=14)
41
42# plot colorbar
43plt.subplots_adjust(left=0.1,right=0.89, bottom=0.1, top=0.89, wspace=0.1, hspace=0.1)
44cax = plt.axes([0.91, 0.1, 0.02, 0.79])
45cbar= plt.colorbar(pcol, ticks=vlevel, cax=cax)
46cbar.ax.tick_params(labelsize=14)
47
48# save figure
49plt.savefig('psi.png', format='png', dpi=300)
50
51plt.show()
52
Note: See TracBrowser for help on using the repository browser.