{
"metadata": {
"name": "TPX08_Tide_Data"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Access Oregon State TPX08 Tidal Data via OPeNDAP\n",
"To test the efficiency of viability of accessing the Oregon State TPX08 Tidal Data using OPeNDAP, I first downloaded the TPX08 NetCDF files for elevation from the home page below. The original files were NetCDF3 files, so I converted these to NetCDF4 files using nccopy, which comes with the netcdf distribution from Unidata. Using level 6 deflation, the size of the 9 files from 4014MB to 74MB without loss of information.\n",
"I also used 128x128 chunks to optimize performance for extracting subregions.
\n",
"Here's the actual script I used: \n",
"\n",
"
\n",
"#!/bin/bash\n",
"for CON in m2 s2 n2 k2 k1 o1 p1 q1 m4\n",
"do\n",
" echo $CON\n",
" nccopy -d6 -c nx/128,ny/128 hf.${CON}_tpxo8_atlas_30c.nc ${CON}_nc4.nc\n",
"done\n",
"\n",
"\n",
"I then placed these NetCDF4 files in a folder scanned by our THREDDS Data Server so they could be accessed via OPeNDAP. In the python script below, I illustrate extracting the M2 amplitude and phase data using OPeNDAP for a specified bounding box.\n",
"\n",
" "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from pylab import *\n",
"import netCDF4\n",
"import time"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# OPeNDAP Data URLs for TPX08 Data on Geoport THREDDS Server\n",
"cons=['m2','n2','s2','k2','k1','o1','p1','q1','m4']\n",
"url={}\n",
"for con in cons:\n",
" url[con]='http://geoport.whoi.edu/thredds/dodsC/usgs/data2/rsignell/data/tpx08/nc4/%s_nc4.nc' % con"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"url['m2']"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"'http://geoport.whoi.edu/thredds/dodsC/usgs/data2/rsignell/data/tpx08/nc4/m2_nc4.nc'"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Open the OPeNDAP Dataset using the NetCDF4-Python library\n",
"nc = netCDF4.Dataset(url['m2']).variables\n",
"nc.keys()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": [
"[u'hIm', u'hRe', u'lat_z', u'lon_z', u'con']"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print(nc['hRe'])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"