source: anuga_work/production/dampier_2006/make_report_cipma.py @ 4134

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

report updates - taking Trevor's comments into account for revision of Onslow report

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