source: anuga_work/production/newcastle_2006/make_report.py @ 7818

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

minor updates for gauge names plus plotting files

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