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

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

(1) updates to make_report script to handle multiple events for multiple return periods (2) take Onslow changes through to Port Hedland and Dampier

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