Forecast 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(2014,12,7)
# Results dataset location
results_home = '/ocean/sallen/allen/research/MEOPAR/SalishSea/forecast/'
results_dir = os.path.join(results_home, run_date.strftime('%d%b%y').lower())
# model winds
model_path='/ocean/sallen/allen/research/MEOPAR/Operational/fcst/'
Load the results datasets:
grid_T_hr = results_dataset('1h', 'grid_T', results_dir)
bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
Display the figures:
HTML('<h2>{:%d%b%y} Forecast 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, model_path, name='Victoria')
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, model_path)
fig = figures.compare_tidalpredictions_maxSSH(grid_T_hr, bathy, model_path, name='Campbell River')
Observed water levels and tidal predictions are from NOAA: http://tidesandcurrents.noaa.gov/stations.html?type=Water+Levels
fig = figures.compare_water_levels(grid_T_hr, bathy,PST=1)
fig = figures.plot_thresholds_all(grid_T_hr, bathy, model_path)
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)
reload(figures)
fig = figures.average_winds_at_station(grid_T_hr, bathy, model_path, station = 'all')
reload(figures)
fig = figures.winds_at_max_ssh(grid_T_hr, bathy, model_path, station = 'all')