import numpy as np
import matplotlib.pyplot as plt
import netCDF4 as nc
import cmocean
%matplotlib inline
with nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/mesh_mask201702.nc') as fm:
tmask=fm.variables['tmask'][:,:,:,:]
print(fm.variables.keys())
dict_keys(['nav_lon', 'nav_lat', 'time_counter', 'tmask', 'umask', 'vmask', 'fmask', 'tmaskutil', 'umaskutil', 'vmaskutil', 'fmaskutil', 'glamt', 'glamu', 'glamv', 'glamf', 'gphit', 'gphiu', 'gphiv', 'gphif', 'e1t', 'e1u', 'e1v', 'e1f', 'e2t', 'e2u', 'e2v', 'e2f', 'ff', 'mbathy', 'misf', 'isfdraft', 'e3t_0', 'e3u_0', 'e3v_0', 'e3w_0', 'gdept_0', 'gdepu', 'gdepv', 'gdepw_0', 'gdept_1d', 'gdepw_1d', 'e3t_1d', 'e3w_1d'])
f0=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_before/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
fptrc0=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_before/SalishSea_1d_20150401_20150402_ptrc_T_20150401-20150410.nc')
f0.variables.keys()
dict_keys(['nav_lat', 'nav_lon', 'bounds_nav_lon', 'bounds_nav_lat', 'area', 'deptht', 'deptht_bounds', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'])
f0b=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_before2/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
fP0b=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_before2/SalishSea_1d_20150401_20150402_grid_T_20150401-20150410.nc')
fP2=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_B/SalishSea_1d_20150401_20150402_grid_T_20150401-20150410.nc')
fptrc2=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_B/SalishSea_1d_20150401_20150402_ptrc_T_20150401-20150410.nc')
fP2b=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_B2/SalishSea_1d_20150401_20150402_grid_T_20150401-20150410.nc')
f1=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_A/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
f2=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_B/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
f2b=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_B2/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
fC=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/BelugaRuns/results/testShort_C/SalishSea_1d_20150401_20150402_dian_T_20150401-20150410.nc')
f1.variables.keys()
dict_keys(['nav_lat', 'nav_lon', 'bounds_nav_lon', 'bounds_nav_lat', 'area', 'deptht', 'deptht_bounds', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'])
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f0.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f0b.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
f0b.variables['GRMICZMRUB'][0,0,:,:]-f0.variables['GRMICZMRUB'][0,0,:,:]),
vmin=-1e-10,vmax=1e-10,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83e2019a90>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f0.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f1.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
f1.variables['GRMICZMRUB'][0,0,:,:]-f0.variables['GRMICZMRUB'][0,0,:,:]),
vmin=-1e-10,vmax=1e-10,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83e20a5a30>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f0.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f2.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
f2.variables['GRMICZMRUB'][0,0,:,:]-f0.variables['GRMICZMRUB'][0,0,:,:]),
vmin=-1e-10,vmax=1e-10,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83e14296d0>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f1.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f2.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
f2.variables['GRMICZMRUB'][0,0,:,:]-f1.variables['GRMICZMRUB'][0,0,:,:]),
vmin=-1e-11,vmax=1e-11,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83d0795760>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,f2.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fC.variables['GRMICZMRUB'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
fC.variables['GRMICZMRUB'][0,0,:,:]-f2.variables['GRMICZMRUB'][0,0,:,:]),
vmin=-1e-11,vmax=1e-11,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83d05a16a0>
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x0=np.ma.masked_where(tmask[0,:,:,:]==0,f0.variables[var][1,:,:,:])
x1=np.ma.masked_where(tmask[0,:,:,:]==0,f1.variables[var][1,:,:,:])
print(f'{var} min0:{np.min(x0)}, max0:{np.max(x0)}, min1:{np.min(x1)}, max1:{np.max(x1)}')
GRMICZDIAT min0:0.0, max0:0.0, min1:0.0, max1:0.0 GRMICZMRUB min0:0.0, max0:1.6768166233305237e-06, min1:0.0, max1:1.676815259088471e-06 GRMICZPHY min0:0.0, max0:3.6023006941832136e-06, min1:0.0, max1:3.6023006941832136e-06 GRMICZPON min0:0.0, max0:4.67904965262278e-06, min1:0.0, max1:4.679086487158202e-06 GRMICZMICZ min0:0.0, max0:1.1170722245879006e-05, min1:0.0, max1:1.1170714969921391e-05
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x0=np.ma.masked_where(tmask[0,:,:,:]==0,f0.variables[var][1,:,:,:])
x0b=np.ma.masked_where(tmask[0,:,:,:]==0,f0b.variables[var][1,:,:,:])
x1=np.ma.masked_where(tmask[0,:,:,:]==0,f1.variables[var][1,:,:,:])
print(f'{var} max(abs(before2-before)):{np.max(np.abs(x0b-x0))}, max(abs(A-before)):{np.max(np.abs(x1-x0))}')
GRMICZDIAT max(abs(before2-before)):0.0, max(abs(A-before)):0.0 GRMICZMRUB max(abs(before2-before)):0.0, max(abs(A-before)):1.552393769088667e-08 GRMICZPHY max(abs(before2-before)):0.0, max(abs(A-before)):3.543993898347253e-08 GRMICZPON max(abs(before2-before)):0.0, max(abs(A-before)):5.328195129550295e-08 GRMICZMICZ max(abs(before2-before)):0.0, max(abs(A-before)):8.941196938394569e-08
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x2=np.ma.masked_where(tmask[0,:,:,:]==0,f2.variables[var][1,:,:,:])
x1=np.ma.masked_where(tmask[0,:,:,:]==0,f1.variables[var][1,:,:,:])
print(f'{var} max(abs(A-B)):{np.max(np.abs(x1-x2))}')
GRMICZDIAT max(abs(A-B)):0.0 GRMICZMRUB max(abs(A-B)):3.6803520231387665e-09 GRMICZPHY max(abs(A-B)):2.1050482246209867e-08 GRMICZPON max(abs(A-B)):4.122000518691493e-09 GRMICZMICZ max(abs(A-B)):3.449878249739413e-08
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x2=np.ma.masked_where(tmask[0,:,:,:]==0,f2.variables[var][1,:,:,:])
x2b=np.ma.masked_where(tmask[0,:,:,:]==0,f2b.variables[var][1,:,:,:])
print(f'{var} max(abs(B-B2)):{np.max(np.abs(x2b-x2))}')
GRMICZDIAT max(abs(B-B2)):0.0 GRMICZMRUB max(abs(B-B2)):0.0 GRMICZPHY max(abs(B-B2)):0.0 GRMICZPON max(abs(B-B2)):0.0 GRMICZMICZ max(abs(B-B2)):0.0
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x2=np.ma.masked_where(tmask[0,:,:,:]==0,f2.variables[var][1,:,:,:])
xC=np.ma.masked_where(tmask[0,:,:,:]==0,fC.variables[var][1,:,:,:])
print(f'{var} max(abs(C-B)):{np.max(np.abs(xC-x2))}')
GRMICZDIAT max(abs(C-B)):0.0 GRMICZMRUB max(abs(C-B)):0.0 GRMICZPHY max(abs(C-B)):0.0 GRMICZPON max(abs(C-B)):0.0 GRMICZMICZ max(abs(C-B)):0.0
for var in ('GRMICZDIAT', 'GRMICZMRUB', 'GRMICZPHY', 'GRMICZPON', 'GRMICZMICZ'):
x2=np.ma.masked_where(tmask[0,:,:,:]==0,f2.variables[var][1,:,:,:])
x0=np.ma.masked_where(tmask[0,:,:,:]==0,f0.variables[var][1,:,:,:])
print(f'{var} max(abs(B-before)):{np.max(np.abs(x2-x0))}')
GRMICZDIAT max(abs(B-before)):0.0 GRMICZMRUB max(abs(B-before)):1.641666358409566e-08 GRMICZPHY max(abs(B-before)):3.573268259060569e-08 GRMICZPON max(abs(B-before)):5.4090691037345096e-08 GRMICZMICZ max(abs(B-before)):8.817596608423628e-08
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fP0b.variables['vosaline'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fP2.variables['vosaline'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
fP2.variables['vosaline'][0,0,:,:]-fP0b.variables['vosaline'][0,0,:,:]),
vmin=-1e-4,vmax=1e-4,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83d03f7220>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc0.variables['diatoms'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc2.variables['diatoms'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
fptrc2.variables['diatoms'][0,0,:,:]-fptrc0.variables['diatoms'][0,0,:,:]),
vmin=-1e-4,vmax=1e-4,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83d0246610>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc0.variables['flagellates'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc2.variables['flagellates'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
fptrc2.variables['flagellates'][0,0,:,:]-fptrc0.variables['flagellates'][0,0,:,:]),
vmin=-1e-5,vmax=1e-5,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83d00609d0>
fig,ax=plt.subplots(1,3,figsize=(14,6))
m0=ax[0].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc0.variables['microzooplankton'][0,0,:,:]))
fig.colorbar(m0,ax=ax[0])
m1=ax[1].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,fptrc2.variables['microzooplankton'][0,0,:,:]))
fig.colorbar(m1,ax=ax[1])
m2=ax[2].pcolormesh(np.ma.masked_where(tmask[0,0,:,:]==0,
fptrc2.variables['microzooplankton'][0,0,:,:]-fptrc0.variables['microzooplankton'][0,0,:,:]),
vmin=-1e-5,vmax=1e-5,
cmap=cmocean.cm.balance)
fig.colorbar(m2,ax=ax[2])
<matplotlib.colorbar.Colorbar at 0x7f83b77c22b0>