Template for daily nowcast figure generation.
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.date.today()
run_date = datetime.datetime(2014,11,19)
# 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_hr = results_dataset('1h', 'grid_T', results_dir)
grid_T_dy = results_dataset('1d', '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')
Display the figures:
HTML('<h2>{:%d%b%y} Figures</h2>'.format(run_date))
fig = figures.ssh_PtAtkinson(grid_T_hr)
fig = figures.PA_tidal_predictions(grid_T_hr)
fig = figures.compare_tidal_predictions('Point Atkinson', grid_T_hr, bathy)
fig = figures.compare_water_levels('NeahBay', grid_T_hr, bathy)
fig = figures.compare_water_levels('CherryPoint', grid_T_hr, bathy)
fig = figures.compare_water_levels('FridayHarbor', grid_T_hr, bathy)
fig = figures.PA_max_ssh(grid_T_hr,bathy)
fig = figures.Sandheads_winds(grid_T_hr)
reload(figures)
<module 'salishsea_tools.nowcast.figures' from '/ocean/imachuca/MEOPAR/tools/SalishSeaTools/salishsea_tools/nowcast/figures.py'>
fig = figures.thalweg_salinity(grid_T_dy)
fig = figures.plot_surface(grid_T_dy, grid_U_dy, grid_V_dy, bathy)