""" """ from os import sep import project # read in gauge file def get_gauges_from_file(filename): fid = open(filename) lines = fid.readlines() fid.close() gauges = [] gaugelocation = [] eastings = [] northings = [] for line in lines[1:]: fields = line.split(',') location = fields[0] easting = float(fields[1]) northing = float(fields[2]) eastings.append(easting) northings.append(northing) gaugelocation.append(location) #Return gauges and raw data for subsequent storage return gaugelocation, eastings, northings gaugelocation, eastings, northings = get_gauges_from_file(project.gauge_filename) filename = project.tex_output print 'filename', filename fid = open(filename, 'w') # put in place tex stuff #fid.write('\\documentclass{article}\n') #fid.write('\\usepackage{epsfig}\n') #fid.write('\\begin{document}\n') # make table of gauge name and location in eastings and northings s = '\\begin{tabular}{|l|l|l|}\hline \n Gauge Name & Easting & Northing \hline \n' fid.write(s) for name, east, north in zip(gaugelocation, eastings, northings): s = '%s & %.2f & %.2f \hline \n' %(name, east, north) fid.write(s) s = '\\end{tabular} \n \n' fid.write(s) # make figure for each gauge n = len(gaugelocation) for i in range(n): for j in range(4): if j == 0: what = 'stage' if j == 1: what = 'speed' if j == 2: what = 'momentum' if j == 3: what = 'bearing' graphloc = project.outputdir+'Slump tests'+sep+'t30_10km_longtime_k1'+sep+'Reflective'+sep+'Gauges'+sep graphname = '%sGauge_%s_%s' %(graphloc, gaugelocation[i], what) + '.png' label = '%s' %(gaugelocation[i]) caption = 'Time series for %s gauge (%.2f, %.2f) - %s' %(gaugelocation[i], eastings[i], northings[i], what) s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width=75mm, height=75mm]{%s}} \n' %(graphname) fid.write(s) s = '\\caption{%s} \n \label{fig:%s_%s} \n \end{figure} \n \n' %(caption, label, what) fid.write(s) #s = '\\end{document}\n' #fid.write(s)