In [1]:
import netCDF4 as nc
import numpy as np 
import matplotlib.pyplot as plt
import datetime as dt
import cmocean
import datetime
from salishsea_tools import nc_tools, viz_tools
%matplotlib inline
In [2]:
import matplotlib as mpl
mpl.rcParams['font.size'] = 18
mpl.rcParams['axes.titlesize'] = 18
In [43]:
from IPython.display import HTML

HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
Out[43]:
In [3]:
f2015top = nc.Dataset('/data/vdo/MEOPAR/sum_grme/seasonal-30_2015.nc')
f2016top = nc.Dataset('/data/vdo/MEOPAR/sum_grme/seasonal-30_2016.nc')
f2017top = nc.Dataset('/data/vdo/MEOPAR/sum_grme/seasonal-30_2017.nc')
In [4]:
t_averages = (f2015top.variables['sum_grme'][:] 
              + f2016top.variables['sum_grme'][:]
              + f2017top.variables['sum_grme'][:])/3
In [5]:
mesh = nc.Dataset('/data/vdo/MEOPAR/NEMO-forcing/grid/mesh_mask201702.nc')
In [6]:
for n in range(4):
    i = np.ma.masked_array(t_averages[n,...],
                                           mask = 1 - mesh.variables['tmask'][0,22,...])
    print(i.min(), i.max())
7.250799e-15 3.1437085e-06
2.8840498e-07 4.8871366e-06
5.0071804e-07 9.225224e-06
2.3591751e-07 5.050452e-06

GRMESZDIAT + GRMESZMRUB + GRMESZPHY + GRMESZPON + GRMESZMICZ

In [13]:
fig, axs = plt.subplots(1,4,figsize = (30,10))
s = axs[0].pcolormesh(np.ma.masked_array(t_averages[0,...],
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.tempo, vmin = 0, vmax = 0.00001
                     )
fig.colorbar(s, ax=axs[0])
viz_tools.set_aspect(axs[0])
axs[0].set_title('Winter Averaged')

s = axs[1].pcolormesh(np.ma.masked_array(t_averages[1,...],
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.tempo, vmin = 0, vmax = 0.00001
                     )
fig.colorbar(s, ax=axs[1])
viz_tools.set_aspect(axs[1])
axs[1].set_title('Spring Averaged')

s = axs[2].pcolormesh(np.ma.masked_array(t_averages[2,...],
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.tempo, vmin = 0, vmax = 0.00001
                     )
fig.colorbar(s, ax=axs[2])
viz_tools.set_aspect(axs[2])
axs[2].set_title('Summer Averaged')

s = axs[3].pcolormesh(np.ma.masked_array(t_averages[3,...],
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.tempo, vmin = 0, vmax = 0.00001
                     )
fig.colorbar(s, ax=axs[3])
viz_tools.set_aspect(axs[3])
axs[3].set_title('Fall Averaged');
/home/vdo/anaconda3/lib/python3.6/site-packages/matplotlib/colors.py:861: RuntimeWarning: overflow encountered in true_divide
  resdat /= (vmax - vmin)
In [17]:
fig, axs = plt.subplots(1,4,figsize = (30,10))

s = axs[0].pcolormesh(np.ma.masked_array(f2015top.variables['sum_grme'][0,...] 
                                           - t_averages[0,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[0])
viz_tools.set_aspect(axs[0])
axs[0].set_title('Winter, 2015')

s = axs[1].pcolormesh(np.ma.masked_array(f2015top.variables['sum_grme'][1,...] 
                                           - t_averages[1,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[1])
viz_tools.set_aspect(axs[1])
axs[1].set_title('Spring, 2015 - averaged')

s = axs[2].pcolormesh(np.ma.masked_array(f2015top.variables['sum_grme'][2,...] 
                                           - t_averages[2,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[2])
viz_tools.set_aspect(axs[2])
axs[2].set_title('Summer, 2015 - averaged')

s = axs[3].pcolormesh(np.ma.masked_array(f2015top.variables['sum_grme'][3,...] 
                                           - t_averages[3,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[3])
viz_tools.set_aspect(axs[3])
axs[3].set_title('Fall, 2015 - averaged');
/home/vdo/anaconda3/lib/python3.6/site-packages/matplotlib/colors.py:861: RuntimeWarning: overflow encountered in true_divide
  resdat /= (vmax - vmin)
In [18]:
fig, axs = plt.subplots(1,4,figsize = (30,10))

s = axs[0].pcolormesh(np.ma.masked_array(f2016top.variables['sum_grme'][0,...] 
                                           - t_averages[0,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[0])
viz_tools.set_aspect(axs[0])
axs[0].set_title('Winter, 2016')

s = axs[1].pcolormesh(np.ma.masked_array(f2016top.variables['sum_grme'][1,...] 
                                           - t_averages[1,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[1])
viz_tools.set_aspect(axs[1])
axs[1].set_title('Spring, 2016 - averaged')

s = axs[2].pcolormesh(np.ma.masked_array(f2016top.variables['sum_grme'][2,...] 
                                           - t_averages[2,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[2])
viz_tools.set_aspect(axs[2])
axs[2].set_title('Summer, 2016 - averaged')

s = axs[3].pcolormesh(np.ma.masked_array(f2016top.variables['sum_grme'][3,...] 
                                           - t_averages[3,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[3])
viz_tools.set_aspect(axs[3])
axs[3].set_title('Fall, 2016 - averaged');
/home/vdo/anaconda3/lib/python3.6/site-packages/matplotlib/colors.py:861: RuntimeWarning: overflow encountered in true_divide
  resdat /= (vmax - vmin)
In [19]:
fig, axs = plt.subplots(1,4,figsize = (30,10))

s = axs[0].pcolormesh(np.ma.masked_array(f2017top.variables['sum_grme'][0,...] 
                                           - t_averages[0,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[0])
viz_tools.set_aspect(axs[0])
axs[0].set_title('Winter, 2017')

s = axs[1].pcolormesh(np.ma.masked_array(f2017top.variables['sum_grme'][1,...] 
                                           - t_averages[1,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[1])
viz_tools.set_aspect(axs[1])
axs[1].set_title('Spring, 2017 - averaged')

s = axs[2].pcolormesh(np.ma.masked_array(f2017top.variables['sum_grme'][2,...] 
                                           - t_averages[2,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[2])
viz_tools.set_aspect(axs[2])
axs[2].set_title('Summer, 2017 - averaged')

s = axs[3].pcolormesh(np.ma.masked_array(f2017top.variables['sum_grme'][3,...] 
                                           - t_averages[3,...], 
                                           mask = 1 - mesh.variables['tmask'][0,22,...]), 
                        cmap = cmocean.cm.balance, vmin = -0.000001, vmax = 0.000001)
fig.colorbar(s, ax=axs[3])
viz_tools.set_aspect(axs[3])
axs[3].set_title('Fall, 2017 - averaged');
/home/vdo/anaconda3/lib/python3.6/site-packages/matplotlib/colors.py:861: RuntimeWarning: overflow encountered in true_divide
  resdat /= (vmax - vmin)