source: production/onslow_2006/make_report.py @ 3261

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