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

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

update for gauge generation script

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