Kent and Alan: better? .j import zipfile import os import pylab as P iFile = raw_input("Which file to process?")
def openarchive(filename): """ open the cmet archive and read contents of file into memory """ z = zipfile.ZipFile(filename, "r") for filename in z.namelist(): print filename contents = z.read(filename) data = contents.split('\n') return data def plotflight(data): """ Plot flight data t vs. hPa with Pylab """ firstline = data[0].strip().split(' ') stind = int(firstline[0]) hdrline = stind - 1 x = [] t = [] for l in data[stind:-1]: l = l.split() # Split on whitespace tval = float(l[0]) t.append(tval) xval = float(l[24]) x.append(xval) #Create scatter plot using pylab function P.scatter(t,x) P.xlabel('time (s) after 00 UTC') P.ylabel('Altitude (hPa)') P.title('Flight elevation vs. Time') P.grid(True) #print out figure if os.path.exists("flight_track.png"): os.remove("flight_track.png") P.savefig('flight_track') P.close() flightdata = openarchive(iFile) plotflight(flightdata)
_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor