Production template

Salish Sea NEMO Model Daily Nowcast Figures for Sea Surface Height

Set-up

In [1]:
from __future__ import division

import datetime
from glob import glob
import os

from IPython.core.display import HTML
import netCDF4 as nc
import scipy.io as sio

from salishsea_tools.nowcast import figures

%matplotlib inline
In [2]:
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])
In [3]:
run_date = datetime.datetime(2015,11,20)
# Results dataset location
results_home = '/results/SalishSea/nowcast/'
results_dir = os.path.join(results_home, run_date.strftime('%d%b%y').lower())
# model winds
model_path = '/ocean/sallen/allen/research/MEOPAR/Operational/'
coastline = sio.loadmat('/ocean/rich/more/mmapbase/bcgeo/PNW.mat')

Load the results datasets:

In [4]:
grid_T_hr = results_dataset('1h', 'grid_T', results_dir)

grids={}
names = ['Point Atkinson', 'Victoria', 'Campbell River', 'Nanaimo', 'Cherry Point', 'Neah Bay', 'Friday Harbor']
for name in names:
    f = os.path.join(results_dir,'{}.nc'.format(name.replace(" ", "")))
    print(f)
    grids[name] = nc.Dataset(f)
/results/SalishSea/nowcast/20nov15/PointAtkinson.nc
/results/SalishSea/nowcast/20nov15/Victoria.nc
/results/SalishSea/nowcast/20nov15/CampbellRiver.nc
/results/SalishSea/nowcast/20nov15/Nanaimo.nc
/results/SalishSea/nowcast/20nov15/CherryPoint.nc
/results/SalishSea/nowcast/20nov15/NeahBay.nc
/results/SalishSea/nowcast/20nov15/FridayHarbor.nc
In [5]:
bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')

Display the figures:

In [6]:
HTML('<h2>{:%d%b%y} Figures</h2>'.format(run_date))
Out[6]:

20Nov15 Figures

Point Atkinson water levels

In [7]:
fig = figures.PA_tidal_predictions(grid_T_hr)

Tidal predictions calculated with t_tide: http://www.eos.ubc.ca/~rich/#T_Tide

In [8]:
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name = "Victoria")
In [9]:
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path)
In [10]:
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name="Campbell River")
In [11]:
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name="Nanaimo")