Skip to content

Commit 081af3e

Browse files
author
Jeffrey Whitaker
committed
update URL
1 parent 38674d2 commit 081af3e

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

doc/users/figures/plotargo.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
from netCDF4 import Dataset
1+
from netCDF4 import Dataset, num2date
22
import time, calendar, datetime, numpy
33
from mpl_toolkits.basemap import Basemap
44
import matplotlib.pyplot as plt
5-
def datetomsecs(d):
6-
"""convert from datetime to msecs since the unix epoch began"""
7-
return int(calendar.timegm(time.struct_time(d.timetuple()))*1000)
8-
# set date range
9-
date1 = datetime.datetime(2010,1,1,0)
10-
date2 = datetime.datetime(2010,1,8,0)
11-
t1 = datetomsecs(date1); t2 = datetomsecs(date2)
12-
# build constraint expression to get locations of floats in specified time
13-
# range.
14-
urlbase='http://dapper.pmel.noaa.gov/dapper/argo/argo_all.cdp'
15-
sel="?location.JULD,location.LATITUDE,location.LONGITUDE&location.JULD>%s&location.JULD<%s"%(t1,t2)
16-
# retrieve data
17-
dset = Dataset(urlbase+sel)
18-
lats = dset.variables['location.LATITUDE'][:]
19-
lons = dset.variables['location.LONGITUDE'][:]
5+
# data downloaded from
6+
# http://coastwatch.pfeg.noaa.gov/erddap/tabledap/apdrcArgoAll.html via
7+
# http://coastwatch.pfeg.noaa.gov/erddap/tabledap/apdrcArgoAll.nc?longitude,latitude,time&longitude>=0&longitude<=360&latitude>=-90&latitude<=90&time>=2010-01-01&time<=2010-01-08&distinct()
8+
dset = Dataset('apdrcArgoAll_af28_ee2b_1d10.nc')
9+
lats = dset.variables['latitude'][:]
10+
lons = dset.variables['longitude'][:]
11+
time = dset.variables['time']
12+
times = time[:]
13+
t1 = times.min(); t2 = times.max()
14+
date1 = num2date(t1, units=time.units)
15+
date2 = num2date(t2, units=time.units)
2016
# draw map with markers for float locations
2117
m = Basemap(projection='hammer',lon_0=180)
2218
x, y = m(lons,lats)
2319
m.drawmapboundary(fill_color='#99ffff')
2420
m.fillcontinents(color='#cc9966',lake_color='#99ffff')
2521
m.scatter(x,y,3,marker='o',color='k')
2622
plt.title('Locations of %s ARGO floats active between %s and %s' %\
27-
(len(lats),date1.strftime('%Y%m%d'),date2.strftime('%Y%m%d')))
23+
(len(lats),date1,date2),fontsize=12)
2824
plt.show()

0 commit comments

Comments
 (0)