How do tracers work in Ariane?

Ariane only allows for all three tracers - this means that you must add Temperat and Salinity and Density or tell ariane that you want to calculate the density from temperature and salinity.

Add a Temperat and Salinity section. These sections are set up almost exactly like the velocity sections, except that the parameters have different names. The filename you are using will look like SalishSea_30m_20061214_20061215_grid_T.nc. The variable for temperature is votemper and that of salinity is vosaline.

Since the nc file above does not contain density, we will tell Ariane that we want the density to be calculated instead of read. For this, we need to add two new parameters to the Ariane section in the namelist.

Add key_computesigma =.TRUE.,

Add zsigma. This will be the reference depth used to calculate the density.

Lastly, key_alltracers should be =.TRUE.,

Imports

In [2]:
import netCDF4 as NC
import numpy as np

import matplotlib.pyplot as plt
import matplotlib.cm as cm

from salishsea_tools import (nc_tools,viz_tools,tidetools)

%matplotlib inline

Variables

In [3]:
tracers = NC.Dataset('/ocean/nsoontie/MEOPAR/SalishSea/results/storm-surges/final/dec2006/all_forcing/30min/SalishSea_30m_20061214_20061215_grid_U.nc')
nc_tools.show_variables(tracers)
[u'depthu', u'nav_lat', u'nav_lon', u'time_counter', u'time_counter_bnds', u'vozocrtx']
In [4]:
tracers = NC.Dataset('/ocean/nsoontie/MEOPAR/SalishSea/results/storm-surges/final/dec2006/all_forcing/30min/SalishSea_30m_20061214_20061215_grid_V.nc')
nc_tools.show_variables(tracers)
[u'depthv', u'nav_lat', u'nav_lon', u'time_counter', u'time_counter_bnds', u'vomecrty']
In [5]:
tracers = NC.Dataset('/ocean/nsoontie/MEOPAR/SalishSea/results/storm-surges/final/dec2006/all_forcing/30min/SalishSea_30m_20061214_20061215_grid_T.nc')
nc_tools.show_variables(tracers)
ssh=tracers.variables['sossheig']
sal=tracers.variables['vosaline']
temp=tracers.variables['votemper']
[u'deptht', u'nav_lat', u'nav_lon', u'sossheig', u'time_counter', u'time_counter_bnds', u'vosaline', u'votemper']

Data

In [6]:
grid = NC.Dataset('/ocean/imachuca/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc','r')
lats = grid.variables['nav_lat']
lons = grid.variables['nav_lon']
bathy = grid.variables['Bathymetry']
bath, X, Y = tidetools.get_bathy_data(grid)
lons.shape
Out[6]:
(898, 398)
In [7]:
one = NC.Dataset('/ocean/imachuca/MEOPAR/Ariane/results/tracers/thalweg/ariane_trajectories_qualitative.nc','r')
nc_tools.show_variables(one)
lon1=one.variables['traj_lon']
lat1=one.variables['traj_lat']
dep1=one.variables['traj_depth']
x1=one.variables['init_x']
y1=one.variables['init_y']
t1=one.variables['traj_time']
[u'init_x', u'init_y', u'init_z', u'init_t', u'init_age', u'init_transp', u'final_x', u'final_y', u'final_z', u'final_t', u'final_age', u'final_transp', u'traj_lon', u'traj_lat', u'traj_depth', u'traj_time']
In [8]:
two = NC.Dataset('/ocean/imachuca/MEOPAR/Ariane/results/tracers/thalweg/withtracers/ariane_trajectories_qualitative.nc','r')
nc_tools.show_variables(two)
lon2=two.variables['traj_lon']
lat2=two.variables['traj_lat']
dep2=two.variables['traj_depth']
x2=two.variables['init_x']
y2=two.variables['init_y']
t2=two.variables['traj_time']

