What are the mechanisms that cause mixing the the sill region? Other literature suggests
Can we find evidence of these features in the model?
import netCDF4 as nc
import matplotlib.pyplot as plt
import numpy as np
import datetime
import os
from nowcast import figures
from salishsea_tools import viz_tools
%matplotlib inline
def results_dataset(time, date, grid, mode):
fname = 'SalishSea_{}_{}_{}_{}.nc'.format(time, date.strftime('%Y%m%d'),
date.strftime('%Y%m%d'), grid)
results= '/results/SalishSea/{}/'.format(mode)
subdir=date.strftime('%d%b%y').lower()
path = os.path.join(results,subdir,fname)
dataset = nc.Dataset(path)
return dataset
d = datetime.datetime(2015,7,27)
grid_t = results_dataset('1h',d,'grid_T','nowcast')
grid_u = results_dataset('1h',d,'grid_U','nowcast')
grid_v = results_dataset('1h',d,'grid_V','nowcast')
lons=grid_t.variables['nav_lon'][:]
lats=grid_t.variables['nav_lat'][:]
mesh = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/mesh_mask_SalishSea2.nc')
grid_B = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
tmask = mesh.variables['tmask'][:]
tmask = 1-tmask
umask = mesh.variables['umask'][:]
umask = 1-umask
vmask = mesh.variables['vmask'][:]
vmask = 1-vmask
tidal_predictions='/data/nsoontie/MEOPAR/tools/SalishSeaNowcast/tidal_predictions/'
fig=figures.PA_tidal_predictions(grid_t,tidal_predictions,PST=0)
sal = grid_t.variables['vosaline'][:]
tmask = tmask +np.zeros(sal.shape)
lines = np.loadtxt('/data/nsoontie/MEOPAR/tools/bathymetry/thalweg_working.txt',delimiter=' ', dtype=int)
depth = grid_t.variables['deptht'][:]
sal = np.ma.masked_array(sal,mask=tmask)
times = grid_t.variables['time_counter']
dates= nc.num2date(times[:],times.units)
u = grid_u.variables['vozocrtx'][:]
umask = umask +np.zeros(u.shape)
depthu = grid_u.variables['depthu'][:]
u = np.ma.masked_array(u,mask=umask)
v = grid_v.variables['vomecrty'][:]
vmask = vmask +np.zeros(v.shape)
depthv = grid_v.variables['depthv'][:]
v = np.ma.masked_array(v,mask=vmask)
def plot_thalweg(ax, t, sal, dates, lines, depth,smin=20,smax=34,ylim=[430,0],xlim=[0,1000]):
salP=sal[t,:,lines[:,0],lines[:,1]]
mesh=ax.pcolormesh(np.arange(salP.shape[0]),depth,salP.T,vmin=smin,vmax=smax)
CS = ax.contour(np.arange(salP.shape[0]),depth,salP.T,[29,30,31],colors='k')
plt.clabel(CS)
cbar = plt.colorbar(mesh,ax=ax)
cbar.set_label('Salinity [psu]')
cbar.add_lines(CS)
ax.set_ylim(ylim)
ax.set_xlim(xlim)
ax.set_ylabel('Depth [m]')
ax.set_title(dates[t].strftime('%d-%b-%Y %H:%M'))
fig,axs = plt.subplots(12,2,figsize=(20,24))
for t, ax in zip(np.arange(0,sal.shape[0]),axs.flat):
plot_thalweg(ax,t,sal,dates,lines,depth)
def hovmoller_depth(ax,var,varname,depth,times,thalweg_points, index, title,ylim=[250,0],smin=-1,smax=1):
varP=var[:,:,thalweg_points[:,0],thalweg_points[:,1]]
varP = varP[:,:, index]
mesh=ax.pcolormesh(times,depth,varP.T,vmin=smin, vmax=smax)
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label(varname)
ax.set_ylim(ylim)
ax.set_ylabel('depth [m]')
ax.set_title('{} at thalweg index {}'.format(title, index))
fig,axs=plt.subplots(3,1,figsize=(10,10))
smin,smax=-1,1
ind=600
ax=axs[0]
hovmoller_depth(ax,u,'u [m/s]',depthu, dates, lines, ind, 'NEMO u velocity',smin=smin,smax=smax)
ax=axs[1]
hovmoller_depth(ax,v,'v [m/s]',depthv, dates, lines, ind, 'NEMO v velocity',smin=smin,smax=smax)
ax=axs[2]
smin,smax=28,31
hovmoller_depth(ax,sal,'Salinity [psu]',depth, dates, lines, ind, 'Salinity',smin=smin,smax=smax)
fig,ax=plt.subplots(1,1)
viz_tools.plot_coastline(ax,grid_B,coords='map')
ax.plot(lons[lines[ind,0], lines[ind,1]], lats[lines[ind,0],lines[ind,1]],'o')
[<matplotlib.lines.Line2D at 0x7f3c3c190b38>]
Idea:
fig,axs=plt.subplots(3,1,figsize=(10,10))
smin,smax=-1,1
ind=400
ax=axs[0]
hovmoller_depth(ax,u,'u [m/s]',depthu, dates, lines, ind, 'NEMO u velocity',smin=smin,smax=smax)
ax=axs[1]
hovmoller_depth(ax,v,'v [m/s]',depthv, dates, lines, ind, 'NEMO v velocity',smin=smin,smax=smax)
ax=axs[2]
smin,smax=28,34
hovmoller_depth(ax,sal,'Salinity [psu]',depth, dates, lines, ind, 'Salinity',smin=smin,smax=smax)
fig,ax=plt.subplots(1,1)
viz_tools.plot_coastline(ax,grid_B,coords='map')
ax.plot(lons[lines[ind,0], lines[ind,1]], lats[lines[ind,0],lines[ind,1]],'o')
[<matplotlib.lines.Line2D at 0x7f3c376f73c8>]
fig,axs=plt.subplots(3,1,figsize=(10,10))
smin,smax=-1,1
ind=500
ax=axs[0]
hovmoller_depth(ax,u,'u [m/s]',depthu, dates, lines, ind, 'NEMO u velocity',smin=smin,smax=smax)
ax=axs[1]
hovmoller_depth(ax,v,'v [m/s]',depthv, dates, lines, ind, 'NEMO v velocity',smin=smin,smax=smax)
ax=axs[2]
smin,smax=28,32
hovmoller_depth(ax,sal,'Salinity [psu]',depth, dates, lines, ind, 'Salinity',smin=smin,smax=smax)
fig,ax=plt.subplots(1,1)
viz_tools.plot_coastline(ax,grid_B,coords='map')
ax.plot(lons[lines[ind,0], lines[ind,1]], lats[lines[ind,0],lines[ind,1]],'o')
[<matplotlib.lines.Line2D at 0x7f3c63b072b0>]