source: anuga_work/production/onslow_2006/make_report.py @ 4145

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

report updates and fixes to check_list

File size: 8.9 KB
Line 
1"""
2Generate report for production run
3
4Inputs:
5
6report_title:    title to be included in tex file
7production dirs: dictionary of production directories with a
8                 association to that simulation run, eg high tide,
9                 low tide and MSL.
10                   
11
12Outputs:
13
14* Report generated to scenario_report.tex where the scenario relates
15the name of the production directory this script is being run from.
16* figures used for report stored in the report_figure directory
17NOTE, this directory will need to be committed, as well as
18the latex files.
19
20The report structure is
21
22* Executive Summary
23* Introduction
24* Modelling Methodology
25* Tsunami scenario
26* Data sources
27
28* Inundation modelling results
29* Impact modelling
30* Summary
31* Acknowledgements
32* References
33* Appendix: Metadata
34* Appendix: Inundation model metadata
35* Appendix: Time series outputs
36
37Other files included in document which require manual intervention:
38
39* an abstract must be written in abstract.tex
40* an introduction must be written in introduction.tex; a basic outline and
41  some of the core inputs are already in place
42* the tsunami-genic event should be discussed in tsunami_scenario.tex
43* a discussion of the ANUGA model is required in anuga.tex
44* a computational_setup.tex file needs to be written for the particular scenario
45* the interpretation of the results needs to be written to interpretation.tex
46* maximum inundation map names need to be included in HAT_map and LAT_map etc.
47* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
48* a summary must be written into summary.tex
49* metadata for the scenario data to be included in metadata.tex
50
51May, June 2006                   
52"""
53
54from os import getcwd, sep, altsep, mkdir, access, F_OK
55import project
56from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
57
58# Derive scenario name
59p = getcwd().split(sep)
60scenario = p[-1] # Last element of absolute CWD path
61scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
62test = scenario_name.split('_')
63if len(test) <> 1:
64    scenario_name = '%s %s' %(test[0], test[1])
65
66# Create report directory
67reportdir = getcwd()+sep+'report'+sep
68if access(reportdir,F_OK) == 0:
69    mkdir (reportdir)
70   
71# User defined inputs
72report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title()
73
74# DTED data
75#production_dirs = {'20060426_004129': '1.5 AHD',
76#                   '20060426_004237': '-1.5 AHD',
77#                   '20060515_001733': '0 AHD'}
78#damage_maps = {'1.5 AHD': 'HAT_damage',
79#               '-1.5 AHD': 'LAT_damage',
80#               '0 AHD': 'MSL_damage'}
81
82# WA DLI data
83production_dirs = {'20060704_063234': 'MSL',
84                   '20060704_063005': 'HAT',
85                   '20060706_235246': 'LAT'}
86
87max_maps = {'MSL': 'MSL_map',
88            'HAT': 'HAT_map',
89            'LAT': 'LAT_map'}
90
91gauge_map = 'onslow_dli_gauge.jpg'
92
93compare_output = 'compare_output_datasets'
94
95# Create sections and graphs for each designated production directory
96latex_output = []
97swwfiles = {}
98for label_id in production_dirs.keys():
99   
100    file_loc = project.outputdir + label_id + sep
101    swwfile = file_loc + project.basename + '.sww'
102    swwfiles[swwfile] = label_id
103
104texname, elev_output = sww2timeseries(swwfiles,
105                                      project.gauge_filename,
106                                      #project.gauge_filename_bindi,
107                                      production_dirs,
108                                      report = True,
109                                      reportname = 'latexoutput',
110                                      plot_quantity = ['stage', 'speed'],
111                                      surface = False,
112                                      time_min = None,
113                                      time_max = None,
114                                      title_on = False,
115                                      verbose = True)
116
117latex_output.append(texname)
118
119# Start report generation
120# Future: generate_report(reportdir, scenario, report_title,
121# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
122report_name = reportdir + scenario + '_report.tex'
123fid = open(report_name, 'w')
124
125s = """
126% This is based on an automatically generated file (by make_report.py).
127%
128% Manual parts are:
129% * an abstract must be written in abstract.tex
130% * an introduction must be written in introduction.tex; a basic outline and
131%   some of the core inputs are already in place
132% * outline of the modelling methodology provided in modelling_methodology.tex
133% * the tsunami-genic event should be discussed in tsunami_scenario.tex
134% * an computational_setup.tex file needs to be written for the particular scenario
135% * the interpretation of the results needs to be written to interpretation.tex
136% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
137% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
138% * a summary must be written into summary.tex
139% * metadata for the scenario data to be included in metadata.tex
140
141\documentclass{article}
142
143\usepackage{ae} % or {zefonts}
144\usepackage[T1]{fontenc}
145\usepackage[ansinew]{inputenc}
146\usepackage{amsmath}
147\usepackage{amssymb}
148\usepackage{graphicx}
149\usepackage{color}
150\usepackage[colorlinks]{hyperref}
151\usepackage{lscape} %landcape pages support
152\usepackage{setspace}
153\usepackage{rotating}
154\include{appendix}
155\setstretch{1.25}
156\\topmargin 0pt
157\oddsidemargin 0pt
158\evensidemargin 0pt
159\marginparwidth 0.5pt
160\\textwidth \paperwidth
161\\advance\\textwidth -2in
162
163"""
164fid.write(s)
165
166#s = '\\title{%s} \n' %report_title
167#fid.write(s)
168
169s = """
170\date{\\today}
171%\\author{Geoscience Australia}
172
173\\begin{document}
174\\title{
175\\begin{figure}[hbt]
176  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
177\end{figure}
178"""
179fid.write(s)
180s = '%s} '%report_title
181fid.write(s)
182s = """
183  \maketitle
184
185    \section{Executive Summary}
186    \label{sec:execsum}
187  \input{execsum}
188
189\clearpage
190
191  \\tableofcontents
192 
193  \section{Introduction}
194    \label{sec:intro}
195  \input{introduction}
196
197   \section{Modelling methodology}
198    \label{sec:methodology}
199    \input{modelling_methodology}
200   
201  \section{Tsunami scenarios}
202    \label{sec:tsunamiscenario}
203    \input{tsunami_scenario}
204
205  \section{Data sources}
206    \label{sec:data}
207    \input{data}
208       
209  \section{Inundation modelling results}
210     \label{sec:results}
211         
212"""
213fid.write(s)
214   
215s = '\input{interpretation} \n'
216fid.write(s)
217
218# Assign titles to each production section
219# Must specify one name per section
220for i, name in enumerate(production_dirs.keys()):
221#
222#    s = '\subsection{%s} \n \n' %production_dirs[name]     
223#    fid.write(s)
224
225    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
226    fid.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 (m)}\\\\ \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}[h] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map
252s = '\\begin{figure}[h] \n \centerline{ \includegraphics[scale=0.7]{../report_figures/%s}}' %gauge_map
253fid.write(s)
254
255= """
256\caption{Point locations used for Onslow study.} 
257\label{fig:points}
258\end{figure}
259
260\clearpage
261"""
262fid.write(s)
263
264# Closing
265
266s = """
267   \section{Impact modelling}
268    \label{sec:impact}
269     \input{damage}
270"""
271fid.write(s)
272
273s = """
274  % \section{Impact due to data accuracy}
275  %   \input{discussion}
276  %   \label{sec:issues}
277
278     \section{Summary}
279     \label{sec:summary}
280     \input{summary}
281
282     \section{Acknowledgements}
283     \input{acknowledgements}
284     
285    \input{references}
286
287\clearpage
288
289    \\appendix
290
291    \section{ANUGA modelling parameters}
292    \label{sec:anugasetup}
293    \input{anuga_setup}
294
295\clearpage
296
297   \section{Metadata}
298     \label{sec:metadata}
299     \input{metadata}
300
301\clearpage
302
303   \section{Time series}
304     \label{sec:timeseries}
305     \input{timeseriesdiscussion}
306     \clearpage
307"""
308fid.write(s)
309
310s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
311fid.write(s)
312
313s="""
314
315   \section{Damage modelling inputs}
316     \label{sec:damageinputs}
317     \input{damage_inputs}
318
319\end{document}
320"""
321fid.write(s)
Note: See TracBrowser for help on using the repository browser.