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

Last change on this file since 3862 was 3862, checked in by sexton, 18 years ago

results for new gauges

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