#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('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/bathy_meter_SalishSea2.nc') # # October 2016 # In[3]: fig, ax = plt.subplots(1,1, figsize=(16,12)) ax.pcolormesh(grid.variables['Bathymetry'][:]) 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)) # In[4]: Oct = nc.Dataset('/ocean/vdo/MEOPAR/ariane-runs/Oct16/ariane_trajectories_qualitative.nc') latt = Oct.variables['traj_lat'] lont = Oct.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 6: index_deep_particles.append(n) # In[18]: 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 6) in Domain at time = x') ax.set_ylabel('Number of Particles') ax.set_xlabel('Time') # In[22]: index_shallow_particles=[] for n in range(2694): if Oct.variables['init_z'][n] < 6: index_shallow_particles.append(n) # In[23]: 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