source: production/sydney_2006/gauges2tex.py @ 2773

Last change on this file since 2773 was 2722, checked in by sexton, 19 years ago

Update Sydney documentation with recent results
Start on automatic tex document for time series figures

File size: 2.2 KB
Line 
1"""
2"""
3from os import sep
4import project
5
6# read in gauge file
7def get_gauges_from_file(filename):
8    fid = open(filename)
9    lines = fid.readlines()
10    fid.close()
11   
12    gauges = []
13    gaugelocation = []
14    eastings = []
15    northings = []
16    for line in lines[1:]:
17        fields = line.split(',')
18        location = fields[0]
19        easting = float(fields[1])
20        northing = float(fields[2])
21        eastings.append(easting)
22        northings.append(northing)
23        gaugelocation.append(location)
24       
25    #Return gauges and raw data for subsequent storage
26    return gaugelocation, eastings, northings
27
28gaugelocation, eastings, northings = get_gauges_from_file(project.gauge_filename)
29
30filename = project.tex_output
31print 'filename', filename
32fid = open(filename, 'w')
33# put in place tex stuff
34#fid.write('\\documentclass{article}\n') 
35#fid.write('\\usepackage{epsfig}\n') 
36#fid.write('\\begin{document}\n')
37 
38# make table of gauge name and location in eastings and northings
39s = '\\begin{tabular}{|l|l|l|}\hline \n Gauge Name & Easting & Northing \hline \n'
40fid.write(s)
41for name, east, north in zip(gaugelocation, eastings, northings):
42    s = '%s & %.2f & %.2f \hline \n' %(name, east, north)
43    fid.write(s)
44
45s = '\\end{tabular} \n \n'
46fid.write(s)
47       
48# make figure for each gauge
49n = len(gaugelocation)
50for i in range(n):
51    for j in range(4):
52        if j == 0: what = 'stage'
53        if j == 1: what = 'speed'
54        if j == 2: what = 'momentum'
55        if j == 3: what = 'bearing'
56        graphloc = project.outputdir+'Slump tests'+sep+'t30_10km_longtime_k1'+sep+'Reflective'+sep+'Gauges'+sep       
57        graphname = '%sGauge_%s_%s' %(graphloc, gaugelocation[i], what) + '.png'
58        label = '%s' %(gaugelocation[i])
59        caption = 'Time series for %s gauge (%.2f, %.2f) - %s' %(gaugelocation[i], eastings[i], northings[i], what)
60        s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width=75mm, height=75mm]{%s}} \n' %(graphname)
61        fid.write(s)
62        s = '\\caption{%s} \n \label{fig:%s_%s} \n \end{figure} \n \n' %(caption, label, what)
63        fid.write(s)
64
65
66#s = '\\end{document}\n'
67#fid.write(s)
Note: See TracBrowser for help on using the repository browser.