In [34]:
import netCDF4 as nc
import numpy as np
import matplotlib.pyplot as plt
from salishsea_tools import viz_tools, tidetools, geo_tools
from matplotlib import animation, rc
%matplotlib inline
In [38]:
particles = nc.Dataset('/ocean/vdo/MEOPAR/ariane-runs/NanimoOilSpill/ariane_trajectories_qualitative.nc')
In [39]:
rc('animation', html='html5')
In [40]:
Bathy = nc.Dataset('/data/vdo/MEOPAR/NEMO-forcing/grid/bathymetry_201702.nc')
In [118]:
test3 = nc.Dataset('/ocean/vdo/MEOPAR/ariane-runs/test3/ariane_trajectories_qualitative.nc')
In [122]:
fig, ax = plt.subplots(figsize = (10,10))
def animate(i):
    ax.clear()
    for n in range(45):
        ax.plot(test3.variables['traj_lon'][i, n], 
                test3.variables['traj_lat'][i, n], 'b.')
    viz_tools.plot_coastline(ax, Bathy, coords = 'map')
    viz_tools.set_aspect(ax)
    ax.plot(213, 418, 'r*')
    ax.plot(-123.89095676900132, 49.16340592936349,  'r*')
    ax.set_xlim(-124.3, -123.5)
    ax.set_ylim(49, 49.5)
    ax.set_title('Time = ' + str(i))
interval = 0.25#in seconds
ani40 = animation.FuncAnimation(fig,animate,
                                frames=44,interval=interval*1e+3, repeat=False)
ani40
Out[122]:
In [123]:
test3.variables['final_t'][:]
Out[123]:
array([ 59.  ,  59.25,  59.5 ,  59.75,  60.  ,  59.  ,  59.25,  59.5 ,
        59.75,  60.  ,  59.  ,  59.25,  59.5 ,  59.75,  60.  ,  59.  ,
        59.25,  59.5 ,  59.75,  60.  ,  59.  ,  59.25,  59.5 ,  59.75,
        60.  ,  59.  ,  59.25,  59.5 ,  59.75,  60.  ,  59.  ,  59.25,
        59.5 ,  59.75,  60.  ,  59.  ,  59.25,  59.5 ,  59.75,  60.  ,
        59.  ,  59.25,  59.5 ,  59.75,  60.  ])
In [ ]: