source: production/onslow_2006/make_report.py @ 3392

Last change on this file since 3392 was 3367, checked in by sexton, 19 years ago

tex fixups

File size: 8.8 KB
RevLine 
[3005]1"""
2Generate report for production run
3
4Inputs:
5
6report_title:    title to be included in tex file
7production dirs: dictionary of production directories with a
8                 association to that simulation run, eg high tide,
9                 low tide and MSL.
10                   
11
12Outputs:
13
14* Report generated to scenario_report.tex where the scenario relates
15the name of the production directory this script is being run from.
16* figures used for report stored in the report_figure directory
17NOTE, this directory will need to be committed, as well as
18the latex files.
19
20The report structure is
21
[3190]22* Executive Summary
[3005]23* Introduction
[3169]24* Modelling Methodology
[3082]25* Tsunami scenario
[3347]26* Data sources
[3082]27* Inundation model
[3347]28* Inundation modelling results
[3082]29* Impact modelling
[3005]30* Summary
[3361]31* Acknowledgements
[3005]32* References
33* Appendix: Metadata
[3082]34* Appendix: Time series outputs
[3005]35
36Other files included in document which require manual intervention:
37
38* an abstract must be written in abstract.tex
39* an introduction must be written in introduction.tex; a basic outline and
40  some of the core inputs are already in place
[3082]41* the tsunami-genic event should be discussed in tsunami_scenario.tex
42* a discussion of the ANUGA model is required in anuga.tex
[3005]43* a computational_setup.tex file needs to be written for the particular scenario
44* the interpretation of the results needs to be written to interpretation.tex
[3082]45* maximum inundation map names need to be included in HAT_map and LAT_map etc.
46* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
[3005]47* a summary must be written into summary.tex
48* metadata for the scenario data to be included in metadata.tex
49
[3082]50May, June 2006                   
[3005]51"""
52
53from os import getcwd, sep, altsep, mkdir, access, F_OK
54import project
55from pyvolution.util import sww2timeseries, get_gauges_from_file
56
57# Derive scenario name
58p = getcwd().split(sep)
59scenario = p[-1] # Last element of absolute CWD path
60scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
61test = scenario_name.split('_')
62if len(test) <> 1:
63    scenario_name = '%s %s' %(test[0], test[1])
64
65# Create report directory
66reportdir = getcwd()+sep+'report'+sep
67if access(reportdir,F_OK) == 0:
68    mkdir (reportdir)
69   
70# User defined inputs
71report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title()
72
[3252]73# DTED data
[3215]74#production_dirs = {'20060426_004129': '1.5 AHD',
75#                   '20060426_004237': '-1.5 AHD',
76#                   '20060515_001733': '0 AHD'}
[3252]77#damage_maps = {'1.5 AHD': 'HAT_damage',
78#               '-1.5 AHD': 'LAT_damage',
79#               '0 AHD': 'MSL_damage'}
[3005]80
[3252]81# WA DLI data
[3285]82production_dirs = {'20060704_063234': 'MSL',
83                   '20060704_063005': 'HAT',
[3300]84                   '20060706_235246': 'LAT'}
[3082]85
[3265]86max_maps = {'MSL': 'MSL_map',
87            'HAT': 'HAT_map',
88            'LAT': 'LAT_map'}
[3252]89
[3301]90gauge_map = 'onslow_dli_gauge.jpg'
[3082]91
[3252]92compare_output = 'compare_output_datasets'
93
[3005]94# Create sections and graphs for each designated production directory
95latex_output = []
[3082]96swwfiles = {}
[3005]97for label_id in production_dirs.keys():
98   
99    file_loc = project.outputdir + label_id + sep
100    swwfile = file_loc + project.basename + '.sww'
[3082]101    swwfiles[swwfile] = label_id
[3005]102
[3188]103texname, elev_output = sww2timeseries(swwfiles,
104                                      project.gauge_filename,
105                                      production_dirs,
106                                      report = True,
107                                      reportname = 'latexoutput',
108                                      plot_quantity = ['stage', 'speed'],
109                                      surface = False,
110                                      time_min = None,
111                                      time_max = None,
112                                      title_on = False,
113                                      verbose = True)
[3005]114
[3082]115latex_output.append(texname)
[3005]116
117# Start report generation
[3082]118# Future: generate_report(reportdir, scenario, report_title,
119# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
[3005]120report_name = reportdir + scenario + '_report.tex'
121fid = open(report_name, 'w')
122
123s = """
124% This is based on an automatically generated file (by make_report.py).
125%
126% Manual parts are:
127% * an abstract must be written in abstract.tex
128% * an introduction must be written in introduction.tex; a basic outline and
129%   some of the core inputs are already in place
[3169]130% * outline of the modelling methodology provided in modelling_methodology.tex
[3005]131% * the tsunami-genic event should be discussed in tsunami_scenario.tex
132% * an computational_setup.tex file needs to be written for the particular scenario
133% * the interpretation of the results needs to be written to interpretation.tex
134% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
135% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
136% * a summary must be written into summary.tex
137% * metadata for the scenario data to be included in metadata.tex
138
139\documentclass{article}
140
141\usepackage{ae} % or {zefonts}
142\usepackage[T1]{fontenc}
143\usepackage[ansinew]{inputenc}
144\usepackage{amsmath}
145\usepackage{amssymb}
146\usepackage{graphicx}
147\usepackage{color}
148\usepackage[colorlinks]{hyperref}
149\usepackage{lscape} %landcape pages support
150\usepackage{setspace}
[3367]151\usepackage{rotating}
[3267]152\include{appendix}
[3005]153\setstretch{1.25}
154\\topmargin 0pt
155\oddsidemargin 0pt
156\evensidemargin 0pt
157\marginparwidth 0.5pt
158\\textwidth \paperwidth
159\\advance\\textwidth -2in
160
161"""
162fid.write(s)
163
[3237]164#s = '\\title{%s} \n' %report_title
165#fid.write(s)
[3005]166
167s = """
168\date{\\today}
[3205]169%\\author{Geoscience Australia}
[3210]170
171\\begin{document}
[3237]172\\title{
[3205]173\\begin{figure}[hbt]
[3237]174  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
[3205]175\end{figure}
[3237]176"""
177fid.write(s)
178s = '%s} '%report_title
179fid.write(s)
180s = """
[3221]181  \maketitle
182
[3190]183    \section{Executive Summary}
184    \label{sec:execsum}
185  \input{execsum}
[3325]186
187  \\tableofcontents
[3005]188 
189  \section{Introduction}
190    \label{sec:intro}
191  \input{introduction}
[3169]192
193   \section{Modelling methodology}
194    \label{sec:methodology}
195    \input{modelling_methodology}
196   
[3082]197  \section{Tsunami scenarios}
[3094]198    \label{sec:tsunamiscenario}
[3082]199    \input{tsunami_scenario}
200
[3347]201  \section{Data sources}
202    \label{sec:data}
203    \input{data}
204   
[3136]205   \section{Inundation model}
[3082]206    \label{sec:anuga}
207    \input{anuga}
208    \input{computational_setup}
[3347]209       
210  \section{Inundation modelling results}
[3005]211     \label{sec:results}
[3082]212         
[3005]213"""
214fid.write(s)
215
[3082]216# Generate latex output for location points
[3268]217s = '\\begin{table} \\begin{center} \n'
[3005]218fid.write(s)
[3330]219s = '\caption{Defined point locations for %s study area.}' %scenario_name
[3005]220fid.write(s)
221s = """
[3268]222\label{table:locations}
[3005]223\\begin{tabular}{|l|l|l|l|}\hline
[3082]224\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
[3005]225"""
226fid.write(s)
227
[3082]228gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
[3005]229
[3082]230for name, gauges, elev in zip(locations, gauges, elevation):
[3005]231    east = gauges[0]
232    north = gauges[1]
233    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
234    fid.write(s)
235
236s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
237fid.write(s)
238
[3082]239s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map
240fid.write(s)
241
242= """
243\caption{Point locations used for Onslow study.} 
244\label{fig:points}
245\end{figure}
246"""
247fid.write(s)
248   
[3005]249s = '\input{interpretation} \n'
250fid.write(s)
251
[3082]252# Assign titles to each production section
[3005]253# Must specify one name per section
254for i, name in enumerate(production_dirs.keys()):
[3082]255#
256#    s = '\subsection{%s} \n \n' %production_dirs[name]     
257#    fid.write(s)
[3005]258
259    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
260    fid.write(s)
261
262# Closing
263
264s = """
[3136]265   \section{Impact modelling}
266    \label{sec:impact}
[3005]267     \input{damage}
268"""
269fid.write(s)
270
[3136]271#for i, name in enumerate(production_dirs.keys()):
[3005]272
[3136]273#    s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]]
274#    fid.write(s)
[3005]275
276s = """
[3252]277   \section{Impact due to data accuracy}
[3232]278     \input{discussion}
[3241]279     \label{sec:issues}
[3232]280
281     \section{Summary}
[3367]282     \label{sec:summary}
[3005]283     \input{summary}
[3361]284
285     \section{Acknowledgements}
286     \input{acknowledgements}
[3005]287     
[3015]288    \input{references}
[3267]289
[3326]290    \\appendix
[3015]291   
[3005]292   \section{Metadata}
293     \label{sec:metadata}
294     \input{metadata}
295
[3333]296\pagebreak
297
[3082]298   \section{Time series}
299     \label{sec:timeseries}
[3252]300"""
301fid.write(s)
302
303s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
304fid.write(s)
305
306s="""
[3333]307
308\pagebreak
309
[3201]310   \section{Damage modelling inputs}
311     \label{sec:damageinputs}
312     \input{damage_inputs}
[3252]313
[3347]314\end{document}
[3005]315"""
316fid.write(s)
Note: See TracBrowser for help on using the repository browser.