In [1]:
import urllib2
import pandas as pd
In [2]:
# dictionary for valid parameter_name
d={'sea_water_temperature':'ZTMP', 'sea_water_salinity':'ZSAL'}
In [3]:
# Specify variable to retrieve:
param=d['sea_water_temperature']
# Get data shallower than this water depth:
depth_max = 10
# Use ERDDAP's built-in relative time functionality to get last 48 hours:
start='now-24hours'
stop='now'
# or specify a specific period:
#start = '2013-05-06T00:00:00Z'
#stop = '2013-05-07T00:00:00Z'
In [4]:
# Construct URL for large PNG:
url='http://osmc.noaa.gov:8180/erddap/tabledap/OSMC_PROFILERS\
.largePng?longitude,latitude,observation_value\
&time>=%s&time<=%s¶meter_name="%s"&observation_depth<=%d&.trim=5&\
.draw=markers&.marker=5|6&.color=0x000000&.colorBar=|||||' % (start,stop,param,depth_max)
In [5]:
# Read the image
im = imread(urllib2.urlopen(url),format='png')
In [6]:
# Display the image
figure(figsize=(12,8))
imshow(im)
axis('off');
In [7]:
# Construct URL for CSV data:
url='http://osmc.noaa.gov:8180/erddap/tabledap/OSMC_PROFILERS\
.csv?time,longitude,latitude,observation_depth,observation_value\
&time>=%s&time<=%s¶meter_name="%s"&observation_depth<=%d' % (start,stop,param,depth_max)
In [8]:
# Load the CSV data directly into Pandas
df = pd.read_csv(url,index_col='time',parse_dates=True,skiprows=[1]) # skip the units row
In [9]:
# List last ten records
df.tail(10)
Out[9]:
In [11]:
df['longitude']
Out[11]:
In [ ]: