1 | """ |
---|
2 | Generate latex output comparing time series of given sww files |
---|
3 | |
---|
4 | Inputs: |
---|
5 | |
---|
6 | output dirs: dictionary of output directories with a |
---|
7 | association to simulation, eg 50m boundary, 100m boundary |
---|
8 | |
---|
9 | Outputs: |
---|
10 | |
---|
11 | * latex output to generate figures for report |
---|
12 | * figures used for report stored in the report_figure directory |
---|
13 | NOTE, this directory will need to be committed, as well as |
---|
14 | the latex files. |
---|
15 | |
---|
16 | June 2006 |
---|
17 | """ |
---|
18 | |
---|
19 | from os import sep |
---|
20 | import project |
---|
21 | from pyvolution.util import sww2timeseries, get_gauges_from_file |
---|
22 | |
---|
23 | # User defined inputs |
---|
24 | production_dirs = {'': '100m boundary', |
---|
25 | '': '50m boundary'} |
---|
26 | |
---|
27 | gauge_map = 'pt_hedland_boundary_gauges.png' |
---|
28 | |
---|
29 | plot_quantity = ['stage', 'speed'] |
---|
30 | |
---|
31 | # Create sections and graphs for each designated production directory |
---|
32 | latex_output = [] |
---|
33 | swwfiles = {} |
---|
34 | for label_id in production_dirs.keys(): |
---|
35 | |
---|
36 | file_loc = project.outputdir + label_id + sep |
---|
37 | swwfile = file_loc + project.basename + '.sww' |
---|
38 | swwfiles[swwfile] = label_id |
---|
39 | |
---|
40 | texname, vec = sww2timeseries(swwfiles, |
---|
41 | project.gauges50, |
---|
42 | production_dirs, |
---|
43 | report = True, |
---|
44 | reportname = 'latexoutput_compare_pt_hedland', |
---|
45 | plot_quantity = plot_quantity, |
---|
46 | time_min = None, |
---|
47 | time_max = None, |
---|
48 | title_on = False, |
---|
49 | verbose = True) |
---|
50 | |
---|
51 | latex_output.append(texname) |
---|
52 | |
---|
53 | from shutil import copy, move |
---|
54 | copy ('report' + sep + texname + '.tex', project.comparereportdir + sep + texname + '.tex') |
---|
55 | |
---|
56 | |
---|
57 | # Start report generation |
---|
58 | input_name = project.comparereportdir + sep + 'comparison_pt_hedland.tex' |
---|
59 | fid = open(input_name, 'w') |
---|
60 | |
---|
61 | # Generate latex output for location points |
---|
62 | s = '\\begin{table} \label{table:locationspthedland} \n' |
---|
63 | fid.write(s) |
---|
64 | s = '\caption{Defined point locations for comparison study for Pt Hedland region.}' |
---|
65 | fid.write(s) |
---|
66 | s = """ |
---|
67 | \\begin{center} |
---|
68 | \\begin{tabular}{|l|l|l|l|}\hline |
---|
69 | \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline |
---|
70 | """ |
---|
71 | fid.write(s) |
---|
72 | |
---|
73 | for i, thisvec in enumerate(vec): |
---|
74 | name = thisvec[0] |
---|
75 | east = thisvec[1] |
---|
76 | north = thisvec[2] |
---|
77 | elev = thisvec[3] |
---|
78 | s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name, east, north, elev) |
---|
79 | fid.write(s) |
---|
80 | for which_one in plot_quantity: |
---|
81 | move ('report_figures' + sep + 'gauge'+name.replace(' ','')+which_one+'.png', project.comparereportfigdir) |
---|
82 | |
---|
83 | s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
84 | fid.write(s) |
---|
85 | |
---|
86 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map |
---|
87 | fid.write(s) |
---|
88 | |
---|
89 | s = """ |
---|
90 | \caption{Point locations used for comparison between boundary at 50m and 100m contour for Onslow region.} |
---|
91 | \label{fig:points} |
---|
92 | \end{figure} |
---|
93 | """ |
---|
94 | fid.write(s) |
---|
95 | |
---|
96 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
97 | fid.write(s) |
---|