pt_atkinson_tide
Module¶Render figure object produced by the nowcast.figures.publish.pt_atkinson_tide
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.
import io
from pathlib import Path
import arrow
import netCDF4 as nc
import yaml
from salishsea_tools import nc_tools
from nowcast.figures import figures
from nowcast.figures.publish import pt_atkinson_tide
%matplotlib inline
NOTE
The next cell mounts the /results
filesystem on skookum
and the /ocean
filesystem locally.
It is intended for use if when this notebook is run on a laptop or other
non-Waterhole machine that has sshfs
installed
and mount points for /results
and /ocean
available in its root filesystem.
Don't execute the cell if that doesn't describe your situation.
!sshfs skookum:/results /results !sshfs skookum:/ocean /ocean
config = '''
timezone: Canada/Pacific
ssh:
tidal_predictions: /results/nowcast-sys/tools/SalishSeaNowcast/tidal_predictions/
run:
results_archive:
nowcast: /results/SalishSea/nowcast/
forecast: /results/SalishSea/forecast/
'''
config = yaml.load(io.StringIO(config))
run_date = arrow.get('2016-06-01')
run_type = 'nowcast'
dmy = run_date.format('DDMMMYY').lower()
start_day = {
'nowcast': run_date.format('YYYYMMDD'),
'forecast': run_date.replace(days=+1).format('YYYYMMDD'),
}
end_day = {
'nowcast': run_date.format('YYYYMMDD'),
'forecast': run_date.replace(days=+2).format('YYYYMMDD'),
}
results_home = Path(config['run']['results_archive'][run_type])
results_dir = results_home/dmy
grid_T_hr = nc.Dataset(
str(results_dir/'SalishSea_1h_{0}_{1}_grid_T.nc'
.format(start_day[run_type], end_day[run_type])))
tidal_predictions = config['ssh']['tidal_predictions']
%%timeit -n1 -r1
# Reference rendering of figure
fig = figures.PA_tidal_predictions(grid_T_hr, tidal_predictions)
1 loop, best of 1: 8.66 s per loop
%%timeit -n1 -r1
# Refactored rendering of figure
from importlib import reload
from nowcast.figures import website_theme
reload(pt_atkinson_tide)
reload(website_theme)
fig = pt_atkinson_tide.pt_atkinson_tide(
grid_T_hr, tidal_predictions, config['timezone'], theme=website_theme)
1 loop, best of 1: 1.8 s per loop