source: production/pt_hedland_2006/make_report.py @ 3383

Last change on this file since 3383 was 3377, checked in by sexton, 19 years ago

updated gauge map

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