Try search and access of glider data


In [45]:
import json, requests

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

params = dict(
    origin='Chicago,IL',
    destination='Los+Angeles,CA',
    waypoints='Joplin,MO|Oklahoma+City,OK',
    sensor='false'
)

resp = requests.get(url=url, params=params)
data = json.loads(resp.text)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-45-27ab9485975c> in <module>()
     11 
     12 resp = requests.get(url=url, params=params)
---> 13 data = json.loads(resp.text)

/home/usgs/anaconda/lib/python2.7/json/__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    336             parse_int is None and parse_float is None and
    337             parse_constant is None and object_pairs_hook is None and not kw):
--> 338         return _default_decoder.decode(s)
    339     if cls is None:
    340         cls = JSONDecoder

/home/usgs/anaconda/lib/python2.7/json/decoder.pyc in decode(self, s, _w)
    364 
    365         """
--> 366         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    367         end = _w(s, end).end()
    368         if end != len(s):

/home/usgs/anaconda/lib/python2.7/json/decoder.pyc in raw_decode(self, s, idx)
    382             obj, end = self.scan_once(s, idx)
    383         except StopIteration:
--> 384             raise ValueError("No JSON object could be decoded")
    385         return obj, end

ValueError: No JSON object could be decoded

In [46]:
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 [47]:
resp = requests.get(url=url, params=params)
data = json.loads(resp.text)

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


Out[48]:
[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']

In [49]:
a[0][2]


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-49-b42dc5b0a63a> in <module>()
----> 1 a[0][2]

IndexError: string index out of range

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

In [ ]:
import urllib

In [ ]:
urllib.ur``

In [ ]:
import pandas as pd

In [53]:
!ls -sail *.nc


ls: cannot access *.nc: No such file or directory

In [ ]: