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

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