[3136] | 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 = {'20060515_001733': '100m boundary', |
---|
[3190] | 25 | '20060530_102753': '50m boundary', |
---|
| 26 | 'MOST': 'MOST'} |
---|
[3136] | 27 | |
---|
| 28 | gauge_map = 'onslow_boundary_gauges.png' |
---|
| 29 | |
---|
[3150] | 30 | plot_quantity = ['stage', 'speed'] |
---|
| 31 | |
---|
[3136] | 32 | # Create sections and graphs for each designated production directory |
---|
| 33 | latex_output = [] |
---|
| 34 | swwfiles = {} |
---|
| 35 | for label_id in production_dirs.keys(): |
---|
| 36 | |
---|
| 37 | file_loc = project.outputdir + label_id + sep |
---|
| 38 | swwfile = file_loc + project.basename + '.sww' |
---|
[3190] | 39 | if label_id == 'MOST': |
---|
| 40 | swwfile = project.boundarydir + project.boundary_basename + '.sww' |
---|
[3136] | 41 | swwfiles[swwfile] = label_id |
---|
| 42 | |
---|
[3150] | 43 | texname, vec = sww2timeseries(swwfiles, |
---|
| 44 | project.gauges50, |
---|
| 45 | production_dirs, |
---|
| 46 | report = True, |
---|
[3190] | 47 | reportname = 'latexoutput_compare50_100_MOST', |
---|
[3188] | 48 | surface = False, |
---|
[3150] | 49 | plot_quantity = plot_quantity, |
---|
| 50 | time_min = None, |
---|
| 51 | time_max = None, |
---|
| 52 | title_on = False, |
---|
| 53 | verbose = True) |
---|
[3136] | 54 | |
---|
| 55 | latex_output.append(texname) |
---|
| 56 | |
---|
[3150] | 57 | from shutil import copy, move |
---|
| 58 | copy ('report' + sep + texname + '.tex', project.comparereportdir + sep + texname + '.tex') |
---|
[3136] | 59 | |
---|
[3150] | 60 | |
---|
[3136] | 61 | # Start report generation |
---|
[3190] | 62 | input_name = project.comparereportdir + sep + '50100MOSTcomparison_onslow.tex' |
---|
[3136] | 63 | fid = open(input_name, 'w') |
---|
| 64 | |
---|
| 65 | # Generate latex output for location points |
---|
[3150] | 66 | s = '\\begin{table} \label{table:locationsonslow} \n' |
---|
[3136] | 67 | fid.write(s) |
---|
| 68 | s = '\caption{Defined point locations for comparison study for Onslow region.}' |
---|
| 69 | fid.write(s) |
---|
| 70 | s = """ |
---|
| 71 | \\begin{center} |
---|
| 72 | \\begin{tabular}{|l|l|l|l|}\hline |
---|
[3150] | 73 | \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline |
---|
[3136] | 74 | """ |
---|
| 75 | fid.write(s) |
---|
| 76 | |
---|
[3150] | 77 | for i, thisvec in enumerate(vec): |
---|
| 78 | name = thisvec[0] |
---|
| 79 | east = thisvec[1] |
---|
| 80 | north = thisvec[2] |
---|
| 81 | elev = thisvec[3] |
---|
| 82 | s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name, east, north, elev) |
---|
[3136] | 83 | fid.write(s) |
---|
[3150] | 84 | for which_one in plot_quantity: |
---|
| 85 | move ('report_figures' + sep + 'gauge'+name.replace(' ','')+which_one+'.png', project.comparereportfigdir) |
---|
[3136] | 86 | |
---|
| 87 | s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
| 88 | fid.write(s) |
---|
| 89 | |
---|
| 90 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map |
---|
| 91 | fid.write(s) |
---|
| 92 | |
---|
| 93 | s = """ |
---|
[3150] | 94 | \caption{Point locations used for comparison between boundary at 50m and 100m contour for Onslow region.} |
---|
[3136] | 95 | \label{fig:points} |
---|
| 96 | \end{figure} |
---|
| 97 | """ |
---|
| 98 | fid.write(s) |
---|
| 99 | |
---|
| 100 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
| 101 | fid.write(s) |
---|