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 | # DTED data |
---|
73 | #production_dirs = {'20060426_004129': '1.5 AHD', |
---|
74 | # '20060426_004237': '-1.5 AHD', |
---|
75 | # '20060515_001733': '0 AHD'} |
---|
76 | #damage_maps = {'1.5 AHD': 'HAT_damage', |
---|
77 | # '-1.5 AHD': 'LAT_damage', |
---|
78 | # '0 AHD': 'MSL_damage'} |
---|
79 | |
---|
80 | # WA DLI data |
---|
81 | production_dirs = {'20060630_065348': 'MSL', |
---|
82 | '20060630_070124': 'HAT', |
---|
83 | '20060630_070359': 'LAT'} |
---|
84 | |
---|
85 | max_maps = {'MSL': 'MSL_map', |
---|
86 | 'HAT': 'HAT_map', |
---|
87 | 'LAT': 'LAT_map'} |
---|
88 | |
---|
89 | gauge_map = 'onslow_gauge_map.jpg' |
---|
90 | |
---|
91 | compare_output = 'compare_output_datasets' |
---|
92 | |
---|
93 | # Create sections and graphs for each designated production directory |
---|
94 | latex_output = [] |
---|
95 | swwfiles = {} |
---|
96 | for label_id in production_dirs.keys(): |
---|
97 | |
---|
98 | file_loc = project.outputdir + label_id + sep |
---|
99 | swwfile = file_loc + project.basename + '.sww' |
---|
100 | swwfiles[swwfile] = label_id |
---|
101 | |
---|
102 | texname, elev_output = sww2timeseries(swwfiles, |
---|
103 | project.gauge_filename, |
---|
104 | production_dirs, |
---|
105 | report = True, |
---|
106 | reportname = 'latexoutput', |
---|
107 | plot_quantity = ['stage', 'speed'], |
---|
108 | surface = False, |
---|
109 | time_min = None, |
---|
110 | time_max = None, |
---|
111 | title_on = False, |
---|
112 | verbose = True) |
---|
113 | |
---|
114 | latex_output.append(texname) |
---|
115 | |
---|
116 | # Start report generation |
---|
117 | # Future: generate_report(reportdir, scenario, report_title, |
---|
118 | # project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output) |
---|
119 | report_name = reportdir + scenario + '_report.tex' |
---|
120 | fid = open(report_name, 'w') |
---|
121 | |
---|
122 | s = """ |
---|
123 | % This is based on an automatically generated file (by make_report.py). |
---|
124 | % |
---|
125 | % Manual parts are: |
---|
126 | % * an abstract must be written in abstract.tex |
---|
127 | % * an introduction must be written in introduction.tex; a basic outline and |
---|
128 | % some of the core inputs are already in place |
---|
129 | % * outline of the modelling methodology provided in modelling_methodology.tex |
---|
130 | % * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
131 | % * an computational_setup.tex file needs to be written for the particular scenario |
---|
132 | % * the interpretation of the results needs to be written to interpretation.tex |
---|
133 | % * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc. |
---|
134 | % * damage modelling maps need to be included in HAT_damage and LAT_damage etc. |
---|
135 | % * a summary must be written into summary.tex |
---|
136 | % * metadata for the scenario data to be included in metadata.tex |
---|
137 | |
---|
138 | \documentclass{article} |
---|
139 | |
---|
140 | \usepackage{ae} % or {zefonts} |
---|
141 | \usepackage[T1]{fontenc} |
---|
142 | \usepackage[ansinew]{inputenc} |
---|
143 | \usepackage{amsmath} |
---|
144 | \usepackage{amssymb} |
---|
145 | \usepackage{graphicx} |
---|
146 | \usepackage{color} |
---|
147 | \usepackage[colorlinks]{hyperref} |
---|
148 | \usepackage{lscape} %landcape pages support |
---|
149 | \usepackage{setspace} |
---|
150 | \include{appendix} |
---|
151 | \setstretch{1.25} |
---|
152 | \\topmargin 0pt |
---|
153 | \oddsidemargin 0pt |
---|
154 | \evensidemargin 0pt |
---|
155 | \marginparwidth 0.5pt |
---|
156 | \\textwidth \paperwidth |
---|
157 | \\advance\\textwidth -2in |
---|
158 | |
---|
159 | """ |
---|
160 | fid.write(s) |
---|
161 | |
---|
162 | #s = '\\title{%s} \n' %report_title |
---|
163 | #fid.write(s) |
---|
164 | |
---|
165 | s = """ |
---|
166 | \date{\\today} |
---|
167 | %\\author{Geoscience Australia} |
---|
168 | |
---|
169 | \\begin{document} |
---|
170 | \\title{ |
---|
171 | \\begin{figure}[hbt] |
---|
172 | \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}} |
---|
173 | \end{figure} |
---|
174 | """ |
---|
175 | fid.write(s) |
---|
176 | s = '%s} '%report_title |
---|
177 | fid.write(s) |
---|
178 | s = """ |
---|
179 | \maketitle |
---|
180 | |
---|
181 | \\tableofcontents |
---|
182 | |
---|
183 | \section{Executive Summary} |
---|
184 | \label{sec:execsum} |
---|
185 | \input{execsum} |
---|
186 | |
---|
187 | \section{Introduction} |
---|
188 | \label{sec:intro} |
---|
189 | \input{introduction} |
---|
190 | |
---|
191 | \section{Modelling methodology} |
---|
192 | \label{sec:methodology} |
---|
193 | \input{modelling_methodology} |
---|
194 | |
---|
195 | \section{Tsunami scenarios} |
---|
196 | \label{sec:tsunamiscenario} |
---|
197 | \input{tsunami_scenario} |
---|
198 | |
---|
199 | \section{Inundation model} |
---|
200 | \label{sec:anuga} |
---|
201 | \input{anuga} |
---|
202 | \input{computational_setup} |
---|
203 | |
---|
204 | \section{Data sources} |
---|
205 | \label{sec:data} |
---|
206 | \input{data} |
---|
207 | |
---|
208 | \section{Modelling results} |
---|
209 | \label{sec:results} |
---|
210 | |
---|
211 | """ |
---|
212 | fid.write(s) |
---|
213 | |
---|
214 | # Generate latex output for location points |
---|
215 | s = '\\begin{table} \label{table:locations} \n' |
---|
216 | fid.write(s) |
---|
217 | s = '\caption{Defined point locations for %s study area.}' %report_title |
---|
218 | fid.write(s) |
---|
219 | s = """ |
---|
220 | \\begin{center} |
---|
221 | \\begin{tabular}{|l|l|l|l|}\hline |
---|
222 | \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline |
---|
223 | """ |
---|
224 | fid.write(s) |
---|
225 | |
---|
226 | gauges, locations, elevation = get_gauges_from_file(project.gauge_filename) |
---|
227 | |
---|
228 | for name, gauges, elev in zip(locations, gauges, elevation): |
---|
229 | east = gauges[0] |
---|
230 | north = gauges[1] |
---|
231 | s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev) |
---|
232 | fid.write(s) |
---|
233 | |
---|
234 | s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
235 | fid.write(s) |
---|
236 | |
---|
237 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map |
---|
238 | fid.write(s) |
---|
239 | |
---|
240 | s = """ |
---|
241 | \caption{Point locations used for Onslow study.} |
---|
242 | \label{fig:points} |
---|
243 | \end{figure} |
---|
244 | """ |
---|
245 | fid.write(s) |
---|
246 | |
---|
247 | s = '\input{interpretation} \n' |
---|
248 | fid.write(s) |
---|
249 | |
---|
250 | # Assign titles to each production section |
---|
251 | # Must specify one name per section |
---|
252 | for i, name in enumerate(production_dirs.keys()): |
---|
253 | # |
---|
254 | # s = '\subsection{%s} \n \n' %production_dirs[name] |
---|
255 | # fid.write(s) |
---|
256 | |
---|
257 | s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]] |
---|
258 | fid.write(s) |
---|
259 | |
---|
260 | # Closing |
---|
261 | |
---|
262 | s = """ |
---|
263 | \section{Impact modelling} |
---|
264 | \label{sec:impact} |
---|
265 | \input{damage} |
---|
266 | """ |
---|
267 | fid.write(s) |
---|
268 | |
---|
269 | #for i, name in enumerate(production_dirs.keys()): |
---|
270 | |
---|
271 | # s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]] |
---|
272 | # fid.write(s) |
---|
273 | |
---|
274 | s = """ |
---|
275 | \section{Impact due to data accuracy} |
---|
276 | \input{discussion} |
---|
277 | \label{sec:issues} |
---|
278 | |
---|
279 | \section{Summary} |
---|
280 | \input{summary} |
---|
281 | |
---|
282 | \input{references} |
---|
283 | |
---|
284 | \appendix |
---|
285 | |
---|
286 | \section{Metadata} |
---|
287 | \label{sec:metadata} |
---|
288 | \input{metadata} |
---|
289 | |
---|
290 | \section{Time series} |
---|
291 | \label{sec:timeseries} |
---|
292 | """ |
---|
293 | fid.write(s) |
---|
294 | |
---|
295 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
296 | fid.write(s) |
---|
297 | |
---|
298 | s=""" |
---|
299 | \section{Damage modelling inputs} |
---|
300 | \label{sec:damageinputs} |
---|
301 | \input{damage_inputs} |
---|
302 | |
---|
303 | \section{Time series} |
---|
304 | \label{sec:timeseriescompare} |
---|
305 | |
---|
306 | """ |
---|
307 | fid.write(s) |
---|
308 | |
---|
309 | s = '\input{%s} \n \clearpage \n \n' %compare_output |
---|
310 | fid.write(s) |
---|
311 | |
---|
312 | s = '\end{document}' |
---|
313 | fid.write(s) |
---|