source: anuga_work/production/hobart_2006/make_report.py @ 3852

Last change on this file since 3852 was 3852, checked in by sexton, 17 years ago

updated results based on refined mesh

File size: 8.6 KB
RevLine 
[3721]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
22* Executive Summary
23* Introduction
24* Modelling Methodology
25* Tsunami scenario
26* Data sources
27* Inundation model
28* Inundation modelling results
29* Impact modelling
30* Summary
31* Acknowledgements
32* References
33* Appendix: Metadata
34* Appendix: Time series outputs
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
41* the tsunami-genic event should be discussed in tsunami_scenario.tex
42* a discussion of the ANUGA model is required in anuga.tex
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
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.
47* a summary must be written into summary.tex
48* metadata for the scenario data to be included in metadata.tex
49
50May, June 2006                   
51"""
52
53from os import getcwd, sep, altsep, mkdir, access, F_OK
54import project
55from anuga.abstract_2d_finite_volumes.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
[3732]71report_title = 'Tsunami impact modelling for Tasmania: %s' %scenario_name.title()
[3721]72
73# WA DLI data
[3852]74production_dirs = {#'20061008_234702': 'Mw 8-7', # 2500 res
[3763]75                   #'20061004_230438': 'Mw 8-7', # 7500 res
[3852]76                   '20061022_224422': 'Mw 8-7', # refined mesh
[3721]77                   '20061006_062319': 'Mw 8-5'} # 2500 res
78
79max_maps = {'Mw 8-7': 'mw87_map',
80            'Mw 8-5': 'mw85_map'}
81
82gauge_map = 'hobart_gauge.jpg'
83
84# Create sections and graphs for each designated production directory
85latex_output = []
86swwfiles = {}
87for label_id in production_dirs.keys():
88   
89    file_loc = project.outputdir + label_id + sep
90    swwfile = file_loc + project.basename + '.sww'
91    swwfiles[swwfile] = label_id
92
93texname, elev_output = sww2timeseries(swwfiles,
94                                      project.gauge_filename,
95                                      production_dirs,
96                                      report = True,
97                                      reportname = 'latexoutput',
98                                      plot_quantity = ['stage', 'speed'],
99                                      surface = False,
100                                      time_min = None,
101                                      time_max = None,
102                                      title_on = False,
103                                      verbose = True)
104
105latex_output.append(texname)
106
107# Start report generation
108# Future: generate_report(reportdir, scenario, report_title,
109# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
110report_name = reportdir + scenario + '_report.tex'
111fid = open(report_name, 'w')
112
113s = """
114% This is based on an automatically generated file (by make_report.py).
115%
116% Manual parts are:
117% * an abstract must be written in abstract.tex
118% * an introduction must be written in introduction.tex; a basic outline and
119%   some of the core inputs are already in place
120% * outline of the modelling methodology provided in modelling_methodology.tex
121% * the tsunami-genic event should be discussed in tsunami_scenario.tex
122% * an computational_setup.tex file needs to be written for the particular scenario
123% * the interpretation of the results needs to be written to interpretation.tex
124% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
125% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
126% * a summary must be written into summary.tex
127% * metadata for the scenario data to be included in metadata.tex
128
129\documentclass{article}
130
131\usepackage{ae} % or {zefonts}
132\usepackage[T1]{fontenc}
133\usepackage[ansinew]{inputenc}
134\usepackage{amsmath}
135\usepackage{amssymb}
136\usepackage{graphicx}
137\usepackage{color}
138\usepackage[colorlinks]{hyperref}
139\usepackage{lscape} %landcape pages support
140\usepackage{setspace}
141\usepackage{rotating}
142\include{appendix}
143\setstretch{1.25}
144\\topmargin 0pt
145\oddsidemargin 0pt
146\evensidemargin 0pt
147\marginparwidth 0.5pt
148\\textwidth \paperwidth
149\\advance\\textwidth -2in
150
151"""
152fid.write(s)
153
154#s = '\\title{%s} \n' %report_title
155#fid.write(s)
156
157s = """
158\date{\\today}
159%\\author{Geoscience Australia}
160
161\\begin{document}
162\\title{
163\\begin{figure}[hbt]
164  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
165\end{figure}
166"""
167fid.write(s)
168s = '%s} '%report_title
169fid.write(s)
170s = """
171  \maketitle
172
173    \section{Executive Summary}
174    \label{sec:execsum}
175  \input{execsum}
176
177  \\tableofcontents
178 
179  \section{Introduction}
180    \label{sec:intro}
181  \input{introduction}
182
183   \section{Modelling methodology}
184    \label{sec:methodology}
185    \input{modelling_methodology}
186   
187  %\section{Tsunami scenarios}
188  %  \label{sec:tsunamiscenario}
189  %  \input{tsunami_scenario}
190
191  \section{Data sources}
192    \label{sec:data}
193    \input{data}
194   
195   \section{Inundation model}
196    \label{sec:anuga}
197    \input{anuga}
198    \input{computational_setup}
199       
200  \section{Inundation modelling results}
201     \label{sec:results}
202         
203"""
204fid.write(s)
205
206# Generate latex output for location points
207s = '\\begin{table} \\begin{center} \n'
208fid.write(s)
209s = '\caption{Defined point locations for %s study area.}' %scenario_name
210fid.write(s)
211s = """
212\label{table:locations}
213\\begin{tabular}{|l|l|l|l|}\hline
214\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
215"""
216fid.write(s)
217
218gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
219
220for name, gauges, elev in zip(locations, gauges, elevation):
221    east = gauges[0]
222    north = gauges[1]
223    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
224    fid.write(s)
225
226s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
227fid.write(s)
228
[3728]229s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map
230fid.write(s)
[3721]231
232= """
233\caption{Point locations used for Hobart study.} 
234\label{fig:points}
235\end{figure}
236"""
237fid.write(s)
238   
239s = '\input{interpretation} \n'
240fid.write(s)
241
242# Assign titles to each production section
243# Must specify one name per section
244for i, name in enumerate(production_dirs.keys()):
245#
246#    s = '\subsection{%s} \n \n' %production_dirs[name]     
247#    fid.write(s)
248
249    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
250    fid.write(s)
251
252# Closing
253
254s = """
255   \section{Impact modelling}
256    \label{sec:impact}
257     \input{damage}
258"""
259#fid.write(s)
260
261#for i, name in enumerate(production_dirs.keys()):
262
263#    s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]]
264#    fid.write(s)
265
266s = """
267  % \section{Impact due to data accuracy}
268  %   \input{discussion}
269  %   \label{sec:issues}
270
271     \section{Summary}
272     \label{sec:summary}
273     \input{summary}
274
275     \section{Acknowledgements}
276     \input{acknowledgements}
277     
278    \input{references}
279
280    \\appendix
281   
282   \section{Metadata}
283     \label{sec:metadata}
284     \input{metadata}
285
286\pagebreak
287
288   \section{Time series}
289     \label{sec:timeseries}
290"""
291fid.write(s)
292
293s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
294fid.write(s)
295
296s="""
297
298%\pagebreak
299
300 %  \section{Damage modelling inputs}
301 %    \label{sec:damageinputs}
302 %    \input{damage_inputs}
303
304\end{document}
305"""
306fid.write(s)
Note: See TracBrowser for help on using the repository browser.