""" Generate report for production run Inputs: Report title: title to be included in tex file latex_output: list of latex_outputs which are generated for the desired output, eg high tide, low tide and MSL. Outputs: * Report generated to scenario_report.tex where the scenario relates the name of the production directory this script is being run from. * figures used for report stored in figure directory NOTE, this directory will need to be committed, as well as the latex files. The report structure is * Introduction * Data sources * Tsunami scenario * Inundation modelling results * Summary * References * Appendix: Metadata Other files included in document: * an abstract must be written in abstract.tex * an introduction must be written in introduction.tex; a basic outline and some of the core inputs are already in place * an interpretation.tex file needs to be written for the particular scenario * any data issues must be included in data_issues.tex (data.tex should be revised for future reports) * the tsunami-genic event should be discussed in tsunami_scenario.tex * a summary must be written into summary.tex * metadata for the scenario data to be included in metadata.tex May 2006 """ from os import getcwd, sep import project from pyvolution.util import sww2timeseries p = getcwd().split(sep) scenario = p[len(p)-1] scenario_name = scenario.split('_')[0] # Inputs report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title() timedirhigh = '20060424_020426_duplictate_time_steps' timedirlow = '20060426_004129' #timedirMSL = # Finish Inputs gauge_filename = project.gauge_filename timedir = [timedirhigh, timedirlow]#, timedirMSL] latex_output = [] for i in range(len(timedir)): label_id = timedir[i] file_loc = project.outputdir + timedir[i] + sep swwfile = file_loc + project.basename + '.sww' texname = sww2timeseries(swwfile, gauge_filename, file_loc, label_id, plot_quantity = ['stage', 'velocity', 'bearing'], time_min = None, time_max = None, title_on = False, verbose = True) latex_output.append(texname) # start report report_name = scenario + '_report.tex' fid = open(report_name, 'w') s = '\documentclass{article} \n \ \usepackage{ae} % or {zefonts} \n \ \usepackage[T1]{fontenc} \n \ \usepackage[ansinew]{inputenc} \n \ \usepackage{amsmath} \n \ \usepackage{amssymb} \n \ \usepackage{graphicx} \n \ \usepackage{color} \n \ \usepackage[colorlinks]{hyperref} \n \ \usepackage{lscape} %landcape pages support \n \ \\topmargin 0pt \n \ \oddsidemargin 0pt \n \ \evensidemargin 0pt \n \ \marginparwidth 0.5pt \n \ \\textwidth \paperwidth \n \ \\advance\\textwidth -2in \n' fid.write(s) s = '\\title{%s} \n ' %report_title fid.write(s) s = '\date{} \n \ \\begin{document} \n \ \maketitle \n \ \\begin{abstract} \n \ \input{abstract} \n \ \end{abstract} \n \ \\tableofcontents \n \ \section{Introduction} \n \ \label{sec:intro} \n \ \input{introduction} \n \ \section{Data sources} \n \ \label{sec:data} \n \ \input{data} \n \ \section{Tsunami scenarios} \n \ \label{sec:tsunami_scenarios} \n \ \input{tsunami_scenario} \n \ \section{Inundation modelling results} \n \ \label{sec:results} \n \ \input{results} \n \ \input{interpretation} \n ' fid.write(s) for i in range(len(latex_output)): if i == 0: s = '\subsection{Highest Astronomical Tide} \n' if i == 1: s = '\subsection{Lowest Astronomical Tide} \n' if i == 2: s = '\subsection{} \n' fid.write(s) #filename = latex_output[i] #s = '\input{%s} \n' %filename.replace('_','') s = '\input{%s} \n \clearpage \n' %latex_output[i] fid.write(s) s = '\section{Summary} \n \ \input{summary} \n \ \section{References} \n \ \section{Metadata} \n \ \label{sec:metadata} \n \ \input{metadata} \n \ \end{document}' fid.write(s)