from netCDF4 import Dataset, num2date import time, calendar, datetime, numpy from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import urllib, os # data downloaded from the form at # http://coastwatch.pfeg.noaa.gov/erddap/tabledap/apdrcArgoAll.html filename, headers = urllib.urlretrieve('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()') dset = Dataset(filename) lats = dset.variables['latitude'][:] lons = dset.variables['longitude'][:] time = dset.variables['time'] times = time[:] t1 = times.min(); t2 = times.max() date1 = num2date(t1, units=time.units) date2 = num2date(t2, units=time.units) dset.close() os.remove(filename) # draw map with markers for float locations m = Basemap(projection='hammer',lon_0=180) x, y = m(lons,lats) m.drawmapboundary(fill_color='#99ffff') m.fillcontinents(color='#cc9966',lake_color='#99ffff') m.scatter(x,y,3,marker='o',color='k') plt.title('Locations of %s ARGO floats active between %s and %s' %\ (len(lats),date1,date2),fontsize=12) plt.show()