#!/usr/bin/env python # coding: utf-8 # In[1]: import netCDF4 as nc import numpy as np from matplotlib import pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: f=nc.Dataset('/ocean/eolson/MEOPAR/NEMO-forcing/grid/mesh_mask201702_noLPE.nc') # In[3]: f.variables.keys() # In[4]: f.variables['e1t'] # In[5]: plt.pcolormesh(f.variables['e2t'][0,:,:300]) # In[6]: e1t=f.variables['e1t'][0,:,:] e2t=f.variables['e2t'][0,:,:] tmask=f.variables['tmask'][0,0,:,:] # In[7]: np.min(np.ma.masked_where(tmask==0,e1t)),np.max(np.ma.masked_where(tmask==0,e1t)) # In[8]: np.min(np.ma.masked_where(tmask==0,e2t)),np.max(np.ma.masked_where(tmask==0,e2t)) # In[9]: np.min(np.ma.masked_where(tmask==0,e1t*e2t)),np.max(np.ma.masked_where(tmask==0,e1t*e2t)) # In[10]: tmask=f.variables['tmask'][0,:,:,:] # In[14]: plt.pcolormesh(tmask[17,:,:]-tmask[18,:,:]) plt.colorbar() # In[23]: plt.pcolormesh((tmask[17,1:-1,1:-1]-tmask[17,2:,1:-1])*tmask[17,1:-1,1:-1]\ +(tmask[17,1:-1,1:-1]-tmask[17,0:-2,1:-1])*tmask[17,1:-1,1:-1]\ +(tmask[17,1:-1,1:-1]-tmask[17,1:-1,2:])*tmask[17,1:-1,1:-1]\ +(tmask[17,1:-1,1:-1]-tmask[17,1:-1,0:-2])*tmask[17,1:-1,1:-1]) plt.colorbar() # In[30]: plt.pcolormesh((2*tmask[17,1:-1,1:-1]-tmask[17,2:,1:-1]-tmask[17,0:-2,1:-1])*tmask[17,1:-1,1:-1]\ +(2*tmask[17,1:-1,1:-1]-tmask[17,1:-1,2:]-tmask[17,1:-1,0:-2])*tmask[17,1:-1,1:-1]) plt.colorbar() plt.xlim(120,150) plt.ylim(280,320) # In[ ]: