A notebook to summarize a large particle release experiment.
Three particle-release experiments where undertaken.
All particle trajectories were initialized on June 1, 2015 and integrated until Jul 31, 2015. Velocity fields from houlr nowcasts.
import netCDF4 as nc
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import animation
import pandas as pd
import datetime
import os
from salishsea_tools import viz_tools
%matplotlib inline
sns.set_color_codes()
grid_B=nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
data=nc.Dataset('/data/dlatorne/MEOPAR/SalishSea/nowcast/01jul15/SalishSea_1d_20150701_20150701_grid_T.nc')
depth = data.variables['deptht'][:]
runs = ['SoG_surface', 'SoG_intermediate', 'JDF']
path = '/ocean/nsoontie/MEOPAR/Ariane/results/2month-summer/'
init_x={}; init_y={}; init_z={}
final_x={}; final_y={}; final_z={}; final_t={}; final_age={}; z={}
t_lon={}; t_lat={}; t_depth={}; t_time={};
for run in runs:
f = nc.Dataset(os.path.join(path,run,'ariane_trajectories_qualitative.nc'))
init_x[run] = f.variables['init_x']
init_y[run] = f.variables['init_y']
init_z[run]= f.variables['init_z']
final_x[run] = f.variables['final_x']
final_y[run] = f.variables['final_y']
final_z[run] = f.variables['final_z']
final_age[run] = f.variables['final_age']
final_t[run] = f.variables['final_t']
z[run]=np.array(final_z[run][:],dtype=int)
t_lat[run] = f.variables['traj_lat']
t_lon[run] = f.variables['traj_lon']
t_depth[run] = f.variables['traj_depth']
t_time[run] = f.variables['traj_time']
fig,axs = plt.subplots(1,3,figsize=(15,6))
for run,ax in zip(runs, axs):
ax.plot(init_x[run],init_y[run],'bo')
viz_tools.plot_coastline(ax,grid_B)
ax.set_title(run)
fig,axs = plt.subplots(1,3,figsize=(15,6))
cmap = sns.cubehelix_palette( as_cmap=True)
for run,ax in zip(runs, axs):
mesh=ax.scatter(final_x[run],final_y[run],c=depth[z[run]],vmin=0,vmax=300,cmap=cmap)
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('Depth [m]')
viz_tools.plot_coastline(ax,grid_B)
ax.set_title(run)
fig,axs = plt.subplots(1,3,figsize=(15,6))
cmap = sns.cubehelix_palette( as_cmap=True)
for run,ax in zip(runs, axs):
hist,xedges,yedges = np.histogram2d(t_lon[run][:].flatten(),t_lat[run][:].flatten()
,bins=100,range=[[-126,-122],[47,50.5]])
hist=np.ma.masked_values(hist,0)
mesh = ax.pcolormesh(xedges,yedges,hist.T,shading='flat',cmap=cmap,vmin=0,vmax=8000)
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('Number of particles in bin')
viz_tools.plot_coastline(ax,grid_B,coords='map')
ax.set_title(run)