velocity_section_and_surface
Module¶Render figure object produced by the nowcast.figures.research.velocity_section_and_surface
module.
Set-up and function call replicates as nearly as possible what is done in the nowcast.workers.make_plots
worker
to help ensure that the module will work in the nowcast production context.
This notebook must be run in a
Nowcast Figures Development Environment
so that all of the necessary dependency packages are installed.
Also, it must be run on a workstation that has the Salish Sea Nowcast system /results/
parition mounted.
# reload lets us pull in changes from modules that we edit
from importlib import reload
import datetime
from glob import glob
import logging
import os
from pathlib import Path
import matplotlib
import arrow
import cmocean
from nemo_nowcast import NowcastWorker
import netCDF4 as nc
import scipy.io as sio
from nowcast import lib
from nowcast.figures.research import velocity_section_and_surface
import io
import yaml
%matplotlib inline
config = '''
run_types:
nowcast-green:
bathymetry: /results/nowcast-sys/grid/bathymetry_201702.nc
mesh_mask: /results/nowcast-sys/grid/mesh_mask201702.nc
nowcast:
bathymetry: /results/nowcast-sys/grid/bathymetry_201702.nc
mesh_mask: /results/nowcast-sys/grid/mesh_mask201702.nc
run:
results_archive:
nowcast-green: /results/SalishSea/nowcast-green/
nowcast: /results/SalishSea/nowcast-blue/
'''
config = yaml.load(io.StringIO(config))
run_type = 'nowcast'
plot_type = 'research'
run_date = arrow.get('2017-10-23')
dmy = run_date.format('DDMMMYY').lower()
results_dir = Path(config['run']['results_archive'][run_type], dmy)
bathy = nc.Dataset(config['run_types'][run_type]['bathymetry'])
mesh_mask = nc.Dataset(config['run_types'][run_type]['mesh_mask'])
yyyymmdd = run_date.format('YYYYMMDD')
U = nc.Dataset(os.fspath(results_dir/f'SalishSea_1h_{yyyymmdd}_{yyyymmdd}_grid_U.nc'))
V = nc.Dataset(os.fspath(results_dir/f'SalishSea_1h_{yyyymmdd}_{yyyymmdd}_grid_V.nc'))
U_var = U.variables['vozocrtx']
V_var = V.variables['vomecrty']
%%timeit -n1 -r1
# Layout parameters
sections = (450, 520, 680)
pos = (
(0.1, 0.35),
(0.4, 0.65),
(0.7, 0.95)
)
section_lims = (
(235, 318, 0, 445),
(192, 277, 0, 445),
(127, 197, 0, 445),
)
# Make figure
fig = velocity_section_and_surface.make_figure(
U_var, V_var, bathy, mesh_mask,
sections=sections, pos=pos, section_lims=section_lims
)
2.15 s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)