source: anuga_work/production/pt_hedland_2006/make_report.py @ 4631

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

update project file to include newly acquired residential building data from EVP

File size: 11.2 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* References
32* Appendix: Metadata
33* Appendix: Time series outputs
34
35Other files included in document which require manual intervention:
36
37* an abstract must be written in abstract.tex
38* an introduction must be written in introduction.tex; a basic outline and
39  some of the core inputs are already in place
40* the tsunami-genic event should be discussed in tsunami_scenario.tex
41* a discussion of the ANUGA model is required in anuga.tex
42* a computational_setup.tex file needs to be written for the particular scenario
43* the interpretation of the results needs to be written to interpretation.tex
44* maximum inundation map names need to be included in HAT_map and LAT_map etc.
45* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
46* a summary must be written into summary.tex
47* metadata for the scenario data to be included in metadata.tex
48
49May, June 2006                   
50"""
51
52from os import getcwd, sep, altsep, mkdir, access, F_OK
53import project
54from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
55
56# Derive scenario name
57p = getcwd().split(sep)
58scenario = p[-1] # Last element of absolute CWD path
59scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
60test = scenario_name.split('_')
61if len(test) <> 1:
62    scenario_name = '%s %s' %(test[0], test[1])
63
64# Create report directory
65reportdir = getcwd()+sep+'report'+sep
66if access(reportdir,F_OK) == 0:
67    mkdir (reportdir)
68   
69# User defined inputs
70report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title()
71
72is_parallel = False
73if is_parallel == True:
74    nodes = 8
75   
76# WA DLI data
77production_dirs = {'20060707_001859': 'MSL',
78                   '20060707_003301': 'HAT',
79                   '20060707_003424': 'LAT'}
80
81all_prod_dirs = [production_dirs]
82
83max_maps = {'MSL': 'MSL_map',
84            'HAT': 'HAT_map',
85            'LAT': 'LAT_map'}
86
87gauge_map = 'pt_hedland_gauge.jpg'
88
89# Create sections and graphs for each designated production directory
90latex_output = []
91report_name = 'latexoutput'
92swwfiles = {}
93if is_parallel == True:
94
95    for j, production_dirs in enumerate(all_prod_dirs):
96       
97        for i in range(nodes):
98            print 'Sending node %d of %d' %(i,nodes)
99            swwfiles = {}
100            reportname = report_name + '%s' + 'rp%s' %(i,j)
101           
102            for label_id in production_dirs.keys():
103                file_loc = project.output_dir + label_id + sep
104                sww_extra = '_P%s_%s' %(i,nodes)
105                swwfile = file_loc + project.basename + sww_extra + '.sww'
106                #swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
107                swwfiles[swwfile] = label_id
108
109                texname, elev_output = sww2timeseries(swwfiles,
110                                                      project.gauge_filename,
111                                                      production_dirs,
112                                                      report = True,
113                                                      reportname = reportname,
114                                                      plot_quantity = ['stage', 'speed'],
115                                                      generate_fig = True,
116                                                      surface = False,
117                                                      time_min = None,
118                                                      time_max = None,
119                                                      time_unit = 'hours',
120                                                      title_on = False,
121                                                      use_cache = True,
122                                                      verbose = True)
123               
124                latex_output.append(texname)
125   
126else:
127
128    for i, production_dirs in enumerate(all_prod_dirs):
129
130        swwfiles = {}
131        reportname = report_name + 'rp%s' %(i)
132       
133        for label_id in production_dirs.keys():
134
135            file_loc = project.outputdir + label_id + sep
136            swwfile = file_loc + project.basename + '.sww'
137            #swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
138            swwfiles[swwfile] = label_id
139           
140        texname, elev_output = sww2timeseries(swwfiles,
141                                              project.gauge_filename,
142                                              production_dirs,
143                                              report = True,
144                                              reportname = reportname,
145                                              plot_quantity = ['stage', 'speed'],
146                                              generate_fig = True,
147                                              surface = False,
148                                              time_min = None,
149                                              time_max = None,
150                                              time_unit = 'hours',
151                                              title_on = False,
152                                              use_cache = True,
153                                              verbose = True)
154       
155        latex_output.append(texname)
156   
157# Start report generation
158# Future: generate_report(reportdir, scenario, report_title,
159# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
160report_name = reportdir + scenario + '_report.tex'
161fid = open(report_name, 'w')
162
163s = """
164% This is based on an automatically generated file (by make_report.py).
165%
166% Manual parts are:
167% * an abstract must be written in abstract.tex
168% * an introduction must be written in introduction.tex; a basic outline and
169%   some of the core inputs are already in place
170% * outline of the modelling methodology provided in modelling_methodology.tex
171% * the tsunami-genic event should be discussed in tsunami_scenario.tex
172% * an computational_setup.tex file needs to be written for the particular scenario
173% * the interpretation of the results needs to be written to interpretation.tex
174% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
175% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
176% * a summary must be written into summary.tex
177% * metadata for the scenario data to be included in metadata.tex
178
179\documentclass{article}
180
181\usepackage{ae} % or {zefonts}
182\usepackage[T1]{fontenc}
183\usepackage[ansinew]{inputenc}
184\usepackage{amsmath}
185\usepackage{amssymb}
186\usepackage{graphicx}
187\usepackage{color}
188\usepackage[colorlinks]{hyperref}
189\usepackage{lscape} %landcape pages support
190\usepackage{setspace}
191\usepackage{rotating}
192\usepackage{pdfpages}
193\include{appendix}
194\setstretch{1.25}
195\\topmargin 0pt
196\oddsidemargin 0pt
197\evensidemargin 0pt
198\marginparwidth 0.5pt
199\\textwidth \paperwidth
200\\advance\\textwidth -2in
201
202"""
203fid.write(s)
204
205s = """
206\date{\\today}
207%\\author{Geoscience Australia}
208
209\\begin{document}
210\\title{
211\\begin{figure}[hbt]
212  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
213\end{figure}
214"""
215fid.write(s)
216s = '%s} '%report_title
217fid.write(s)
218s = """
219  \maketitle
220
221    \section{Executive Summary}
222    \label{sec:execsum}
223  \input{execsum}
224
225\clearpage
226
227  \\tableofcontents
228 
229  \section{Introduction}
230    \label{sec:intro}
231  \input{introduction}
232
233   \section{Modelling methodology}
234    \label{sec:methodology}
235    \input{modelling_methodology}
236   
237  \section{Tsunami scenarios}
238    \label{sec:tsunamiscenario}
239    \input{tsunami_scenario}
240
241  \section{Data sources}
242    \label{sec:data}
243    \input{data}
244       
245  \section{Inundation modelling results}
246     \label{sec:results}
247         
248"""
249fid.write(s)
250   
251s = '\input{interpretation} \n'
252fid.write(s)
253
254# Assign titles to each production section
255# Must specify one name per section
256for i, max_maps in enumerate(all_maps):
257
258    s = '\subsection{Return Period: %s years} \n \n' %return_periods[i]     
259    fid.write(s)
260
261    production_dirs = all_prod_dirs[i]
262    for i, name in enumerate(production_dirs.keys()):
263
264        s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
265        fid.write(s)
266
267# Generate latex output for location points
268s = '\\begin{table} \\begin{center} \n'
269fid.write(s)
270s = '\caption{Defined point locations for %s study area.}' %scenario_name.title()
271fid.write(s)
272s = """
273\label{table:locations}
274\\begin{tabular}{|l|l|l|l|}\hline
275\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline
276"""
277fid.write(s)
278
279gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
280
281for name, gauges, elev in zip(locations, gauges, elevation):
282    east = gauges[0]
283    north = gauges[1]
284    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
285    fid.write(s)
286
287s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
288fid.write(s)
289
290#s = '\\begin{figure}[h] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map
291s = '\\begin{figure}[h] \n \centerline{ \includegraphics[scale=0.7]{../report_figures/%s}}' %gauge_map
292fid.write(s)
293
294= """
295\caption{Point locations used for Port Hedland study.} 
296\label{fig:points}
297\end{figure}
298
299\clearpage
300"""
301fid.write(s)
302
303# Closing
304
305s = """
306   \section{Impact modelling}
307    \label{sec:impact}
308     \input{damage}
309"""
310fid.write(s)
311
312s = """
313  % \section{Impact due to data accuracy}
314  %   \input{discussion}
315  %   \label{sec:issues}
316
317     \section{Summary}
318     \label{sec:summary}
319     \input{summary}
320
321     \section{Acknowledgements}
322     \input{acknowledgements}
323     
324    \input{references}
325
326\clearpage
327
328    \\appendix
329
330    \section{ANUGA modelling parameters}
331    \label{sec:anugasetup}
332    \input{anuga_setup}
333
334\clearpage
335
336   \section{Metadata}
337     \label{sec:metadata}
338     \input{metadata}
339
340\clearpage
341
342   \section{Time series}
343     \label{sec:timeseries}
344     \input{timeseriesdiscussion}
345     \clearpage
346"""
347fid.write(s)
348
349for i in range(len(latex_output)):
350    if latex_output[i] <> '':
351        s = '\subsection{Return Period: %s years} \n' %return_periods[i]
352        fid.write(s)
353        s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
354        fid.write(s)
355
356s="""
357
358   \section{Damage modelling inputs}
359     \label{sec:damageinputs}
360     \input{damage_inputs}
361
362\end{document}
363"""
364fid.write(s)
Note: See TracBrowser for help on using the repository browser.