{ "metadata": { "name": "", "signature": "sha256:a7dd71a08f40cddedc5b9f51a31f8b956df6aeeacdf32722104224d9a5f4ccca" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Template for daily nowcast figure generation." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Salish Sea NEMO Model Daily Nowcast Figures" ] }, { "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.date.today()\n", "run_date = datetime.datetime(2014,11,19)\n", "# Results dataset location\n", "results_home = '/data/dlatorne/MEOPAR/SalishSea/nowcast/'\n", "results_dir = os.path.join(results_home, run_date.strftime('%d%b%y').lower())" ], "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)\n", "grid_T_dy = results_dataset('1d', 'grid_T', results_dir)\n", "grid_U_dy = results_dataset('1d', 'grid_U', results_dir)\n", "grid_V_dy = results_dataset('1d', 'grid_V', results_dir)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 29 }, { "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": "markdown", "metadata": {}, "source": [ "Display the figures:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "HTML('