Production template
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
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,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:
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
bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
Display the figures:
HTML('<h2>{:%d%b%y} Figures</h2>'.format(run_date))
fig = figures.PA_tidal_predictions(grid_T_hr)
Tidal predictions calculated with t_tide: http://www.eos.ubc.ca/~rich/#T_Tide
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name = "Victoria")
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path)
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name="Campbell River")
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, grids, model_path, name="Nanaimo")
Observed water levels from NOAA: http://tidesandcurrents.noaa.gov/stations.html?type=Water+Levels
To do:
fig = figures.compare_water_levels(grid_T_hr, bathy, grids, coastline)
fig = figures.plot_thresholds_all(grid_T_hr, bathy, grids, model_path, coastline)
Fix thresholds
Observations from Environment Canada data. http://climate.weather.gc.ca/
Modelled winds are from the High Resolution Deterministic Prediction System of Environment Canada. https://weather.gc.ca/grib/grib2_HRDPS_HR_e.html
fig = figures.Sandheads_winds(grid_T_hr,bathy,model_path, coastline)
fig = figures.winds_average_max(grid_T_hr, bathy, model_path, coastline, station ='all', wind_type = 'average')
fig = figures.winds_average_max(grid_T_hr, bathy, model_path, coastline, station = 'all', wind_type = 'max')
fig=figures.plot_threshold_website(bathy, grid_T_hr, grids, model_path,coastline)
fig=figures.website_thumbnail(bathy, grid_T_hr, grids, model_path,coastline)