{ "metadata": { "name": "", "signature": "sha256:cdc0adc1510e373cd21e38fb32f067ab49ebf5de9df45b46a9258e91cdfc41ba" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "from IPython.core.display import HTML\n", "\n", "with open('creative_commons.txt', 'r') as f:\n", " html = f.read()\n", " \n", "name = '2015-07-20-pyugrid'\n", "\n", "html = '''\n", "\n", "
This post was written as an IPython notebook.\n", " It is available for download\n", " or as a static html.
\n", "\n", "%s''' % (name, name, html)\n", "\n", "%matplotlib inline\n", "from matplotlib import style\n", "style.use('ggplot')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "import os\n", "from datetime import datetime\n", "\n", "title = \"SciPy 2015 sprint: pyugrid\"\n", "hour = datetime.utcnow().strftime('%H:%M')\n", "comments=\"true\"\n", "\n", "date = '-'.join(name.split('-')[:3])\n", "slug = '-'.join(name.split('-')[3:])\n", "\n", "metadata = dict(title=title,\n", " date=date,\n", " hour=hour,\n", " comments=comments,\n", " slug=slug,\n", " name=name)\n", "\n", "markdown = \"\"\"Title: {title}\n", "date: {date} {hour}\n", "comments: {comments}\n", "slug: {slug}\n", "\n", "{{% notebook {name}.ipynb cells[2:] %}}\n", "\"\"\".format(**metadata)\n", "\n", "content = os.path.abspath(os.path.join(os.getcwd(), os.pardir, os.pardir, '{}.md'.format(name)))\n", "with open('{}'.format(content), 'w') as f:\n", " f.writelines(markdown)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Last week, at the SciPy conference, I had chance to sprint on the\n", "[pyugrid](https://github.com/pyugrid/pyugrid). The pyugrid module aims to be a\n", "Python API to utilize data written using the netCDF unstructured grid\n", "[conventions](https://github.com/ugrid-conventions/ugrid-conventions). Right\n", "now it support only triangular meshes, but the conventions cover any type of\n", "unstructured grids.\n", "\n", "Let's explore this module in this post. First: how to read an unstructured?\n", "\n", "(And once hexagonal meshes are implemented I will be able to re-create\n", "Borges'\n", "[Library](https://www.google.com.br/maps/uv?hl=en&pb=!1s0x95bcca51842d40bb:0xaf79e4b89d1a272c!2m5!2m2!1i80!2i80!3m1!2i100!3m1!7e1!4s//geo3.ggpht.com/cbk?photoid%3D6VH09QOdV6YAAAQZFGcekg%26output%3Dphoto%26cb_client%3Dsearch.LOCAL_UNIVERSAL.gps%26minw%3D0%26minh%3D160!5sbuenos+aires+miguel+cane+library+-+Google+Search&sa=X&ved=0CGUQoiowC2oVChMIjpiVmrX5xgIVRh8eCh0VTw3o) of\n", "[Babel](https://en.wikipedia.org/wiki/National_Library_of_the_Argentine_Republic)\n", "and solved the\n", "[crime](http://www.amazon.com/Unimaginable-Mathematics-Borges-Library-Babel/dp/0195334574)\n", "using network theory and the connectivity array ;-)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import pyugrid\n", "\n", "print(pyugrid.__version__)\n", "\n", "url = ('http://comt.sura.org/thredds/dodsC/data/comt_1_archive/'\n", " 'inundation_tropical/VIMS_SELFE/Hurricane_Ike_3D_final_run_with_waves')\n", "\n", "ugrid = pyugrid.UGrid.from_ncfile(url)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0.1.5\n" ] } ], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "How about we check this dataset for consistency?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "ugrid.check_consistent()" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "NotImplementedError", "evalue": "", "output_type": "pyerr", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNotImplementedError\u001b[0m Traceback (most recent call last)", "\u001b[1;32mThis post was written as an IPython notebook.\n", " It is available for download\n", " or as a static html.
\n", "\n", "