source: production/onslow_2006/make_report.py @ 3261

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