source: production/onslow_2006/make_report.py @ 3174

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

updates to Onslow report

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