using NOAA CO-OPS SOS Rest Service + Pandas.
import pandas as pd
from IPython.core.display import HTML
HTML('<iframe src=http://tidesandcurrents.noaa.gov/tsunami/ width=900 height=600></iframe>')
def coops2df(sta='8447930',start='2013-06-13T18:30:00Z',stop='2013-06-13T23:00:00Z'):
url='http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?\
request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&\
offering=urn:ioos:station:NOAA.NOS.CO-OPS:%s&\
observedProperty=water_surface_height_above_reference_datum&\
dataType=PreliminaryOneMinute&\
eventTime=%s/%s' % (sta,start,stop)
df = pd.read_csv(url,index_col='date_time',parse_dates=True)
print url
return df
stas = {}
stas['montauk']='8510560'
stas['woods hole']='8447930'
stas['nantucket']='8449130'
stas['newport']='8452660'
stas['atlantic city']='8534720'
stas['sandy hook']='8531680'
stas['quonset']='8454049'
stas['mystic']='8465705'
stas['battery']='8518750'
stas['lewes']='8557380'
df={}
for sta_name,sta_id in stas.iteritems():
df[sta_name]=coops2df(sta=sta_id,start='2013-06-13T17:30:00Z',stop='2013-06-13T22:00:00Z')
# df[sta_name]=coops2df(sta=sta_id,start='2013-04-11T03:00:00Z',stop='2013-04-11T09:00:00Z')
http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8447930&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8518750&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8465705&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8534720&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8449130&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8452660&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8510560&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8454049&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8557380&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?request=GetObservation&service=SOS&responseFormat=text/csv&version=1.0.0&offering=urn:ioos:station:NOAA.NOS.CO-OPS:8531680&observedProperty=water_surface_height_above_reference_datum&dataType=PreliminaryOneMinute&eventTime=2013-06-13T17:30:00Z/2013-06-13T22:00:00Z
panel = pd.Panel(df)
slice = panel.minor_xs('water_surface_height_above_reference_datum (m)').astype(float)
# take just 3 stations from list
df3 = slice[['woods hole','atlantic city','montauk']]
df3.plot(figsize=(16,6),title='1-minute East Coast water levels (m)');
df3.columns
Index([woods hole, atlantic city, montauk], dtype=object)
df3_6min=df3.resample('6min',how='mean')
df3_6min.plot(figsize=(16,6),title='6-minute average East Coast water levels (m)');