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

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

dampier report updates

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