{ "metadata": { "name": "", "signature": "sha256:053f21cc878dafb4c2e930b1679de14ecc6f7150b646708e2276fd2548252e0d" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Salish Sea NEMO Model Daily Forecast Figures for Sea Surface Height" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Set-up" ] }, { "cell_type": "code", "collapsed": false, "input": [ "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", "\n", "from salishsea_tools.nowcast import figures\n", "\n", "%matplotlib inline" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "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])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "run_date = datetime.datetime(2015,2,2)\n", "\n", "# Results dataset location\n", "results_home = '/ocean/sallen/allen/research/MEOPAR/SalishSea/forecast/'\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/fcst/'" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the results datasets:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "grid_T_hr = results_dataset('1h', 'grid_T', results_dir)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "bathy = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "import scipy.io as sio\n", "PNW_coastline = sio.loadmat('/ocean/rich/more/mmapbase/bcgeo/PNW.mat')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the figures:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "HTML('