temp2=two.variables['traj_temp']
salt2=two.variables['traj_salt']
dens2=two.variables['traj_dens']
[u'init_x', u'init_y', u'init_z', u'init_t', u'init_age', u'init_transp', u'final_x', u'final_y', u'final_z', u'final_t', u'final_age', u'final_transp', u'traj_lon', u'traj_lat', u'traj_depth', u'traj_time', u'traj_temp', u'traj_salt', u'traj_dens']
In [9]:
three = NC.Dataset('/ocean/imachuca/MEOPAR/Ariane/results/tracers/wedgepart/ariane_trajectories_qualitative.nc','r')
nc_tools.show_variables(three)
lon3=three.variables['traj_lon']
lat3=three.variables['traj_lat']
dep3=three.variables['traj_depth']
x3=three.variables['init_x']
y3=three.variables['init_y']
t3=three.variables['traj_time']

temp3=three.variables['traj_temp']
salt3=three.variables['traj_salt']
dens3=three.variables['traj_dens']
[u'init_x', u'init_y', u'init_z', u'init_t', u'init_age', u'init_transp', u'final_x', u'final_y', u'final_z', u'final_t', u'final_age', u'final_transp', u'traj_lon', u'traj_lat', u'traj_depth', u'traj_time', u'traj_temp', u'traj_salt', u'traj_dens']

Closer Look

River particle, December 14-15, 2006, 30 minute input and output, confined, 2 day trajectory, time 0.5

/ocean/nsoontie/MEOPAR/SalishSea/results/storm-surges/final/dec2006/all_forcing/30min/

In [10]:
lons = [lon1,lon2]
lats = [lat1, lat2]
titles = ['Surface particle - without tracers','Surface particle - with tracers']

fig, axs = plt.subplots(1,2,figsize=(20,7))

for ax,lon,lat,title in zip(axs,lons,lats,titles):
    viz_tools.plot_land_mask(ax,grid,coords='map')
    ax.set_xlim([-123.5,-123])
    ax.set_ylim([48.96,49.17])

    ax.set_title(title)
    ax.set_xlabel('lon')
    ax.set_ylabel('lat')

    ax.scatter(lon[1:,:],lat[1:,:],color='Sienna', marker='.', )
    ax.scatter(lon[0,:],lat[0,:],color='red',marker='s')
    ax.annotate('12',(lon[23,:],lat[23,:]),fontsize=15,color='black')
    ax.annotate('24',(lon[47,:],lat[47,:]),fontsize=15,color='black')
    ax.annotate('36',(lon[71,:],lat[71,:]),fontsize=15,color='black')
    ax.annotate('48',(lon[95,:],lat[95,:]),fontsize=15,color='black')
    
#

tracers = [temp,sal]
tracers2 = [temp2,salt2]
titles = ['Ariane: Temperature','Ariane: Salinity']
titles2 = ['Model: Temperature at t=0','Model: Salinity at t=0']
units = ['degC','psu']

fig, axs = plt.subplots(2,2,figsize=(20,14))

for ax,tracer2,title,unit in zip(axs[:,0],tracers2,titles,units):
    ax.plot(t2[0,:]*48,tracer2[0,:],'.r')
    ax.plot(t2[1:,:]*48,tracer2[1:,:],'.',color='Sienna')
    ax.annotate('12',(t2[23,:]*48,tracer2[23,:]),fontsize=15,color='black')
    ax.annotate('24',(t2[47,:]*48,tracer2[47,:]),fontsize=15,color='black')
    ax.annotate('36',(t2[71,:]*48,tracer2[71,:]),fontsize=15,color='black')
    ax.annotate('48',(t2[95,:]*48,tracer2[95,:]),fontsize=15,color='black')
      
    ax.set_title(title)
    ax.set_xlabel('hours')
    ax.set_ylabel(unit)
    
