source: anuga_work/production/dampier_2006/make_report_cipma.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: 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+'report'+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
75# WA DLI data
76production_dirs = {#'20061101_053132_run': 'big event'} # parallel
77                    #'20061101_054432_run': 'big event'} # sequential
78                    #'20061107_070805_run': 'Mw 9.0',
79                    #'20061116_055135_run': 'Mw 9.0'} # multiple interior regions
80                    #'20061116_062924_run': 'Mw 9.0'} # one interior region
81                    '20070426_045818_run': '1 in 10000 wave height'} # revised run with water flowing in the correct direction!
82
83is_parallel = False
84if is_parallel == True:
85    nodes = 8
86
87max_maps = {'1 in 10000 wave height': 'mw9_map'}
88
89gauge_map1 = 'dampier_gauges_1.jpg'
90gauge_map2 = 'dampier_gauges_2.jpg'
91
92# Create sections and graphs for each designated production directory
93latex_output = []
94report_name = 'latexoutput_cipma'
95
96if is_parallel == True:
97
98    for i in range(nodes):
99        print 'Sending node %d of %d' %(i,nodes)
100        swwfiles = {}
101        reportname = report_name + '_%s' %(i)
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.scenario_name + sww_extra + '.sww'
106            swwfiles[swwfile] = label_id
107
108            texname, elev_output = sww2timeseries(swwfiles,
109                                                  project.gauges_dir_name,
110                                                  production_dirs,
111                                                  report = True,
112                                                  reportname = reportname,
113                                                  plot_quantity = ['stage', 'speed'],
114                                                  generate_fig = True,
115                                                  surface = False,
116                                                  time_min = None,
117                                                  time_max = None,
118                                                  time_unit = 'hours',
119                                                  title_on = False,
120                                                  use_cache = True,
121                                                  verbose = True)
122           
123            latex_output.append(texname)
124   
125else:
126    swwfiles = {}
127    for label_id in production_dirs.keys():
128
129        file_loc = project.output_dir + label_id + sep
130        swwfile = file_loc + project.scenario_name + '.sww'
131        swwfiles[swwfile] = label_id
132       
133    texname, elev_output = sww2timeseries(swwfiles,
134                                          project.gauges_dir_name,
135                                          production_dirs,
136                                          report = True,
137                                          reportname = report_name,
138                                          plot_quantity = ['stage', 'speed'],
139                                          generate_fig = True,
140                                          surface = False,
141                                          time_min = None,
142                                          time_max = None,
143                                          time_unit = 'hours',
144                                          title_on = False,
145                                          use_cache = True,
146                                          verbose = True)
147    latex_output.append(texname)
148
149# Start report generation
150# Future: generate_report(reportdir, scenario, report_title,
151# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
152report_name = reportdir + scenario + '_report_CIPMA.tex'
153fid = open(report_name, 'w')
154
155s = """
156% This is based on an automatically generated file (by make_report.py).
157%
158% Manual parts are:
159% * an abstract must be written in abstract.tex
160% * an introduction must be written in introduction.tex; a basic outline and
161%   some of the core inputs are already in place
162% * outline of the modelling methodology provided in modelling_methodology.tex
163% * the tsunami-genic event should be discussed in tsunami_scenario.tex
164% * an computational_setup.tex file needs to be written for the particular scenario
165% * the interpretation of the results needs to be written to interpretation.tex
166% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
167% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
168% * a summary must be written into summary.tex
169% * metadata for the scenario data to be included in metadata.tex
170
171\documentclass{article}
172
173\usepackage{ae} % or {zefonts}
174\usepackage[T1]{fontenc}
175\usepackage[ansinew]{inputenc}
176\usepackage{amsmath}
177\usepackage{amssymb}
178\usepackage{graphicx}
179\usepackage{color}
180\usepackage[colorlinks]{hyperref}
181\usepackage{lscape} %landcape pages support
182\usepackage{setspace}
183\usepackage{rotating}
184\usepackage{pdfpages}
185\include{appendix}
186\setstretch{1.25}
187\\topmargin 0pt
188\oddsidemargin 0pt
189\evensidemargin 0pt
190\marginparwidth 0.5pt
191\\textwidth \paperwidth
192\\advance\\textwidth -2in
193
194"""
195fid.write(s)
196
197s = """
198\date{\\today}
199%\\author{Geoscience Australia}
200
201\\begin{document}
202\\title{
203\\begin{figure}[hbt]
204  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
205\end{figure}
206"""
207fid.write(s)
208s = '%s} '%report_title
209fid.write(s)
210s = """
211  \maketitle
212
213    \section{Executive Summary}
214    \label{sec:execsum}
215  \input{execsum}
216
217  \\tableofcontents
218 
219   \section{Modelling methodology}
220    \label{sec:methodology}
221    \input{modelling_methodology}
222
223  \section{Data sources}
224    \label{sec:data}
225    \input{data}
226   
227   %\section{Inundation model}
228   % \label{sec:anuga}
229   % \input{anuga}
230   % \input{computational_setup}
231       
232  \section{Inundation modelling results}
233     \label{sec:results}
234         
235"""
236fid.write(s)
237
238# Generate latex output for location points
239##s = '\\begin{table} \\begin{center} \n'
240##fid.write(s)
241##s = '\caption{Defined point locations for %s study area.}' %scenario_name
242##fid.write(s)
243##s = """
244##\label{table:locations}
245##\\begin{tabular}{|l|l|l|l|}\hline
246##\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation (m)}\\\\ \hline
247##"""
248##fid.write(s)
249##
250##gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
251##
252##for name, gauges, elev in zip(locations, gauges, elevation):
253##    east = gauges[0]
254##    north = gauges[1]
255##    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
256##    fid.write(s)
257##
258##s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
259##fid.write(s)
260##
261
262s = '\\begin{figure}[hbt] \centerline{\includegraphics[scale = 0.5]{../report_figures/%s}}' %gauge_map2
263fid.write(s)
264= """
265\caption{Point locations used for Dampier study; surrounding the facility.
266See Appendix \\ref{sec:timeseries} for stage and momentum results.
267
268\label{fig:points2}
269\end{figure}
270"""
271fid.write(s)
272s = '\\begin{figure}[hbt] \centerline{\includegraphics[scale=0.5]{../report_figures/%s}}' %gauge_map1
273fid.write(s)
274= """
275\caption{Point locations used for Dampier study; section
276of the pipeline towards the boundary of the region and other boundary gauges.
277See Appendix \\ref{sec:timeseries} for stage and momentum results.} 
278\label{fig:points3}
279\end{figure}
280"""
281fid.write(s)
282   
283#s = '\input{interpretation} \n'
284#fid.write(s)
285
286# Assign titles to each production section
287# Must specify one name per section
288for i, name in enumerate(production_dirs.keys()):
289
290    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
291    fid.write(s)
292
293# Closing
294
295
296s = """
297
298     \section{Summary}
299     \label{sec:summary}
300     \input{summary}
301
302     %\section{Acknowledgements}
303     %\input{acknowledgements}
304     
305    \input{references}
306
307    \\appendix
308
309   \section{ANUGA modelling parameters}
310\label{sec:anugasetup}
311\input{anuga_setup}
312
313   \section{Metadata}
314     \label{sec:metadata}
315     \input{metadata}
316     
317\section{ANUGA modelling parameters}
318\label{sec:anugasetup}
319\input{anuga_setup}
320
321\clearpage
322
323   \section{Time series}
324     \label{sec:timeseries}
325"""
326fid.write(s)
327
328for i in range(len(latex_output)):
329    if latex_output[i] <> '':
330        s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
331        fid.write(s)
332
333s="""
334\end{document}
335"""
336fid.write(s)
Note: See TracBrowser for help on using the repository browser.