""" 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 * Executive Summary * Introduction * Modelling Methodology * Tsunami scenario * Inundation model * Data sources * Modelling results * Impact modelling * Summary * References * Appendix: Metadata * Appendix: Time series outputs 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 * the tsunami-genic event should be discussed in tsunami_scenario.tex * a discussion of the ANUGA model is required in anuga.tex * a computational_setup.tex file needs to be written for the particular scenario * the interpretation of the results needs to be written to interpretation.tex * maximum inundation map names need to be included in HAT_map and LAT_map etc. * damage modelling map names need to be included in HAT_damage and LAT_damage etc. * a summary must be written into summary.tex * metadata for the scenario data to be included in metadata.tex May, June 2006 """ from os import getcwd, sep, altsep, mkdir, access, F_OK import project from pyvolution.util import sww2timeseries, get_gauges_from_file # 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]) # Create report directory reportdir = getcwd()+sep+'report'+sep if access(reportdir,F_OK) == 0: mkdir (reportdir) # User defined inputs report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title() # DTED data #production_dirs = {'20060426_004129': '1.5 AHD', # '20060426_004237': '-1.5 AHD', # '20060515_001733': '0 AHD'} #damage_maps = {'1.5 AHD': 'HAT_damage', # '-1.5 AHD': 'LAT_damage', # '0 AHD': 'MSL_damage'} # WA DLI data production_dirs = {'20060704_063234': 'MSL', '20060704_063005': 'HAT', '20060704_063112': 'LAT'} max_maps = {'MSL': 'MSL_map', 'HAT': 'HAT_map', 'LAT': 'LAT_map'} gauge_map = 'onslow_gauge_map.jpg' compare_output = 'compare_output_datasets' # 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, elev_output = sww2timeseries(swwfiles, project.gauge_filename, production_dirs, report = True, reportname = 'latexoutput', plot_quantity = ['stage', 'speed'], surface = False, time_min = None, time_max = None, title_on = False, verbose = True) latex_output.append(texname) # Start report generation # Future: generate_report(reportdir, scenario, report_title, # project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output) 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 % * outline of the modelling methodology provided in modelling_methodology.tex % * the tsunami-genic event should be discussed in tsunami_scenario.tex % * an computational_setup.tex file needs to be written for the particular scenario % * the interpretation of the results needs to be written to interpretation.tex % * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc. % * damage modelling maps need to be included in HAT_damage and LAT_damage etc. % * 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} \include{appendix} \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} \\title{ \\begin{figure}[hbt] \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}} \end{figure} """ fid.write(s) s = '%s} '%report_title fid.write(s) s = """ \maketitle \\tableofcontents \section{Executive Summary} \label{sec:execsum} \input{execsum} \section{Introduction} \label{sec:intro} \input{introduction} \section{Modelling methodology} \label{sec:methodology} \input{modelling_methodology} \section{Tsunami scenarios} \label{sec:tsunamiscenario} \input{tsunami_scenario} \section{Inundation model} \label{sec:anuga} \input{anuga} \input{computational_setup} \section{Data sources} \label{sec:data} \input{data} \section{Modelling results} \label{sec:results} """ fid.write(s) # Generate latex output for location points s = '\\begin{table} \\begin{center} \n' fid.write(s) s = '\caption{Defined point locations for %s study area.}' %scenario fid.write(s) s = """ \label{table:locations} \\begin{tabular}{|l|l|l|l|}\hline \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline """ fid.write(s) gauges, locations, elevation = get_gauges_from_file(project.gauge_filename) for name, gauges, elev in zip(locations, gauges, elevation): east = gauges[0] north = gauges[1] s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev) fid.write(s) 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 Onslow study.} \label{fig:points} \end{figure} """ fid.write(s) s = '\input{interpretation} \n' 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' %max_maps[production_dirs[name]] fid.write(s) # Closing s = """ \section{Impact modelling} \label{sec:impact} \input{damage} """ fid.write(s) #for i, name in enumerate(production_dirs.keys()): # s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]] # fid.write(s) s = """ \section{Impact due to data accuracy} \input{discussion} \label{sec:issues} \section{Summary} \input{summary} \input{references} \appendix \section{Metadata} \label{sec:metadata} \input{metadata} \section{Time series} \label{sec:timeseries} """ fid.write(s) s = '\input{%s} \n \clearpage \n \n' %latex_output[0] fid.write(s) s=""" \section{Damage modelling inputs} \label{sec:damageinputs} \input{damage_inputs} \section{Time series} \label{sec:timeseriescompare} """ fid.write(s) s = '\input{%s} \n \clearpage \n \n' %compare_output fid.write(s) s = '\end{document}' fid.write(s)