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