{ "metadata": { "name": "", "signature": "sha256:14e17c17e7966be684b78ce309d21760913cf904ae1fadfa24746e8175172f0e" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# testing stride on NOMADS\n", "Trying to figure out why this NCO ncks stride command doesn't work:\n", "```\n", "ncks -O -D4 -d time,1 -d lev,0 -d lat,0,100,3 -d lon,0,100,3 -v u_velocity,v_velocity \\\n", " http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global20140303/rtofs_glo_2ds_forecast_daily_prog foo.nc\n", "```\n", "Does it work with netCDF4-Python, which also uses the NetCDF-C library?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import netCDF4" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "url='http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global20140303/rtofs_glo_2ds_forecast_daily_prog'\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "nc = netCDF4.Dataset(url)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "ncv = nc.variables" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try just reading a few values of longitude" ] }, { "cell_type": "code", "collapsed": false, "input": [ "ncv['lon'][:10]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ "array([ 74.16 , 74.24333, 74.32666, 74.40999, 74.49332, 74.57665,\n", " 74.65998, 74.74331, 74.82664, 74.90997])" ] } ], "prompt_number": 5 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now try reading the u_velocity variable with stride" ] }, { "cell_type": "code", "collapsed": false, "input": [ "u = ncv['u_velocity'][0,0,0:100:3,0:100:3]\n", "v = ncv['v_velocity'][0,0,0:100:3,0:100:3]\n", "print shape(u)\n", "print shape(v)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(34, 34)\n", "(34, 34)\n" ] } ], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seems to work fine. Why doesn't NCO work?" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 } ], "metadata": {} } ] }