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, getcwd, F_OK, access, mkdir |
---|
20 | import project |
---|
21 | from pyvolution.util import sww2timeseries, get_gauges_from_file |
---|
22 | |
---|
23 | # User defined inputs |
---|
24 | production_dirs = {'SU-AU_clip': 'MOST'} |
---|
25 | |
---|
26 | gauge_map = 'boundarycomparison.png' |
---|
27 | plot_quantity = ['stage', 'speed'] |
---|
28 | |
---|
29 | # Create sections and graphs for each designated production directory |
---|
30 | latex_output = [] |
---|
31 | swwfiles = {} |
---|
32 | for label_id in production_dirs.keys(): |
---|
33 | |
---|
34 | file_loc = project.boundarydir |
---|
35 | swwfile = file_loc + project.boundary_basename + '.sww' |
---|
36 | swwfiles[swwfile] = label_id |
---|
37 | |
---|
38 | texname, vec = sww2timeseries(swwfiles, |
---|
39 | project.gauge_comparison, |
---|
40 | production_dirs, |
---|
41 | report = True, |
---|
42 | reportname = 'latexoutput_MOST_input', |
---|
43 | plot_quantity = plot_quantity, |
---|
44 | time_min = None, |
---|
45 | time_max = None, |
---|
46 | title_on = False, |
---|
47 | verbose = True) |
---|
48 | |
---|
49 | latex_output.append(texname) |
---|
50 | |
---|
51 | |
---|
52 | # Start report generation |
---|
53 | reportdir = getcwd()+sep+'report'+sep |
---|
54 | if access(reportdir,F_OK) == 0: |
---|
55 | mkdir (reportdir) |
---|
56 | input_name = reportdir + sep + 'MOST_input_onslow.tex' |
---|
57 | fid = open(input_name, 'w') |
---|
58 | |
---|
59 | # Generate latex output for location points |
---|
60 | #s = '\\begin{table} \label{table:MOSTlocationsonslow} \n' |
---|
61 | #fid.write(s) |
---|
62 | #s = '\caption{Defined point locations for comparison study for Onslow region.}' |
---|
63 | #fid.write(s) |
---|
64 | #s = """ |
---|
65 | #\\begin{center} |
---|
66 | #\\begin{tabular}{|l|l|l|l|}\hline |
---|
67 | #\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline |
---|
68 | #""" |
---|
69 | #fid.write(s) |
---|
70 | |
---|
71 | #for i, thisvec in enumerate(vec): |
---|
72 | # name = thisvec[0] |
---|
73 | # east = thisvec[1] |
---|
74 | # north = thisvec[2] |
---|
75 | # elev = thisvec[3] |
---|
76 | # s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name, east, north, elev) |
---|
77 | # fid.write(s) |
---|
78 | # for which_one in plot_quantity: |
---|
79 | # move ('report_figures' + sep + 'gauge'+name.replace(' ','')+which_one+'.png', project.comparereportfigdir) |
---|
80 | |
---|
81 | #s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
82 | #fid.write(s) |
---|
83 | |
---|
84 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map |
---|
85 | fid.write(s) |
---|
86 | |
---|
87 | s = """ |
---|
88 | \caption{Point locations used for MOST input for Onslow region.} |
---|
89 | \label{fig:boundarypoints} |
---|
90 | \end{figure} |
---|
91 | """ |
---|
92 | fid.write(s) |
---|
93 | |
---|
94 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
95 | fid.write(s) |
---|