source: production/pt_hedland_2006/make_report.py @ 3287

Last change on this file since 3287 was 3190, checked in by sexton, 19 years ago

MOST and ANUGA comparisons and updates

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