source: anuga_work/production/dampier_2006/make_report.py @ 4228

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

(1) add building damage scripts for the study areas and update project.py (2) update report generation scripts (3) update Gantt chart (4) report updates to reflect URS input

File size: 10.9 KB
Line 
1"""
2Generate report for production run
3
4NOTE - this will only work on Windows system (as pylab not installed on unix).
5
6Inputs:
7
8report_title:    title to be included in tex file
9production dirs: dictionary of production directories with a
10                 association to that simulation run, eg high tide,
11                 low tide and MSL.
12                   
13
14Outputs:
15
16* Report generated to scenario_report.tex where the scenario relates
17the name of the production directory this script is being run from.
18* figures used for report stored in the report_figure directory
19NOTE, this directory will need to be committed, as well as
20the latex files.
21
22The report structure is
23
24* Executive Summary
25* Introduction
26* Modelling Methodology
27* Tsunami scenario
28* Data sources
29* Inundation modelling results
30* Impact modelling
31* Summary
32* Acknowledgements
33* References
34* Appendix: Metadata
35* Appendix: Inundation model metadata
36* Appendix: Time series outputs
37
38Other files included in document which require manual intervention:
39
40* an abstract must be written in abstract.tex
41* an introduction must be written in introduction.tex; a basic outline and
42  some of the core inputs are already in place
43* the tsunami-genic event should be discussed in tsunami_scenario.tex
44* a discussion of the ANUGA model is required in anuga.tex
45* a computational_setup.tex file needs to be written for the particular scenario
46* the interpretation of the results needs to be written to interpretation.tex
47* maximum inundation map names need to be included in HAT_map and LAT_map etc.
48* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
49* a summary must be written into summary.tex
50* metadata for the scenario data to be included in metadata.tex
51
52May, June 2006                   
53"""
54
55from os import getcwd, sep, altsep, mkdir, access, F_OK
56import project
57from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
58
59# Derive scenario name
60p = getcwd().split(sep)
61scenario = p[-1] # Last element of absolute CWD path
62scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
63test = scenario_name.split('_')
64if len(test) <> 1:
65    scenario_name = '%s %s' %(test[0], test[1])
66
67# Create report directory
68reportdir = getcwd()+sep+'report07'+sep
69if access(reportdir,F_OK) == 0:
70    mkdir (reportdir)
71   
72# User defined inputs
73report_title = 'Tsunami impact modelling for %s' %scenario_name.title()
74
75is_parallel = True
76if is_parallel == True:
77    nodes = 8
78   
79return_periods = [1000, 100000]
80
81# output directories
82production_dirs_1000 = {'20061116_055135_run': 'Mw 9.0'} # RP 1000 years
83production_dirs_100000 = {'20061116_055135': 'Mw 8.0'} # RP 100000 years
84
85all_prod_dirs = [production_dirs_1000, production_dirs_100000]
86                         
87max_maps_1000 = {'Mw 6.0': 'mw6_map'}
88max_maps_100000 = {'Mw 9.0': 'mw9_map'}
89
90all_maps = [max_maps_1000, max_maps_100000]
91
92# gauge map names
93gauge_map1 = 'dampier_gauges_1.jpg'
94gauge_map2 = 'dampier_gauges_2.jpg'
95
96# Create sections and graphs for each designated production directory
97latex_output = []
98report_name = 'latexoutput'
99
100if is_parallel == True:
101   
102    for j, production_dirs in enumerate(all_prod_dirs):
103       
104        for i in range(nodes):
105            print 'Sending node %d of %d' %(i,nodes)
106            reportname = report_name + '%s' + 'rp%s' %(i,j)
107            swwfiles = {}
108           
109            for label_id in production_dirs.keys():
110                file_loc = project.output_dir + label_id + sep
111                sww_extra = '_P%s_%s' %(i,nodes)
112                swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
113                swwfiles[swwfile] = label_id
114
115                texname, elev_output = sww2timeseries(swwfiles,
116                                                      project.gauge_filename,
117                                                      production_dirs,
118                                                      report = True,
119                                                      reportname = reportname,
120                                                      plot_quantity = ['stage', 'momentum'],
121                                                      generate_fig = True,
122                                                      surface = False,
123                                                      time_min = None,
124                                                      time_max = None,
125                                                      title_on = False,
126                                                      verbose = True)
127               
128                latex_output.append(texname)
129   
130else:
131
132    for i, production_dirs in enumerate(all_prod_dirs):
133
134        swwfiles = {}
135        reportname = report_name + 'rp%s' %(i)
136       
137        for label_id in production_dirs.keys():
138
139            file_loc = project.output_dir + label_id + sep
140            swwfile = file_loc + project.scenario_name + '.sww'
141            swwfiles[swwfile] = label_id
142           
143        texname, elev_output = sww2timeseries(swwfiles,
144                                              project.gauge_filename,
145                                              production_dirs,
146                                              report = True,
147                                              reportname = reportname,
148                                              plot_quantity = ['stage', 'momentum'],
149                                              generate_fig = True,
150                                              surface = False,
151                                              time_min = None,
152                                              time_max = None,
153                                              title_on = False,
154                                              verbose = True)
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)
218
219s = """
220  \maketitle
221
222    \section{Executive Summary}
223    \label{sec:execsum}
224  \input{execsum}
225
226\clearpage
227
228  \\tableofcontents
229 
230  \section{Introduction}
231    \label{sec:intro}
232  \input{introduction}
233
234   \section{Modelling methodology}
235    \label{sec:methodology}
236    \input{modelling_methodology}
237   
238  \section{Tsunami scenarios}
239    \label{sec:tsunamiscenario}
240    \input{tsunami_scenario}
241
242  \section{Data sources}
243    \label{sec:data}
244    \input{data}
245       
246  \section{Inundation modelling results}
247     \label{sec:results}
248         
249"""
250fid.write(s)
251   
252s = '\input{interpretation} \n'
253fid.write(s)
254
255# Assign titles to each production section
256# Must specify one name per section
257for i, max_maps in enumerate(all_maps):
258
259    s = '\subsection{Return Period: %s years} \n \n' %return_periods[i]     
260    fid.write(s)
261
262    production_dirs = all_prod_dirs[i]
263    for name in enumerate(production_dirs.keys()):
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 Dampier 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{Summary}
314     \label{sec:summary}
315     \input{summary}
316
317     \section{Acknowledgements}
318     \input{acknowledgements}
319     
320    \input{references}
321
322\clearpage
323
324    \\appendix
325
326    \section{ANUGA modelling parameters}
327    \label{sec:anugasetup}
328    \input{anuga_setup}
329
330\clearpage
331
332   \section{Metadata}
333     \label{sec:metadata}
334     \input{metadata}
335
336\clearpage
337
338   \section{Time series}
339     \label{sec:timeseries}
340     \input{timeseriesdiscussion}
341     \clearpage
342"""
343fid.write(s)
344
345for i in range(len(latex_output)):
346    if latex_output[i] <> '':
347        s = '\subsection{Return Period: %s years} \n' %return_periods[i]
348        fid.write(s)
349        s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
350        fid.write(s)
351
352s="""
353     \section{Damage modelling inputs}
354     \label{sec:damageinputs}
355     \input{damage_inputs}
356     
357\end{document}
358"""
359fid.write(s)
Note: See TracBrowser for help on using the repository browser.