In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import netCDF4 as nc
import numpy as np
import matplotlib.patches as patches
from salishsea_tools import viz_tools, geo_tools, tidetools
from bathy_helpers import *
import matplotlib.path as mpltPath
from fast_ll2ij_SalishSea201702 import *
In [2]:
grid = nc.Dataset('/data/vdo/MEOPAR/NEMO-forcing/grid/bathymetry_201702.nc')
In [6]:
fig, ax = plt.subplots(1,1, figsize=(16,12))
bathy = ax.contourf(grid.variables['Bathymetry'][:], levels = np.arange(0,60, 10))
ax.set_ylim(590,670)
ax.set_xlim(115,135)
viz_tools.set_aspect(ax)
ax.add_patch(patches.Rectangle((118,598), 15, 59, fill=False, linewidth=3))
fig.colorbar(bathy, ax=ax)
Out[6]:
<matplotlib.colorbar.Colorbar at 0x7fcad2d7b860>
In [4]:
result = nc.Dataset('/ocean/vdo/MEOPAR/ariane-runs/Apr17/ariane_trajectories_qualitative.nc')
latt = result.variables['traj_lat']
lont = result.variables['traj_lon']
bathy, lons, lats = tidetools.get_bathy_data(grid)
mask = lont[:].mask
In [5]:
def still_inside(time, number):
    number_of_particles = np.zeros(time)
    for n in range(time):
        for m in range(number):
            if (mask[n,m]) == False:
                y,x = fast_ll2ij_SalishSea201702(lont[n,m],latt[n,m],lons, lats)
                if (598<y<658) and (118<x<134):
                    number_of_particles[n] = number_of_particles[n] + 1
    return number_of_particles
In [6]:
op = still_inside(720, 2694)
In [7]:
fig,ax=plt.subplots(1,1,figsize=(8,6))
time = range(720)
ax.plot(time, op)
ax.grid('on')
ax.set_title('Number of Particles in Domain', fontsize=16)
ax.set_ylabel('Number of Particles', fontsize=14)
ax.set_xlabel('Time (h)', fontsize=14)
ax.tick_params(labelsize=12)
In [9]:
index_deep_particles=[]
d = result.variables['init_z']
for n in range(2694):
    if d[n] > 6:
        index_deep_particles.append(n)
In [12]:
mask = lont[:].mask
def deep_particles(time, index):
    number_of_deep_particles = np.zeros(time)
    for n in range(time):
        for m in index:
            if (mask[n,m]) == False: 
                y,x = fast_ll2ij_SalishSea201702(lont[n,m],latt[n,m],lons, lats)
                if (598<y<658) and (118<x<134):
                    number_of_deep_particles[n] = number_of_deep_particles[n] + 1
    return number_of_deep_particles
In [13]:
sa = deep_particles(720,index_deep_particles)
In [14]:
fig,ax=plt.subplots(1,1,figsize=(8,6))
time = range(720)
ax.plot(time, sa)
ax.grid('on')
ax.set_title('Number of Particles (init depth > 6) in Domain at time = x')
ax.set_ylabel('Number of Particles')
ax.set_xlabel('Time')
Out[14]:
<matplotlib.text.Text at 0x7f7630ef27f0>
In [20]:
index_shallow_particles=[]
for n in range(2694):
    if result.variables['init_z'][n] < 6:
        index_shallow_particles.append(n)
In [21]:
mask=lont[:].mask
def shallow_particles(time, index):
    number_of_shallow_particles = np.zeros(time)
    for n in range(time):
        for m in index:
            if (mask[n,m]) == False: 
                y,x = fast_ll2ij_SalishSea201702(lont[n,m],latt[n,m],lons, lats)
                if (598<y<658) and (118<x<134):
                    number_of_shallow_particles[n] = number_of_shallow_particles[n] + 1
    return number_of_shallow_particles
In [22]:
sb = shallow_particles(720, index_shallow_particles)
In [23]:
fig,ax=plt.subplots(1,1,figsize=(8,6))
time = range(720)
ax.plot(time, sb)
ax.grid('on')
ax.set_title('Number of Particles (init depth < 6) in Domain at time = x')
ax.set_ylabel('Number of Particles')
ax.set_xlabel('Time')
Out[23]:
<matplotlib.text.Text at 0x7f7630e9d208>
In [ ]: