{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Production template" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Salish Sea NEMO Model Daily Nowcast Figures for Sea Surface Height" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Set-up" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from __future__ import division\n", "\n", "import datetime\n", "from glob import glob\n", "import os\n", "\n", "from IPython.core.display import HTML\n", "import netCDF4 as nc\n", "import scipy.io as sio\n", "\n", "from salishsea_tools.nowcast import figures\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def results_dataset(period, grid, results_dir):\n", " \"\"\"Return the results dataset for period (e.g. 1h or 1d)\n", " and grid (e.g. grid_T, grid_U) from results_dir.\n", " \"\"\"\n", " filename_pattern = 'SalishSea_{period}_*_{grid}.nc'\n", " filepaths = glob(os.path.join(results_dir, filename_pattern.format(period=period, grid=grid)))\n", " return nc.Dataset(filepaths[0])" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "run_date = datetime.datetime(2015,11,20)\n", "# Results dataset location\n", "results_home = '/results/SalishSea/nowcast/'\n", "results_dir = os.path.join(results_home, run_date.strftime('%d%b%y').lower())\n", "# model winds\n", "model_path = '/ocean/sallen/allen/research/MEOPAR/Operational/'\n", "coastline = sio.loadmat('/ocean/rich/more/mmapbase/bcgeo/PNW.mat')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the results datasets:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/results/SalishSea/nowcast/20nov15/PointAtkinson.nc\n", "/results/SalishSea/nowcast/20nov15/Victoria.nc\n", "/results/SalishSea/nowcast/20nov15/CampbellRiver.nc\n", "/results/SalishSea/nowcast/20nov15/Nanaimo.nc\n", "/results/SalishSea/nowcast/20nov15/CherryPoint.nc\n", "/results/SalishSea/nowcast/20nov15/NeahBay.nc\n", "/results/SalishSea/nowcast/20nov15/FridayHarbor.nc\n" ] } ], "source": [ "grid_T_hr = results_dataset('1h', 'grid_T', results_dir)\n", "\n", "grids={}\n", "names = ['Point Atkinson', 'Victoria', 'Campbell River', 'Nanaimo', 'Cherry Point', 'Neah Bay', 'Friday Harbor']\n", "for name in names:\n", " f = os.path.join(results_dir,'{}.nc'.format(name.replace(\" \", \"\")))\n", " print(f)\n", " grids[name] = nc.Dataset(f)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the figures:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "