In [20]:
from datetime import datetime
import cStringIO
import pandas as pd
from owslib.sos import SensorObservationService
In [21]:
# pick a buoy, any buoy
#sta_id='44066' # texas tower
sta_id='44013' # boston buoy
In [22]:
# pick a start & stop time
start = '2013-06-12T00:00:00Z'
stop = '2013-06-14T00:00:00Z'
In [23]:
from IPython.core.display import HTML
HTML('<iframe src=http://www.ndbc.noaa.gov/station_page.php?station=%s width=950 height=400></iframe>' % sta_id)
Out[23]:
In [24]:
ndbc=SensorObservationService('http://sdf.ndbc.noaa.gov/sos/server.php?request=GetCapabilities&service=SOS')
In [25]:
id=ndbc.identification
id.title
Out[25]:
In [26]:
contents = ndbc.contents
network = contents['network-all']
network.description
Out[26]:
In [27]:
id.title
Out[27]:
In [28]:
rfs = network.response_formats
In [29]:
print '\n'.join(rfs)
In [30]:
station = contents['station-%s' % sta_id]
In [31]:
station.name
Out[31]:
In [32]:
station.description
Out[32]:
In [33]:
getob = ndbc.get_operation_by_name('getobservation')
In [34]:
getob.parameters
Out[34]:
In [35]:
# issue the SOS get_obs request
response = ndbc.get_observation(offerings=['urn:ioos:station:wmo:%s' % sta_id],
responseFormat='text/csv',
observedProperties=['winds'],
eventTime='%s/%s' % (start,stop))
In [36]:
df2 = pd.read_csv(cStringIO.StringIO(response.strip()),index_col='date_time',parse_dates=True) # skip the units row
In [37]:
df2.head()
Out[37]:
In [38]:
df2[['wind_speed_of_gust (m/s)','wind_speed (m/s)']].plot(figsize=(12,4),title=station.description,legend=True)
Out[38]: