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 | * Data sources |
---|
27 | * Inundation model |
---|
28 | * Inundation modelling results |
---|
29 | * Impact modelling |
---|
30 | * Summary |
---|
31 | * Acknowledgements |
---|
32 | * References |
---|
33 | * Appendix: Metadata |
---|
34 | * Appendix: Time series outputs |
---|
35 | |
---|
36 | Other files included in document which require manual intervention: |
---|
37 | |
---|
38 | * an abstract must be written in abstract.tex |
---|
39 | * an introduction must be written in introduction.tex; a basic outline and |
---|
40 | some of the core inputs are already in place |
---|
41 | * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
42 | * a discussion of the ANUGA model is required in anuga.tex |
---|
43 | * a computational_setup.tex file needs to be written for the particular scenario |
---|
44 | * the interpretation of the results needs to be written to interpretation.tex |
---|
45 | * maximum inundation map names need to be included in HAT_map and LAT_map etc. |
---|
46 | * damage modelling map names need to be included in HAT_damage and LAT_damage etc. |
---|
47 | * a summary must be written into summary.tex |
---|
48 | * metadata for the scenario data to be included in metadata.tex |
---|
49 | |
---|
50 | May, June 2006 |
---|
51 | """ |
---|
52 | |
---|
53 | from os import getcwd, sep, altsep, mkdir, access, F_OK |
---|
54 | import project |
---|
55 | from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file |
---|
56 | |
---|
57 | # Derive scenario name |
---|
58 | p = getcwd().split(sep) |
---|
59 | scenario = p[-1] # Last element of absolute CWD path |
---|
60 | scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` |
---|
61 | test = scenario_name.split('_') |
---|
62 | if len(test) <> 1: |
---|
63 | scenario_name = '%s %s' %(test[0], test[1]) |
---|
64 | |
---|
65 | # Create report directory |
---|
66 | reportdir = getcwd()+sep+'report'+sep |
---|
67 | if access(reportdir,F_OK) == 0: |
---|
68 | mkdir (reportdir) |
---|
69 | |
---|
70 | # User defined inputs |
---|
71 | report_title = 'Tsunami impact modelling for Tasmania: %s' %scenario_name.title() |
---|
72 | |
---|
73 | # WA DLI data |
---|
74 | production_dirs = {#'20061008_234702': 'Mw 8-7', # 2500 res |
---|
75 | #'20061004_230438': 'Mw 8-7', # 7500 res |
---|
76 | '20061022_224422': 'Mw 8-7'} # refined mesh |
---|
77 | #'20061006_062319': 'Mw 8-5'} # 2500 res |
---|
78 | |
---|
79 | max_maps = {'Mw 8-7': 'mw87_map', |
---|
80 | 'Mw 8-5': 'mw85_map'} |
---|
81 | |
---|
82 | gauge_map = 'MRT_gauges.jpg' |
---|
83 | #gauge_map = 'hobart_gauge.jpg' |
---|
84 | |
---|
85 | # Create sections and graphs for each designated production directory |
---|
86 | latex_output = [] |
---|
87 | swwfiles = {} |
---|
88 | for label_id in production_dirs.keys(): |
---|
89 | |
---|
90 | file_loc = project.outputdir + label_id + sep |
---|
91 | swwfile = file_loc + project.basename + '.sww' |
---|
92 | swwfiles[swwfile] = label_id |
---|
93 | |
---|
94 | texname, elev_output = sww2timeseries(swwfiles, |
---|
95 | project.gauge_filename, |
---|
96 | production_dirs, |
---|
97 | report = True, |
---|
98 | reportname = 'latexoutput_MRT', |
---|
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_MRT.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 | \usepackage{rotating} |
---|
144 | \include{appendix} |
---|
145 | \setstretch{1.25} |
---|
146 | \\topmargin 0pt |
---|
147 | \oddsidemargin 0pt |
---|
148 | \evensidemargin 0pt |
---|
149 | \marginparwidth 0.5pt |
---|
150 | \\textwidth \paperwidth |
---|
151 | \\advance\\textwidth -2in |
---|
152 | |
---|
153 | """ |
---|
154 | fid.write(s) |
---|
155 | |
---|
156 | #s = '\\title{%s} \n' %report_title |
---|
157 | #fid.write(s) |
---|
158 | |
---|
159 | s = """ |
---|
160 | \date{\\today} |
---|
161 | %\\author{Geoscience Australia} |
---|
162 | |
---|
163 | \\begin{document} |
---|
164 | \\title{ |
---|
165 | \\begin{figure}[hbt] |
---|
166 | \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}} |
---|
167 | \end{figure} |
---|
168 | """ |
---|
169 | fid.write(s) |
---|
170 | s = '%s} '%report_title |
---|
171 | fid.write(s) |
---|
172 | s = """ |
---|
173 | \maketitle |
---|
174 | |
---|
175 | \section{Executive Summary} |
---|
176 | \label{sec:execsum} |
---|
177 | \input{execsum} |
---|
178 | |
---|
179 | \\tableofcontents |
---|
180 | |
---|
181 | \section{Introduction} |
---|
182 | \label{sec:intro} |
---|
183 | \input{introduction} |
---|
184 | |
---|
185 | \section{Modelling methodology} |
---|
186 | \label{sec:methodology} |
---|
187 | \input{modelling_methodology} |
---|
188 | |
---|
189 | %\section{Tsunami scenarios} |
---|
190 | % \label{sec:tsunamiscenario} |
---|
191 | % \input{tsunami_scenario} |
---|
192 | |
---|
193 | \section{Data sources} |
---|
194 | \label{sec:data} |
---|
195 | \input{data} |
---|
196 | |
---|
197 | \section{Inundation model} |
---|
198 | \label{sec:anuga} |
---|
199 | \input{anuga} |
---|
200 | \input{computational_setup} |
---|
201 | |
---|
202 | \section{Inundation modelling results} |
---|
203 | \label{sec:results} |
---|
204 | |
---|
205 | """ |
---|
206 | fid.write(s) |
---|
207 | |
---|
208 | # Generate latex output for location points |
---|
209 | s = '\\begin{table} \\begin{center} \n' |
---|
210 | fid.write(s) |
---|
211 | s = '\caption{Defined point locations for %s study area.}' %scenario_name |
---|
212 | fid.write(s) |
---|
213 | s = """ |
---|
214 | \label{table:locations} |
---|
215 | \\begin{tabular}{|l|l|l|l|}\hline |
---|
216 | \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline |
---|
217 | """ |
---|
218 | fid.write(s) |
---|
219 | |
---|
220 | gauges, locations, elevation = get_gauges_from_file(project.gauge_filename) |
---|
221 | |
---|
222 | for name, gauges, elev in zip(locations, gauges, elevation): |
---|
223 | east = gauges[0] |
---|
224 | north = gauges[1] |
---|
225 | s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev) |
---|
226 | fid.write(s) |
---|
227 | |
---|
228 | s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
229 | fid.write(s) |
---|
230 | |
---|
231 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map |
---|
232 | fid.write(s) |
---|
233 | |
---|
234 | s = """ |
---|
235 | \caption{Point locations used for Hobart study.} |
---|
236 | \label{fig:points} |
---|
237 | \end{figure} |
---|
238 | """ |
---|
239 | fid.write(s) |
---|
240 | |
---|
241 | s = '\input{interpretation} \n' |
---|
242 | fid.write(s) |
---|
243 | |
---|
244 | # Assign titles to each production section |
---|
245 | # Must specify one name per section |
---|
246 | for i, name in enumerate(production_dirs.keys()): |
---|
247 | # |
---|
248 | # s = '\subsection{%s} \n \n' %production_dirs[name] |
---|
249 | # fid.write(s) |
---|
250 | |
---|
251 | s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]] |
---|
252 | fid.write(s) |
---|
253 | |
---|
254 | # Closing |
---|
255 | |
---|
256 | s = """ |
---|
257 | \section{Impact modelling} |
---|
258 | \label{sec:impact} |
---|
259 | \input{damage} |
---|
260 | """ |
---|
261 | #fid.write(s) |
---|
262 | |
---|
263 | #for i, name in enumerate(production_dirs.keys()): |
---|
264 | |
---|
265 | # s = '\input{%s} \n \clearpage \n \n' %damage_maps[production_dirs[name]] |
---|
266 | # fid.write(s) |
---|
267 | |
---|
268 | s = """ |
---|
269 | % \section{Impact due to data accuracy} |
---|
270 | % \input{discussion} |
---|
271 | % \label{sec:issues} |
---|
272 | |
---|
273 | \section{Summary} |
---|
274 | \label{sec:summary} |
---|
275 | \input{summary} |
---|
276 | |
---|
277 | \section{Acknowledgements} |
---|
278 | \input{acknowledgements} |
---|
279 | |
---|
280 | \input{references} |
---|
281 | |
---|
282 | \\appendix |
---|
283 | |
---|
284 | \section{Metadata} |
---|
285 | \label{sec:metadata} |
---|
286 | \input{metadata} |
---|
287 | |
---|
288 | \clearpage |
---|
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 | |
---|
300 | %\pagebreak |
---|
301 | |
---|
302 | % \section{Damage modelling inputs} |
---|
303 | % \label{sec:damageinputs} |
---|
304 | % \input{damage_inputs} |
---|
305 | |
---|
306 | \end{document} |
---|
307 | """ |
---|
308 | fid.write(s) |
---|