source: production/onslow_2006/make_report.py @ 3396

Last change on this file since 3396 was 3396, checked in by sexton, 18 years ago

some updates

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