""" Generate report for production run Inputs: report_title: title to be included in tex file production dirs: dictionary of production directories with a association to that simulation run, 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 the report_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 * Damage modelling * Summary * References * Appendix: Metadata Other files included in document which require manual intervention: * 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 results.tex file needs to be written for the particular scenario * 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, altsep, mkdir, access, F_OK import project from pyvolution.util import sww2timeseries # Derive scenario name p = getcwd().split(sep) scenario = p[-1] # Last element of absolute CWD path scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` test = scenario_name.split('_') if len(test) <> 1: scenario_name = '%s %s' %(test[0], test[1]) # User defined inputs report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title() production_dirs = {'': 'Highest Astronomical Tide', '': 'Lowest Astronomical Tide'} # Create sections and graphs for each designated production directory latex_output = [] for label_id in production_dirs.keys(): file_loc = project.outputdir + label_id + sep swwfile = file_loc + project.basename + '.sww' texname = sww2timeseries(swwfile, project.gauge_filename, label_id, report = True, plot_quantity = ['stage', 'velocity', 'bearing'], time_min = None, time_max = None, title_on = False, verbose = True) latex_output.append(texname) # Start report generation reportdir = getcwd()+sep+'report'+sep if access(reportdir,F_OK) == 0: mkdir (reportdir) report_name = reportdir + scenario + '_report.tex' fid = open(report_name, 'w') s = """ % This is based on an automatically generated file (by make_report.py). % % Manual parts are: % * 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 results.tex file needs to be written for the particular scenario % * 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 \documentclass{article} \usepackage{ae} % or {zefonts} \usepackage[T1]{fontenc} \usepackage[ansinew]{inputenc} \usepackage{amsmath} \usepackage{amssymb} \usepackage{graphicx} \usepackage{color} \usepackage[colorlinks]{hyperref} \usepackage{lscape} %landcape pages support \usepackage{setspace} \setstretch{1.25} \\topmargin 0pt \oddsidemargin 0pt \evensidemargin 0pt \marginparwidth 0.5pt \\textwidth \paperwidth \\advance\\textwidth -2in """ fid.write(s) s = '\\title{%s} \n' %report_title fid.write(s) s = """ \date{\\today} \\author{Geoscience Australia} \\begin{document} \maketitle \\begin{abstract} \input{abstract} \end{abstract} \\tableofcontents \section{Introduction} \label{sec:intro} \input{introduction} \section{Data sources} \label{sec:data} \input{data} \section{Tsunami scenarios} \label{sec:tsunami_scenarios} \input{tsunami_scenario} \section{Inundation modelling results} \label{sec:results} \input{results} """ fid.write(s) # Assign titles to each production section # Must specify one name per section for i, name in enumerate(production_dirs.keys()): s = '\subsection{%s} \n \n' %production_dirs[name] fid.write(s) s = '\input{%s} \n \clearpage \n \n' %latex_output[i] fid.write(s) # Closing s = """ \section{Damage modelling} \input{damage} \section{Summary} \input{summary} \section{References} \section{Metadata} \label{sec:metadata} \input{metadata} \end{document} """ fid.write(s)