grid = NC.Dataset('../../NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
lats = grid.variables['nav_lat']
lons = grid.variables['nav_lon']

for ax,tracer,title2 in zip(axs[:,1],tracers,titles2):
    viz_tools.set_aspect(ax, coords='map', lats=lats)
    cmap = plt.cm.get_cmap("ocean")
    viz_tools.plot_coastline(ax, grid, coords='map')
    
    contour_fills = ax.contourf(lons, lats, tracer[0,0,:,:],cmap=cmap)
    cbar = plt.colorbar(contour_fills,ax=ax)

    ax.set_xlim([-123.5,-123])
    ax.set_ylim([48.96,49.17])
    ax.set_title(title2)
    

    ax.scatter(lon2[1:,:],lat2[1:,:],color='White', marker='.', )
    ax.scatter(lon2[0,:],lat2[0,:],color='red',marker='s')
    ax.annotate('12',(lon2[23,:],lat2[23,:]),fontsize=15,color='black')
    ax.annotate('24',(lon2[47,:],lat2[47,:]),fontsize=15,color='black')
    ax.annotate('36',(lon2[71,:],lat2[71,:]),fontsize=15,color='black')
    ax.annotate('48',(lon2[95,:],lat2[95,:]),fontsize=15,color='black')

#

fig, ax1 = plt.subplots(1,1,figsize=(9,6))
ax1.plot(t2[0,:]*48,dens2[0,:],'.r')
ax1.plot(t2[1:,:]*48,dens2[1:,:],'.',color='Sienna')
ax1.annotate('12',(t2[23,:]*48,dens2[23,:]),fontsize=15,color='black')
ax1.annotate('24',(t2[47,:]*48,dens2[47,:]),fontsize=15,color='black')
ax1.annotate('36',(t2[71,:]*48,dens2[71,:]),fontsize=15,color='black')
ax1.annotate('48',(t2[95,:]*48,dens2[95,:]),fontsize=15,color='black')
ax1.set_title('Density calculated by Ariane using temperature and salinity')
Out[10]:
<matplotlib.text.Text at 0x7f14b4573390>

Replotting for docs

In [23]:
fig, axs = plt.subplots(1,3,figsize=(21,6))
tracers = [temp2,salt2,dens2]
titles = ['Temperature','Salinity','Density']
for tracer,ax,title in zip(tracers,axs,titles):
    ax.plot(t2[0,:]*48,tracer[0,:],'.r',markersize=15)
    ax.plot(t2[1:,:]*48,tracer[1:,:],'-',color='Sienna')
    ax.set_title(title)
    ax.set_ylabel('NEMO unit')
    ax.set_xlabel('time [hr]')
    
fig.savefig('result_tracers_doc.png')

Salt wedge particle

In [12]:
fig, (ax1,ax2) = plt.subplots(1,2,figsize=(22,10))

land_colour = 'burlywood'
viz_tools.plot_land_mask(ax1,grid,coords='map',color=land_colour)
ax1.set_xlim([-123.25,-123.05])
ax1.set_ylim([49.04,49.14])

ax1.set_title('Particle at 3 m')
ax1.set_xlabel('lon')
ax1.set_ylabel('lat')

ax1.scatter(lon3[0,:],lat3[0,:],color='black',marker='s')
ax1.scatter(lon3[1:23:1,:],lat3[1:23:1,:],color='red', marker='o', )
ax1.scatter(lon3[22:30:1,:],lat3[22:30:1,:],color='OrangeRed', marker='o', )
ax1.scatter(lon3[29:47:1,:],lat3[29:47:1,:],color='Gold', marker='o', )
ax1.scatter(lon3[46:52:1,:],lat3[46:52:1,:],color='DarkGreen', marker='o', )
ax1.scatter(lon3[51:67:1,:],lat3[51:67:1,:],color='Dodgerblue', marker='o', )
ax1.scatter(lon3[66:,:],lat3[66:,:],color='DarkViolet', marker='o' )


ax2.plot(t3[0,:]*48,salt3[0,:],'.k')
ax2.plot(t3[1:23:1,:]*48,salt3[1:23:1,:],'-o',color='red')
ax2.plot(t3[22:30:1,:]*48,salt3[22:30:1,:],'-o',color='OrangeRed')
ax2.plot(t3[29:47:1,:]*48,salt3[29:47:1,:],'-o',color='Gold')
ax2.plot(t3[46:52:1,:]*48,salt3[46:52:1,:],'-o',color='DarkGreen')
ax2.plot(t3[51:67:1,:]*48,salt3[51:67:1,:],'-o',color='Dodgerblue')
ax2.plot(t3[66:,:]*48,salt3[66:,:],'-o',color='DarkViolet')

ax2.set_xlim(0,50)
ax2.set_ylim(0,14)
ax2.set_title('Ariane Salinity')
ax2.set_xlabel('hours')
ax2.set_ylabel('psu')
Out[12]:
<matplotlib.text.Text at 0x7f14b43babd0>