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

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

(i) update sww2timeseries so can handle gauges which don't fall within sww domain (ii) script for generating report for dampier based on sww files from parallel setup

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\include{appendix}
175\setstretch{1.25}
176\\topmargin 0pt
177\oddsidemargin 0pt
178\evensidemargin 0pt
179\marginparwidth 0.5pt
180\\textwidth \paperwidth
181\\advance\\textwidth -2in
182
183"""
184fid.write(s)
185
186s = """
187\date{\\today}
188%\\author{Geoscience Australia}
189
190\\begin{document}
191\\title{
192\\begin{figure}[hbt]
193  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
194\end{figure}
195"""
196fid.write(s)
197s = '%s} '%report_title
198fid.write(s)
199s = """
200  \maketitle
201
202    \section{Executive Summary}
203    \label{sec:execsum}
204  \input{execsum}
205
206  \\tableofcontents
207 
208   \section{Modelling methodology}
209    \label{sec:methodology}
210    \input{modelling_methodology}
211
212  \section{Data sources}
213    \label{sec:data}
214    \input{data}
215   
216   \section{Inundation model}
217    \label{sec:anuga}
218    \input{anuga}
219    \input{computational_setup}
220       
221  \section{Inundation modelling results}
222     \label{sec:results}
223         
224"""
225fid.write(s)
226
227# Generate latex output for location points
228s = '\\begin{table} \\begin{center} \n'
229fid.write(s)
230s = '\caption{Defined point locations for %s study area.}' %scenario_name
231fid.write(s)
232s = """
233\label{table:locations}
234\\begin{tabular}{|l|l|l|l|}\hline
235\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
236"""
237fid.write(s)
238
239gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
240
241for name, gauges, elev in zip(locations, gauges, elevation):
242    east = gauges[0]
243    north = gauges[1]
244    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
245    fid.write(s)
246
247s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
248fid.write(s)
249
250#s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map
251#fid.write(s)
252
253#s  = """
254#\caption{Point locations used for Dampier study.} 
255#\label{fig:points}
256#\end{figure}
257#"""
258#fid.write(s)
259   
260#s = '\input{interpretation} \n'
261#fid.write(s)
262
263# Assign titles to each production section
264# Must specify one name per section
265#for i, name in enumerate(production_dirs.keys()):
266#
267#    s = '\subsection{%s} \n \n' %production_dirs[name]     
268#    fid.write(s)
269
270    #s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
271    #fid.write(s)
272
273# Closing
274
275
276s = """
277
278     \section{Summary}
279     \label{sec:summary}
280     \input{summary}
281
282     %\section{Acknowledgements}
283     %\input{acknowledgements}
284     
285    \input{references}
286
287    \\appendix
288   
289   \section{Metadata}
290     \label{sec:metadata}
291     \input{metadata}
292
293\clearpage
294
295   \section{Time series}
296     \label{sec:timeseries}
297"""
298fid.write(s)
299
300for i in range(len(latex_output)):
301    s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
302    fid.write(s)
303
304s="""
305\end{document}
306"""
307fid.write(s)
Note: See TracBrowser for help on using the repository browser.