Gliders are Autonomous Underwater Vehicles that carry several oceanographic instruments and allow unmanned ocean sampling. Below we present code to simple plotting using data from the OTN Ocean Glider Programme.
Note that this particular glider adds a “zero” every time it starts a up-cast.
import csv import matplotlib.pyplot as plt import matplotlib.dates as md import datetime import urllib2 import StringIO # Retreive data from the "glider" server response = urllib2.urlopen('http://glider.ceotr.ca/data/live/sci_water_temp_live.csv') data = response.read() data = StringIO.StringIO(data) # Read file r = csv.DictReader(data) # Initialize empty variables date, lat, lon, depth, temp = [],[],[],[],[] # Loop to parse data into our variables for row in r: date.append(float(row['unixtime'])) lat.append(float(row['lat'])) lon.append(float(row['lon'])) depth.append(float(row['depth'])) temp.append(float(row['sci_water_temp'])) # Change unix-time into a date object (for easy plotting) DATE = [] for row in date: DATE.append(datetime.datetime.fromtimestamp(row)) # Make plot fig, ax1 = plt.subplots(1) plt.scatter(DATE,depth,s=15,c=temp,marker='o', edgecolor='none') plt.ylim((-0.5,max(depth)+5)) ax1.set_ylim(ax1.get_ylim()[::-1]) cbar = plt.colorbar(orientation='horizontal', extend='both') xfmt = md.DateFormatter('%Hh\n%dd\n%b') ax1.xaxis.set_major_formatter(xfmt) cbar.ax.set_xlabel('Temperature ($^\circ$C)') plt.title('Glider transect') plt.ylabel('Depth (m)') plt.show() # Save figure (without 'white' borders) plt.savefig('glider_basic.png', bbox_inches='tight')