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

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

update poly for Broome

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