Testing the Unidata THREDDS NetCDF Subset Service

Exploring using the point service, extracting a time series closest to a specified lon,lat location


In [1]:
import pandas as pd
import time

In [1]:
url='http://geoport.whoi.edu/thredds/ncss/grid/coawst_4/use/fmrc/coawst_4_use_best.ncd?\
var=zeta&latitude=41.07&longitude=-68.29&\
time_start=2013-05-01T01%3A00%3A00Z&time_end=2013-05-10T00%3A00%3A00Z&\
vertCoord=&accept=csv'

In [4]:
# Load the CSV data directly into Pandas
df = pd.read_csv(url,index_col='date',parse_dates=True)  # skip the units row

In [29]:
df['zeta[unit="meter"]'].tail(5)


Out[29]:
date
2013-05-09 20:00:00   -0.465322
2013-05-09 21:00:00   -0.437841
2013-05-09 22:00:00   -0.291778
2013-05-09 23:00:00   -0.077532
2013-05-10 00:00:00    0.158908
Name: zeta[unit="meter"], dtype: float64

In [30]:
df['zeta[unit="meter"]'].plot(figsize=(10,4))


Out[30]:
<matplotlib.axes.AxesSubplot at 0x38c2090>

In [31]:
df['zeta[unit="meter"]'].std()


Out[31]:
0.45749683774834193

In [33]:
url='http://geoport.whoi.edu/thredds/ncss/grid/bbleh/spring2013?\
var=temp,salt&latitude=39.93&longitude=-74.12&\
time_start=2012-05-01T00%3A30%3A00Z&time_end=2012-05-10T00%3A00%3A00Z&\
vertCoord=7&accept=csv'
# Load the CSV data directly into Pandas
time0=time.time()
df = pd.read_csv(url,index_col='date',parse_dates=True)  # skip the units row 
print('Elapsed time=%d seconds' % (time.time()-time0))


Elapsed time=86 seconds

In [34]:
df2=df.ix[:,-2:]  # last two columns of data

In [38]:
df2.plot(figsize=(12,4));



In [35]:
df2.head()


Out[35]:
temp[unit="Celsius"] salt[unit=""]
date
2012-05-01 00:30:00 15.816136 25.733746
2012-05-01 01:00:00 15.757267 25.703269
2012-05-01 01:30:00 15.681166 25.660203
2012-05-01 02:00:00 15.561799 25.624484
2012-05-01 02:30:00 15.416397 25.588893

In [18]:
time()


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-18-e93d56e4ca00> in <module>()
----> 1 time()

TypeError: 'module' object is not callable

In [ ]: