""" Generate latex output comparing time series of given sww files Inputs: output dirs: dictionary of output directories with a association to simulation, eg 50m boundary, 100m boundary Outputs: * latex output to generate figures for report * figures used for report stored in the report_figure directory NOTE, this directory will need to be committed, as well as the latex files. June 2006 """ from os import sep import project from pyvolution.util import sww2timeseries, get_gauges_from_file # User defined inputs production_dirs = {'': '100m boundary', '': '50m boundary'} gauge_map = 'pt_hedland_boundary_gauges.png' plot_quantity = ['stage', 'speed'] # Create sections and graphs for each designated production directory latex_output = [] swwfiles = {} for label_id in production_dirs.keys(): file_loc = project.outputdir + label_id + sep swwfile = file_loc + project.basename + '.sww' swwfiles[swwfile] = label_id texname, vec = sww2timeseries(swwfiles, project.gauges50, production_dirs, report = True, reportname = 'latexoutput_compare_pt_hedland', plot_quantity = plot_quantity, time_min = None, time_max = None, title_on = False, verbose = True) latex_output.append(texname) from shutil import copy, move copy ('report' + sep + texname + '.tex', project.comparereportdir + sep + texname + '.tex') # Start report generation input_name = project.comparereportdir + sep + 'comparison_pt_hedland.tex' fid = open(input_name, 'w') # Generate latex output for location points s = '\\begin{table} \label{table:locationspthedland} \n' fid.write(s) s = '\caption{Defined point locations for comparison study for Pt Hedland region.}' fid.write(s) s = """ \\begin{center} \\begin{tabular}{|l|l|l|l|}\hline \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline """ fid.write(s) for i, thisvec in enumerate(vec): name = thisvec[0] east = thisvec[1] north = thisvec[2] elev = thisvec[3] s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name, east, north, elev) fid.write(s) for which_one in plot_quantity: move ('report_figures' + sep + 'gauge'+name.replace(' ','')+which_one+'.png', project.comparereportfigdir) s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' fid.write(s) s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map fid.write(s) s = """ \caption{Point locations used for comparison between boundary at 50m and 100m contour for Onslow region.} \label{fig:points} \end{figure} """ fid.write(s) s = '\input{%s} \n \clearpage \n \n' %latex_output[0] fid.write(s)