compare_tide_prediction_max_ssh
Module¶Render figure object produced by the nowcast.figures.publish.compare_tide_prediction_max_ssh
module.
Provides data for visual testing to confirm that refactoring has not adversely changed figure for web page.
Set-up and function call replicates as nearly as possible what is done in the nowcast.workers.make_plots
worker.
Notebooks like this should be developed in a
Nowcast Figures Development Environment
so that all of the necessary dependency packages are installed.
The development has to be done on a workstation that has the Salish Sea Nowcast system /results/
parition mounted.
import io
import os
from pathlib import Path
import arrow
import netCDF4 as nc
import requests
import yaml
from salishsea_tools import nc_tools
from nowcast.figures.publish import compare_tide_prediction_max_ssh
%matplotlib inline
The bits of config/nowcast.yaml
that are required:
config = '''
run types:
forecast:
bathymetry: bathymetry_201702.nc
duration: 1.5 # days
forecast2:
bathymetry: bathymetry_201702.nc
duration: 1.25 # days
figures:
dataset URLs:
HRDPS fields: https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSaSurfaceAtmosphereFieldsV1
tide stn ssh time series:
# **Must be quoted to project {} characters**
'https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSf{place}SSH10m'
grid dir: /SalishSeaCast/grid/
ssh:
tidal_predictions: /SalishSeaCast/tidal-predictions/
weather:
ops_dir: /results/forcing/atmospheric/continental2.5/nemo_forcing/
run:
results_archive:
forecast: /results/SalishSea/forecast.201905/
forecast2: /results/SalishSea/forecast2.201905/
'''
config = yaml.safe_load(io.StringIO(config))
run_date = arrow.get('2021-04-08')
run_type = 'forecast'
dmy = run_date.format('DDMMMYY').lower()
start_day = {
'forecast': run_date.shift(days=+1).format('YYYYMMDD'),
'forecast2': run_date.shift(days=+2).format('YYYYMMDD'),
}
end_day = {
'forecast': run_date.shift(days=+2).format('YYYYMMDD'),
'forecast2': run_date.shift(days=+3).format('YYYYMMDD'),
}
ymd = run_date.format('YYYYMMDD')
results_home = Path(config['run']['results_archive'][run_type])
results_dir = results_home/dmy
ssh_fcst_dataset_url_tmpl = config['figures']['dataset URLs']['tide stn ssh time series']
tidal_predictions = Path(config['ssh']['tidal_predictions'])
forecast_hrs = int(config['run types'][run_type]['duration'] * 24)
weather_path = Path(config['weather']['ops_dir'], 'fcst')
grid_dir = Path(config['figures']['grid dir'])
bathy = nc.Dataset(grid_dir / config['run types'][run_type]['bathymetry'])
grid_T_hr_path = results_dir/f'SalishSea_1h_{start_day[run_type]}_{end_day[run_type]}_grid_T.nc'
%%timeit -n1 -r1
from importlib import reload
from nowcast.figures import website_theme, shared
from salishsea_tools import places
reload(compare_tide_prediction_max_ssh)
reload(website_theme)
reload(shared)
reload(places)
fig = compare_tide_prediction_max_ssh.make_figure(
'Sandy Cove', ssh_fcst_dataset_url_tmpl, tidal_predictions, forecast_hrs,
weather_path, bathy, grid_T_hr_path, theme=website_theme
)
/media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour(
30.9 s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)
%%timeit -n1 -r1
from importlib import reload
from nowcast.figures import website_theme, shared
from salishsea_tools import places
reload(compare_tide_prediction_max_ssh)
reload(website_theme)
reload(shared)
reload(places)
names = {
"Boundary Bay": "BB_maxSSH",
"Campbell River": "CR_maxSSH",
"Cherry Point": "CP_maxSSH",
"Friday Harbor": "FH_maxSSH",
"Halfmoon Bay": "HB_maxSSH",
"Nanaimo": "Nan_maxSSH",
"Neah Bay": "NB_maxSSH",
"New Westminster": "NW_maxSSH",
"Patricia Bay": "PB_maxSSH",
"Point Atkinson": "PA_maxSSH",
"Port Renfrew": "PR_maxSSH",
"Sand Heads": "SH_maxSSH",
"Sandy Cove": "SC_maxSSH",
"Squamish": "Sqam_maxSSH",
"Victoria": "Vic_maxSSH",
"Woodwards Landing": "WL_maxSSH",
}
for name in names:
fig = compare_tide_prediction_max_ssh.make_figure(
name, ssh_fcst_dataset_url_tmpl, tidal_predictions, forecast_hrs,
weather_path, bathy, grid_T_hr_path, theme=website_theme
)
ERROR:root:invalid station number for Boundary Bay station: None ERROR:root:can't resolve a valid CHS station code for Boundary Bay /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour( /media/doug/warehouse/MEOPAR/tools/SalishSeaTools/salishsea_tools/viz_tools.py:133: UserWarning: No contour levels were found within the data range. contour_lines = axes.contour(
8min 6s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)