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