Try search and access of glider data


In [56]:
import json, requests

url = 'http://erddap.marine.rutgers.edu/erddap/search/advanced.json'

params = dict(
    page='1',
    itemsPerPage='1000',
    searchFor='',
    protocol='(ANY)',
    cdm_data_type='(ANY)',
    institution='(ANY)',
    ioos_category='(ANY)',
    keywords='(ANY)',
    long_name='(ANY)',
    standard_name='sea_water_temperature',
    variableName='(ANY)',
    maxLat='37.78803',
    minLon='-75.5659',
    maxLon='-74.2846',
    minLat='37.0371',
    minTime='2013-09-23T00%3A00%3A00Z',
    maxTime='2013-10-18T00%3A00%3A00Z'
)

In [57]:
resp = requests.get(url=url, params=params)
data = json.loads(resp.text)

In [58]:
data['table']['rows'][0][:]


Out[58]:
[u'',
 u'http://erddap.marine.rutgers.edu/erddap/tabledap/ru22-20130924T2010.subset',
 u'http://erddap.marine.rutgers.edu/erddap/tabledap/ru22-20130924T2010',
 u'http://erddap.marine.rutgers.edu/erddap/tabledap/ru22-20130924T2010.graph',
 u'',
 u'ru22-20130924T2010',
 u'U.S. IOOS Mid-Atlantic Regional Consortium of Ocean Observing Systems (MARACOOS) glider deployment to survey the physical and biological properties of Mid-Atlantic Bight coastal waters.\n\ncdm_data_type = TrajectoryProfile\nVARIABLES:\ntrajectory (Trajectory Name)\nwmo_id\ntime (Profile Time, seconds since 1970-01-01T00:00:00Z)\nlatitude (Profile Latitude, degrees_north)\nlatitude_qc (latitude Variable Quality Flag)\nlongitude (Profile Longitude, degrees_east)\nlongitude_qc (longitude Variable Quality Flag)\ntime_qc (profile_time Variable Quality Flag)\ndepth (m)\ndepth_qc (depth Variable Quality Flag)\npressure (Sea Water Pressure, dbar)\npressure_qc (pressure Variable Quality Flag)\nconductivity (Sea Water Electrical Conductivity, S m-1)\nconductivity_qc (conductivity Variable Quality Flag)\ndensity (Sea Water Density, kg m-3)\ndensity_qc (density Variable Quality Flag)\nprecise_lat (Precise Latitude, degrees_north)\nprecise_lon (Precise Longitude, degrees_east)\nprecise_time (seconds since 1970-01-01T00:00:00Z)\nprofile_id\nprecise_lat_qc (lat Variable Quality Flag)\nprecise_lon_qc (precise_lon Variable Quality Flag)\nprecise_time_qc (precise_time Variable Quality Flag)\nsalinity (Sea Water Practical Salinity, 1e-3)\nsalinity_qc (salinity Variable Quality Flag)\ntemperature (Sea Water Temperature, Celsius)\n... (13 more variables)\n',
 u'http://erddap.marine.rutgers.edu/erddap/metadata/fgdc/xml/ru22-20130924T2010_fgdc.xml',
 u'http://erddap.marine.rutgers.edu/erddap/metadata/iso19115/xml/ru22-20130924T2010_iso19115.xml',
 u'http://erddap.marine.rutgers.edu/erddap/info/ru22-20130924T2010/index.json',
 u'http://rucool.marine.rutgers.edu',
 u'http://erddap.marine.rutgers.edu/erddap/rss/ru22-20130924T2010.rss',
 u'Rutgers University',
 u'ru22-20130924T2010']

Tell ERDDAP to save as NetCDF CF-1.6 multidimensional array


In [88]:
url='http://erddap.marine.rutgers.edu/erddap/tabledap/ru22-20130924T2010.ncCF?time,latitude,longitude,depth,temperature&trajectory=%22ru22-20130924T2010%22'

In [89]:
import urllib

In [90]:
urllib.urlretrieve(url,'glider.nc')


Out[90]:
('glider.nc', <httplib.HTTPMessage instance at 0x7fbaab3ed4d0>)

In [91]:
import netCDF4

In [92]:
nc = netCDF4.Dataset('glider.nc')
ncv = nc.variables
print ncv.keys()


[u'trajectory', u'profile_id', u'time', u'latitude', u'longitude', u'trajectoryIndex', u'rowSize', u'depth', u'temperature']

In [97]:
print unique(ncv['profile_id'][:])
print unique(ncv['trajectoryIndex'][:])


[   1    2    3 ..., 3292 3293 3294]
[0]

In [ ]:
import pandas as pd

In [96]:
print shape(ncv['latitude'])
print shape(ncv['temperature'])
print shape(ncv['depth'])


(3294,)
(777280,)
(777280,)

In [80]:
t = np.squeeze(ncv['temperature'][:,:,:])
d = np.squeeze(ncv['depth'][:,:,:])
lon = np.squeeze(ncv['longitude'][:,:])
lat = np.squeeze(ncv['latitude'][:,:])

In [81]:
shape(t)


Out[81]:
(3294, 680)

In [87]:
pcolormesh(lon.T,d.T,t.T);


Out[87]:
<matplotlib.collections.QuadMesh at 0x7fbaab31d0d0>

In [ ]: