Compare 1-min Water Levels from Tsunami Capable Tide Stations

using NOAA CO-OPS SOS Rest Service + Pandas.


In [1]:
import pandas as pd

In [2]:
start='2012-06-30T09:30:00Z'
stop='2012-06-30T15:00:00Z'

In [3]:
from IPython.core.display import HTML
HTML('<iframe src=http://tidesandcurrents.noaa.gov/tsunami/ width=900 height=600></iframe>')


Out[3]:

In [4]:
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

In [5]:
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=start,stop=stop)

#    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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15: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=2012-06-30T09:30:00Z/2012-06-30T15:00:00Z

In [32]:
panel = pd.Panel(df)

In [33]:
slice = panel.minor_xs('water_surface_height_above_reference_datum (m)')

In [34]:
slice[['woods hole','atlantic city','montauk']].plot(figsize=(20,6),title='East Coast water levels (m)');



In [35]:
# NDBC Rest
def ndbc2df(sta='8447930',start='2013-06-13T18:30:00Z',stop='2013-06-13T23:00:00Z'):
    url='http://sdf.ndbc.noaa.gov/sos/server.php?request=GetObservation&service=SOS&version=1.0.0&\
offering=urn:ioos:station:wmo:%s&\
observedproperty=sea_floor_depth_below_sea_surface&responseformat=text/csv&\
eventtime=%s/%s' % (sta,start,stop)
    df = pd.read_csv(url,index_col='date_time',parse_dates=True)  
    print url
    return df

In [45]:
# Dart Buoy in 1500m water, northeast of Hudson Canyon
sta_id='44402'

In [46]:
df_dart=ndbc2df(sta=sta_id,start=start,stop=stop)


http://sdf.ndbc.noaa.gov/sos/server.php?request=GetObservation&service=SOS&version=1.0.0&offering=urn:ioos:station:wmo:44402&observedproperty=sea_floor_depth_below_sea_surface&responseformat=text/csv&eventtime=2012-06-30T09:30:00Z/2012-06-30T15:00:00Z

In [47]:
df_dart['sea_floor_depth_below_sea_surface (m)'].plot(figsize=(20,6))


Out[47]:
<matplotlib.axes.AxesSubplot at 0x34fd5d0>

In [48]:
df_event1=df_dart['2013-6-13 16:45:00':'2013-6-13 17:45:00']
df_event1['sea_floor_depth_below_sea_surface (m)'].plot(figsize=(20,6))


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-48-b81cf519a487> in <module>()
      1 df_event1=df_dart['2013-6-13 16:45:00':'2013-6-13 17:45:00']
----> 2 df_event1['sea_floor_depth_below_sea_surface (m)'].plot(figsize=(20,6))

/home/local/python27_epd/lib/python2.7/site-packages/pandas/tools/plotting.py in plot_series(series, label, kind, use_index, rot, xticks, yticks, xlim, ylim, ax, style, grid, legend, logx, logy, secondary_y, **kwds)
   1656                      secondary_y=secondary_y, **kwds)
   1657 
-> 1658     plot_obj.generate()
   1659     plot_obj.draw()
   1660 

/home/local/python27_epd/lib/python2.7/site-packages/pandas/tools/plotting.py in generate(self)
    798         self._compute_plot_data()
    799         self._setup_subplots()
--> 800         self._make_plot()
    801         self._post_plot_logic()
    802         self._adorn_subplots()

/home/local/python27_epd/lib/python2.7/site-packages/pandas/tools/plotting.py in _make_plot(self)
   1185 
   1186                     if self._is_datetype():
-> 1187                         left, right = _get_xlim(lines)
   1188                         ax.set_xlim(left, right)
   1189                 except AttributeError as inst: # non-numeric

/home/local/python27_epd/lib/python2.7/site-packages/pandas/tools/plotting.py in _get_xlim(lines)
   2278     for l in lines:
   2279         x = l.get_xdata()
-> 2280         left = min(_maybe_convert_date(x[0]), left)
   2281         right = max(_maybe_convert_date(x[-1]), right)
   2282     return left, right

IndexError: index 0 is out of bounds for axis 0 with size 0

In [ ]:
df_event2=df_dart['2013-6-13 19:45:00':'2013-6-13 20:45:00']
df_event2['sea_floor_depth_below_sea_surface (m)'].plot(figsize=(20,6))

In [ ]:
# 60 km/hr, 90 km/hr, 90 km/hr

In [ ]:
g=9.81
c=60.0 * 1000./3600 # convert km/hr to m/s
h = (c*c)/g
print h

In [ ]:
c=90.0 * 1000./3600 # convert km/hr to m/s
h = (c*c)/g
print h

In [ ]: