source: production/onslow_2006/make_report.py @ 3031

Last change on this file since 3031 was 3015, checked in by sexton, 19 years ago

including references and more updates to report words

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