source: production/pt_hedland_2006/make_report.py @ 3094

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

fix legend and add elevation information to caption in sww2timeseries

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 = {'': '1.5 AHD',
71                   '': '-1.5 AHD',
72                   '': '0 AHD'}
73
74max_maps = {'1.5 AHD': 'HAT_map',
75            '-1.5 AHD': 'LAT_map',
76            '0 AHD': 'MSL_map'}
77
78damage_maps = {'1.5 AHD': 'HAT_damage',
79               '-1.5 AHD': 'LAT_damage',
80               '0 AHD': 'MSL_damage'}
81
82gauge_map = 'pt_hedland_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                         #label_id,
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% * the tsunami-genic event should be discussed in tsunami_scenario.tex
120% * an computational_setup.tex file needs to be written for the particular scenario
121% * the interpretation of the results needs to be written to interpretation.tex
122% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
123% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
124% * a summary must be written into summary.tex
125% * metadata for the scenario data to be included in metadata.tex
126
127\documentclass{article}
128
129\usepackage{ae} % or {zefonts}
130\usepackage[T1]{fontenc}
131\usepackage[ansinew]{inputenc}
132\usepackage{amsmath}
133\usepackage{amssymb}
134\usepackage{graphicx}
135\usepackage{color}
136\usepackage[colorlinks]{hyperref}
137\usepackage{lscape} %landcape pages support
138\usepackage{setspace}
139\setstretch{1.25}
140\\topmargin 0pt
141\oddsidemargin 0pt
142\evensidemargin 0pt
143\marginparwidth 0.5pt
144\\textwidth \paperwidth
145\\advance\\textwidth -2in
146
147"""
148fid.write(s)
149
150s = '\\title{%s} \n' %report_title
151fid.write(s)
152
153s = """
154\date{\\today}
155\\author{Geoscience Australia}
156\\begin{document}
157  \maketitle
158 
159  \\begin{abstract}
160    \input{abstract}
161  \end{abstract}
162 
163  \\tableofcontents
164 
165  \section{Introduction}
166    \label{sec:intro}
167  \input{introduction}
168   
169  \section{Tsunami scenarios}
170    \label{sec:tsunamiscenario}
171    \input{tsunami_scenario}
172
173   \section{Inundation Model}
174    \label{sec:anuga}
175    \input{anuga}
176    \input{computational_setup}
177   
178  \section{Data sources}
179    \label{sec:data}
180    \input{data}
181   
182  \section{Modelling results}
183     \label{sec:results}
184         
185"""
186fid.write(s)
187
188# Generate latex output for location points
189s = '\\begin{table} \label{table:locations} \n'
190fid.write(s)
191s = '\caption{Defined point locations for %s study area.}' %report_title
192fid.write(s)
193s = """
194\\begin{center}
195\\begin{tabular}{|l|l|l|l|}\hline
196\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
197"""
198fid.write(s)
199
200gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
201
202for name, gauges, elev in zip(locations, gauges, elevation):
203    east = gauges[0]
204    north = gauges[1]
205    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
206    fid.write(s)
207
208s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
209fid.write(s)
210
211s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map
212fid.write(s)
213
214= """
215\caption{Point locations used for Pt Hedland study.} 
216\label{fig:points}
217\end{figure}
218"""
219fid.write(s)
220   
221s = '\input{interpretation} \n'
222fid.write(s)
223
224# Assign titles to each production section
225# Must specify one name per section
226for i, name in enumerate(production_dirs.keys()):
227#
228#    s = '\subsection{%s} \n \n' %production_dirs[name]     
229#    fid.write(s)
230
231    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
232    fid.write(s)
233
234# Closing
235
236s = """
237   \section{Damage modelling}
238    \label{sec:damage}
239     \input{damage}
240"""
241fid.write(s)
242
243for i, name in enumerate(production_dirs.keys()):
244
245    s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]]
246    fid.write(s)
247
248s = """
249   \section{Summary}
250     \input{summary}
251     
252   \section{References}
253    \input{references}
254   
255   \section{Metadata}
256     \label{sec:metadata}
257     \input{metadata}
258
259   \section{Time series}
260     \label{sec:timeseries}
261"""
262fid.write(s)
263
264s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
265fid.write(s)
266     
267s = '\end{document}'
268fid.write(s)
Note: See TracBrowser for help on using the repository browser.