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_moc.py in NEMO/branches/2018/dev_r9956_ENHANCE05_ZAD_AIMP/tests/ISOMIP/EXPREF – NEMO

source: NEMO/branches/2018/dev_r9956_ENHANCE05_ZAD_AIMP/tests/ISOMIP/EXPREF/plot_moc.py @ 9957

Last change on this file since 9957 was 9957, checked in by acc, 6 years ago

New development branch for the adaptive-implicit vertical advection (05_Gurvan-Vertical_advection)

File size: 1.7 KB
Line 
1from netCDF4 import Dataset
2import numpy as np
3import argparse
4import matplotlib.pyplot as plt
5
6# read argument
7parser = argparse.ArgumentParser()
8parser.add_argument("-f" , metavar='file_name'   , help="names of input files" , type=str  , nargs=1  , 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')
14vx2d  = ncid.variables['gphit'  ][0,:,0].squeeze()
15vx2dv = ncid.variables['gphiv'  ][0,:,0].squeeze()
16y2d   = ncid.variables['gdepw_0'][0,:,:,1].squeeze()*-1
17y2dt  = ncid.variables['gdept_0'][0,:,:,1].squeeze()*-1
18msk   = ncid.variables['tmask'  ][0,:,:,1].squeeze()
19ncid.close()
20
21# build x 2d array
22x2d=y2d*0.0
23x2dv=y2d*0.0
24for jk in range(0,y2d.shape[0]):
25   x2d[jk,:]=vx2d[:]
26   x2dv[jk,:]=vx2d[:]
27
28plt.figure(figsize=np.array([210,210]) / 25.4)
29
30# read data and mask it
31ncid   = Dataset(args.f[0])
32var2d  = ncid.variables[args.v[0]][-1,:,:,:].squeeze() 
33var2dm = var2d[:,:]
34var2dm[msk==0] = -1
35ncid.close()
36
37# define colorbar
38vlevel=np.arange(0,0.13,0.01) 
39pcol = plt.contourf(x2d,y2d,var2dm,levels=vlevel)
40plt.clf()
41
42# plot contour
43ax = plt.subplot(1, 1, 1)
44ax.contour(x2dv,y2dt,var2dm,levels=vlevel)
45ax.grid()
46ax.set_title('MOC ISOMIP (Sv)')
47ax.set_ylabel('Depth (m)',fontsize=14)
48ax.set_xlabel('Latitude',fontsize=14)
49
50# plot colorbar
51plt.subplots_adjust(left=0.1,right=0.89, bottom=0.1, top=0.89, wspace=0.1, hspace=0.1)
52cax = plt.axes([0.91, 0.1, 0.02, 0.79])
53cbar= plt.colorbar(pcol, ticks=vlevel, cax=cax)
54cbar.ax.tick_params(labelsize=14)
55
56# save figure
57plt.savefig('moc.png', format='png', dpi=300)
58
59plt.show()
60
Note: See TracBrowser for help on using the repository browser.