1 | """ |
---|
2 | """ |
---|
3 | from os import sep |
---|
4 | import project |
---|
5 | |
---|
6 | # read in gauge file |
---|
7 | def 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 | |
---|
28 | gaugelocation, eastings, northings = get_gauges_from_file(project.gauge_filename) |
---|
29 | |
---|
30 | filename = project.tex_output |
---|
31 | print 'filename', filename |
---|
32 | fid = 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 |
---|
39 | s = '\\begin{tabular}{|l|l|l|}\hline \n Gauge Name & Easting & Northing \hline \n' |
---|
40 | fid.write(s) |
---|
41 | for name, east, north in zip(gaugelocation, eastings, northings): |
---|
42 | s = '%s & %.2f & %.2f \hline \n' %(name, east, north) |
---|
43 | fid.write(s) |
---|
44 | |
---|
45 | s = '\\end{tabular} \n \n' |
---|
46 | fid.write(s) |
---|
47 | |
---|
48 | # make figure for each gauge |
---|
49 | n = len(gaugelocation) |
---|
50 | for 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) |
---|