Reasearch figures template
from __future__ import division
import datetime
from glob import glob
import os
from IPython.core.display import HTML
import netCDF4 as nc
from salishsea_tools.nowcast import figures
%matplotlib inline
def results_dataset(period, grid, results_dir):
"""Return the results dataset for period (e.g. 1h or 1d)
and grid (e.g. grid_T, grid_U) from results_dir.
"""
filename_pattern = 'SalishSea_{period}_*_{grid}.nc'
filepaths = glob(os.path.join(results_dir, filename_pattern.format(period=period, grid=grid)))
return nc.Dataset(filepaths[0])
run_date = datetime.datetime(2015,10,20)
# Results dataset location
results_home = '/data/dlatorne/MEOPAR/SalishSea/nowcast/'
results_dir = os.path.join(results_home, run_date.strftime('%d%b%y').lower())
Load the results datasets:
grid_T_dy = results_dataset('1d', 'grid_T', results_dir)
grid_T_hr = results_dataset('1h', 'grid_T', results_dir)
grid_U_dy = results_dataset('1d', 'grid_U', results_dir)
grid_V_dy = results_dataset('1d', 'grid_V', results_dir)
bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
mesh_mask = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid//mesh_mask_SalishSea2.nc')
Display the figures:
HTML('<h2>{:%d%b%y} Figures</h2>'.format(run_date))
To do: Remove this section and add to TracersCurrents_Template.ipynb
#reload(figures)
fig = figures.thalweg_salinity(grid_T_dy, mesh_mask, bathy)
#reload(figures)
fig = figures.thalweg_temperature(grid_T_dy, mesh_mask, bathy)
fig = figures.plot_surface(grid_T_dy, grid_U_dy, grid_V_dy, bathy)
xmin=0, xmax=398, ymin=0, ymax=898