source: production/onslow_2006/make_report.py @ 3157

Last change on this file since 3157 was 3136, checked in by sexton, 19 years ago

updates

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