1 | """ |
---|
2 | Generate report for production run |
---|
3 | |
---|
4 | NOTE - this will only work on Windows system (as pylab not installed on unix). |
---|
5 | |
---|
6 | Inputs: |
---|
7 | |
---|
8 | report_title: title to be included in tex file |
---|
9 | production dirs: dictionary of production directories with a |
---|
10 | association to that simulation run, eg high tide, |
---|
11 | low tide and MSL. |
---|
12 | |
---|
13 | |
---|
14 | Outputs: |
---|
15 | |
---|
16 | * Report generated to scenario_report.tex where the scenario relates |
---|
17 | the name of the production directory this script is being run from. |
---|
18 | * figures used for report stored in the report_figure directory |
---|
19 | NOTE, this directory will need to be committed, as well as |
---|
20 | the latex files. |
---|
21 | |
---|
22 | The report structure is |
---|
23 | |
---|
24 | * Executive Summary |
---|
25 | * Introduction |
---|
26 | * Modelling Methodology |
---|
27 | * Tsunami scenario |
---|
28 | * Data sources |
---|
29 | * Inundation model |
---|
30 | * Inundation modelling results |
---|
31 | * Impact modelling |
---|
32 | * Summary |
---|
33 | * Acknowledgements |
---|
34 | * References |
---|
35 | * Appendix: Metadata |
---|
36 | * Appendix: Time series outputs |
---|
37 | |
---|
38 | Other files included in document which require manual intervention: |
---|
39 | |
---|
40 | * an abstract must be written in abstract.tex |
---|
41 | * an introduction must be written in introduction.tex; a basic outline and |
---|
42 | some of the core inputs are already in place |
---|
43 | * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
44 | * a discussion of the ANUGA model is required in anuga.tex |
---|
45 | * a computational_setup.tex file needs to be written for the particular scenario |
---|
46 | * the interpretation of the results needs to be written to interpretation.tex |
---|
47 | * maximum inundation map names need to be included in HAT_map and LAT_map etc. |
---|
48 | * damage modelling map names need to be included in HAT_damage and LAT_damage etc. |
---|
49 | * a summary must be written into summary.tex |
---|
50 | * metadata for the scenario data to be included in metadata.tex |
---|
51 | |
---|
52 | May, June 2006 |
---|
53 | """ |
---|
54 | |
---|
55 | from os import getcwd, sep, altsep, mkdir, access, F_OK |
---|
56 | import project_slide |
---|
57 | from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file |
---|
58 | |
---|
59 | # Derive scenario name |
---|
60 | p = getcwd().split(sep) |
---|
61 | scenario = p[-1] # Last element of absolute CWD path |
---|
62 | scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` |
---|
63 | test = scenario_name.split('_') |
---|
64 | if len(test) <> 1: |
---|
65 | scenario_name = '%s %s' %(test[0], test[1]) |
---|
66 | |
---|
67 | # Create report directory |
---|
68 | reportdir = getcwd()+sep+'report'+sep |
---|
69 | if access(reportdir,F_OK) == 0: |
---|
70 | mkdir (reportdir) |
---|
71 | |
---|
72 | # User defined inputs |
---|
73 | report_title = 'Tsunami inundation modelling for the NSW coastline: Generation by Submarine Mass Failures' |
---|
74 | |
---|
75 | # WA DLI data |
---|
76 | production_dirs = {'20061211_071516': 'Area B - Bulli', |
---|
77 | '20061212_012705': 'Area B - Shovel', |
---|
78 | '20070322_035214': 'Area B - Yacaaba', |
---|
79 | '20070322_035135': 'Area B - Birubi', |
---|
80 | '20061211_060105': 'Area A - Bulli', |
---|
81 | '20061212_012715': 'Area A - Shovel', |
---|
82 | '20070322_035513': 'Area A - Yacaaba', |
---|
83 | '20070322_035640': 'Area A - Birubi', |
---|
84 | '20061211_073709': 'Area C - Bulli', |
---|
85 | '20061212_012802': 'Area C - Shovel', |
---|
86 | '20070331_070841': 'Area C - Yacaaba', |
---|
87 | '20070331_080432': 'Area C - Birubi', |
---|
88 | '20070322_033608': 'Area C0 - Bulli', |
---|
89 | '20070322_033716': 'Area C0 - Shovel', |
---|
90 | '20070323_012310': 'Area C0 - Yacaaba', |
---|
91 | '20070322_033350': 'Area C0 - Birubi', |
---|
92 | '20070331_080235': 'Area C2 - Bulli', |
---|
93 | '20070331_080213': 'Area C2 - Shovel', |
---|
94 | '20070401_030248': 'Area C2 - Yacaaba', |
---|
95 | '20070331_080603': 'Area C2 - Birubi',} |
---|
96 | |
---|
97 | do_timeseries = False |
---|
98 | |
---|
99 | is_parallel = False |
---|
100 | if is_parallel == True: |
---|
101 | nodes = 8 |
---|
102 | |
---|
103 | max_maps = {'Area A - Bulli': 'bulli_A_map', |
---|
104 | 'Area A - Shovel': 'shovel_A_map', |
---|
105 | 'Area A - Yacaaba': 'yacaaba_A_map', |
---|
106 | 'Area A - Birubi': 'birubi_A_map', |
---|
107 | 'Area B - Bulli': 'bulli_B_map', |
---|
108 | 'Area B - Shovel': 'shovel_B_map', |
---|
109 | 'Area B - Yacaaba': 'yacaaba_B_map', |
---|
110 | 'Area B - Birubi': 'birubi_B_map', |
---|
111 | 'Area C0 - Bulli': 'bulli_C0_map', |
---|
112 | 'Area C0 - Shovel': 'shovel_C0_map', |
---|
113 | 'Area C0 - Yacaaba': 'yacaaba_C0_map', |
---|
114 | 'Area C0 - Birubi': 'birubi_C0_map', |
---|
115 | 'Area C - Bulli': 'bulli_C_map', |
---|
116 | 'Area C - Shovel': 'shovel_C_map', |
---|
117 | 'Area C - Yacaaba': 'yacaaba_C_map', |
---|
118 | 'Area C - Birubi': 'birubi_C_map', |
---|
119 | 'Area C2 - Bulli': 'bulli_C2_map', |
---|
120 | 'Area C2 - Shovel': 'shovel_C2_map', |
---|
121 | 'Area C2 - Yacaaba': 'yacaaba_C2_map', |
---|
122 | 'Area C2 - Birubi': 'birubi_C2_map'} |
---|
123 | |
---|
124 | ##gauge_mapA = '' |
---|
125 | ##gauge_mapB = '' |
---|
126 | ##gauge_mapC = '' |
---|
127 | |
---|
128 | # Create sections and graphs for each designated production directory |
---|
129 | latex_output = [] |
---|
130 | report_name = 'latexoutput' |
---|
131 | |
---|
132 | if do_timeseries == True: |
---|
133 | |
---|
134 | if is_parallel == True: |
---|
135 | |
---|
136 | for i in range(nodes): |
---|
137 | print 'Sending node %d of %d' %(i,nodes) |
---|
138 | swwfiles = {} |
---|
139 | reportname = report_name + '_%s' %(i) |
---|
140 | for label_id in production_dirs.keys(): |
---|
141 | file_loc = project_slide.outputdir + label_id + sep |
---|
142 | sww_extra = '_P%s_%s' %(i,nodes) |
---|
143 | swwfile = file_loc + project.scenario_name + sww_extra + '.sww' |
---|
144 | swwfiles[swwfile] = label_id |
---|
145 | |
---|
146 | texname, elev_output = sww2timeseries(swwfiles, |
---|
147 | project.gauge_filename, |
---|
148 | production_dirs, |
---|
149 | report = True, |
---|
150 | reportname = reportname, |
---|
151 | plot_quantity = ['stage', 'momentum'], |
---|
152 | generate_fig = True, |
---|
153 | surface = False, |
---|
154 | time_min = None, |
---|
155 | time_max = None, |
---|
156 | title_on = False, |
---|
157 | verbose = True) |
---|
158 | |
---|
159 | latex_output.append(texname) |
---|
160 | |
---|
161 | else: |
---|
162 | swwfiles = {} |
---|
163 | for label_id in production_dirs.keys(): |
---|
164 | |
---|
165 | file_loc = project_slide.outputdir + label_id + sep |
---|
166 | if production_dirs[label_id] == 'Area A - Bulli': |
---|
167 | scenario_dir_name = 'wollongong_tsunami_scenario_2006' |
---|
168 | file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep |
---|
169 | if production_dirs[label_id] == 'Area C - Bulli': |
---|
170 | scenario_dir_name = 'newcastle_tsunami_scenario_2006' |
---|
171 | file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep |
---|
172 | swwfile = file_loc + project_slide.basename + '.sww' |
---|
173 | swwfiles[swwfile] = label_id |
---|
174 | |
---|
175 | texname, elev_output = sww2timeseries(swwfiles, |
---|
176 | 'arrivaltime.csv',#project.gauge_filename, |
---|
177 | production_dirs, |
---|
178 | report = True, |
---|
179 | reportname = report_name, |
---|
180 | plot_quantity = ['stage', 'momentum'], |
---|
181 | generate_fig = True, |
---|
182 | surface = False, |
---|
183 | time_min = None, |
---|
184 | time_max = None, |
---|
185 | title_on = False, |
---|
186 | verbose = True) |
---|
187 | |
---|
188 | # Start report generation |
---|
189 | # Future: generate_report(reportdir, scenario, report_title, |
---|
190 | # project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output) |
---|
191 | report_name = reportdir + scenario + '_report.tex' |
---|
192 | fid = open(report_name, 'w') |
---|
193 | |
---|
194 | s = """ |
---|
195 | % This is based on an automatically generated file (by make_report.py). |
---|
196 | % |
---|
197 | % Manual parts are: |
---|
198 | % * an abstract must be written in abstract.tex |
---|
199 | % * an introduction must be written in introduction.tex; a basic outline and |
---|
200 | % some of the core inputs are already in place |
---|
201 | % * outline of the modelling methodology provided in modelling_methodology.tex |
---|
202 | % * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
203 | % * an computational_setup.tex file needs to be written for the particular scenario |
---|
204 | % * the interpretation of the results needs to be written to interpretation.tex |
---|
205 | % * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc. |
---|
206 | % * damage modelling maps need to be included in HAT_damage and LAT_damage etc. |
---|
207 | % * a summary must be written into summary.tex |
---|
208 | % * metadata for the scenario data to be included in metadata.tex |
---|
209 | |
---|
210 | \documentclass{article} |
---|
211 | |
---|
212 | \usepackage{ae} % or {zefonts} |
---|
213 | \usepackage[T1]{fontenc} |
---|
214 | \usepackage[ansinew]{inputenc} |
---|
215 | \usepackage{amsmath} |
---|
216 | \usepackage{amssymb} |
---|
217 | \usepackage{graphicx} |
---|
218 | \usepackage{color} |
---|
219 | \usepackage[colorlinks]{hyperref} |
---|
220 | \usepackage{lscape} %landcape pages support |
---|
221 | \usepackage{setspace} |
---|
222 | \usepackage{rotating} |
---|
223 | \usepackage{pdfpages} |
---|
224 | \include{appendix} |
---|
225 | \setstretch{1.25} |
---|
226 | \\topmargin 0pt |
---|
227 | \oddsidemargin 0pt |
---|
228 | \evensidemargin 0pt |
---|
229 | \marginparwidth 0.5pt |
---|
230 | \\textwidth \paperwidth |
---|
231 | \\advance\\textwidth -2in |
---|
232 | \\newcommand{\degree}{\ensuremath{^\circ}} |
---|
233 | \\newcommand{\sech}{\operatorname{sech}} |
---|
234 | |
---|
235 | """ |
---|
236 | fid.write(s) |
---|
237 | |
---|
238 | s = """ |
---|
239 | \date{\\today} |
---|
240 | %\\author{Geoscience Australia} |
---|
241 | |
---|
242 | \\begin{document} |
---|
243 | \\title{ |
---|
244 | \\begin{figure}[hbt] |
---|
245 | \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}} |
---|
246 | \end{figure} |
---|
247 | """ |
---|
248 | fid.write(s) |
---|
249 | s = '%s} '%report_title |
---|
250 | fid.write(s) |
---|
251 | s = """ |
---|
252 | \maketitle |
---|
253 | |
---|
254 | \section{Executive Summary} |
---|
255 | \label{sec:execsum} |
---|
256 | \input{execsum} |
---|
257 | |
---|
258 | \pagebreak |
---|
259 | |
---|
260 | \\tableofcontents |
---|
261 | |
---|
262 | \section{Modelling methodology} |
---|
263 | \label{sec:methodology} |
---|
264 | \input{modelling_methodology} |
---|
265 | |
---|
266 | \section{Data sources} |
---|
267 | \label{sec:data} |
---|
268 | \input{data} |
---|
269 | |
---|
270 | \section{Inundation modelling results} |
---|
271 | \label{sec:results} |
---|
272 | |
---|
273 | """ |
---|
274 | fid.write(s) |
---|
275 | |
---|
276 | # Generate latex output for location points |
---|
277 | ##s = '\\begin{table} \\begin{center} \n' |
---|
278 | ##fid.write(s) |
---|
279 | ##s = '\caption{Defined point locations for %s study area.}' %scenario_name |
---|
280 | ##fid.write(s) |
---|
281 | ##s = """ |
---|
282 | ##\label{table:locations} |
---|
283 | ##\\begin{tabular}{|l|l|l|l|}\hline |
---|
284 | ##\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline |
---|
285 | ##""" |
---|
286 | ##fid.write(s) |
---|
287 | ## |
---|
288 | ##gauges, locations, elevation = get_gauges_from_file(project.gauge_filename) |
---|
289 | ## |
---|
290 | ##for name, gauges, elev in zip(locations, gauges, elevation): |
---|
291 | ## east = gauges[0] |
---|
292 | ## north = gauges[1] |
---|
293 | ## s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev) |
---|
294 | ## fid.write(s) |
---|
295 | ## |
---|
296 | ##s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
297 | ##fid.write(s) |
---|
298 | ## |
---|
299 | |
---|
300 | ##s = '\\begin{figure}[hbt] \centerline{\includegraphics[scale = 0.5]{../report_figures/%s}}' %gauge_map2 |
---|
301 | ##fid.write(s) |
---|
302 | ##s = """ |
---|
303 | ##\caption{Point locations used for Dampier study; surrounding the facility. |
---|
304 | ##See Appendix \\ref{sec:timeseries} for stage and momentum results. |
---|
305 | ##} |
---|
306 | ##\label{fig:points2} |
---|
307 | ##\end{figure} |
---|
308 | ##""" |
---|
309 | ##fid.write(s) |
---|
310 | |
---|
311 | s = '\input{interpretation} \n' |
---|
312 | fid.write(s) |
---|
313 | |
---|
314 | # Assign titles to each production section |
---|
315 | # Must specify one name per section |
---|
316 | for i, name in enumerate(production_dirs.keys()): |
---|
317 | |
---|
318 | s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]] |
---|
319 | fid.write(s) |
---|
320 | |
---|
321 | # Closing |
---|
322 | |
---|
323 | |
---|
324 | s = """ |
---|
325 | |
---|
326 | \section{Summary} |
---|
327 | \label{sec:summary} |
---|
328 | \input{summary} |
---|
329 | |
---|
330 | %\section{Acknowledgements} |
---|
331 | %\input{acknowledgements} |
---|
332 | |
---|
333 | \input{references} |
---|
334 | |
---|
335 | \\appendix |
---|
336 | |
---|
337 | % \section{Metadata} |
---|
338 | % \label{sec:metadata} |
---|
339 | % \input{metadata} |
---|
340 | |
---|
341 | \section{ANUGA modelling parameters} |
---|
342 | \label{sec:anugasetup} |
---|
343 | \input{anuga_setup} |
---|
344 | |
---|
345 | \pagebreak |
---|
346 | |
---|
347 | \section{Submarine Mass Failure Model} |
---|
348 | \label{sec:smfmodel} |
---|
349 | \input{smfmodel} |
---|
350 | |
---|
351 | \clearpage |
---|
352 | |
---|
353 | \section{Time series} |
---|
354 | \label{sec:timeseries} |
---|
355 | """ |
---|
356 | fid.write(s) |
---|
357 | |
---|
358 | ##for i in range(len(latex_output)): |
---|
359 | ## if latex_output[i] <> '': |
---|
360 | ## s = '\input{%s} \n \clearpage \n \n' %latex_output[i] |
---|
361 | ## fid.write(s) |
---|
362 | texname = 'latexoutput20061211071516' |
---|
363 | s = '\input{%s} \n \clearpage \n \n' %texname |
---|
364 | fid.write(s) |
---|
365 | texname2 = 'latexoutput20061211060105' |
---|
366 | texname3 = 'latexoutput20061211073709' |
---|
367 | s = '\input{%s} \n \clearpage \n \n' %texname2 |
---|
368 | fid.write(s) |
---|
369 | s = '\input{%s} \n \clearpage \n \n' %texname3 |
---|
370 | fid.write(s) |
---|
371 | s=""" |
---|
372 | \end{document} |
---|
373 | """ |
---|
374 | fid.write(s) |
---|