source: production/onslow_2006/make_report.py @ 2877

Last change on this file since 2877 was 2870, checked in by sexton, 19 years ago

including damage modelling into report script

File size: 5.1 KB
Line 
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
22* Introduction
23* Data sources
24* Tsunami scenario
25* Inundation modelling results
26* Damage modelling
27* Summary
28* References
29* Appendix: Metadata
30
31Other files included in document which require manual intervention:
32
33* an abstract must be written in abstract.tex
34* an introduction must be written in introduction.tex; a basic outline and
35  some of the core inputs are already in place
36* an interpretation.tex file needs to be written for the particular scenario
37* any data issues must be included in data_issues.tex (data.tex should
38  be revised for future reports)
39* the tsunami-genic event should be discussed in tsunami_scenario.tex
40* a summary must be written into summary.tex
41* metadata for the scenario data to be included in metadata.tex
42
43May 2006                   
44"""
45
46from os import getcwd, sep
47import project
48from pyvolution.util import sww2timeseries
49
50# Derive scenario name
51p = getcwd().split(sep)
52scenario = p[-1] # Last element of absolute CWD path
53scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
54test = scenario_name.split('_')
55if len(test) <> 1:
56    scenario_name = '%s %s' %(test[0], test[1])
57
58# User defined inputs
59report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title()
60
61production_dirs = {'20060424_020426_duplictate_time_steps': 'Highest Astronomical Tide',
62                   '20060426_004129': 'Lowest Astronomical Tide'}
63
64# Create sections and graphs for each designated production directory
65latex_output = []
66for label_id in production_dirs.keys():
67   
68    file_loc = project.outputdir + label_id + sep
69    swwfile = file_loc + project.basename + '.sww'
70
71    texname = sww2timeseries(swwfile,
72                             project.gauge_filename,
73                             label_id,
74                             report = True,
75                             plot_quantity = ['stage', 'velocity', 'bearing'],
76                             time_min = None,
77                             time_max = None,
78                             title_on = False,   
79                             verbose = True)
80
81    latex_output.append(texname)
82
83
84# Start report generation
85report_name = scenario + '_report.tex'
86fid = open(report_name, 'w')
87
88s = """
89% This is based on an automatically generated file (by make_report.py).
90%
91% Manual parts are:
92% * an abstract must be written in abstract.tex
93% * an introduction must be written in introduction.tex; a basic outline and
94%   some of the core inputs are already in place
95% * an interpretation.tex file needs to be written for the particular scenario
96% * any data issues must be included in data_issues.tex (data.tex should
97%   be revised for future reports)
98% * the tsunami-genic event should be discussed in tsunami_scenario.tex
99% * a summary must be written into summary.tex
100% * metadata for the scenario data to be included in metadata.tex
101
102\documentclass{article}
103
104\usepackage{ae} % or {zefonts}
105\usepackage[T1]{fontenc}
106\usepackage[ansinew]{inputenc}
107\usepackage{amsmath}
108\usepackage{amssymb}
109\usepackage{graphicx}
110\usepackage{color}
111\usepackage[colorlinks]{hyperref}
112\usepackage{lscape} %landcape pages support
113\usepackage{setspace}
114\setstretch{1.25}
115\\topmargin 0pt
116\oddsidemargin 0pt
117\evensidemargin 0pt
118\marginparwidth 0.5pt
119\\textwidth \paperwidth
120\\advance\\textwidth -2in
121
122"""
123fid.write(s)
124
125s = '\\title{%s} \n' %report_title
126fid.write(s)
127
128s = """
129\date{\\today}
130\\author{Geoscience Australia}
131\\begin{document}
132  \maketitle
133 
134  \\begin{abstract}
135    \input{abstract}
136  \end{abstract}
137 
138  \\tableofcontents
139 
140  \section{Introduction}
141    \label{sec:intro}
142  \input{introduction}
143 
144  \section{Data sources}
145    \label{sec:data}
146    \input{data}
147   
148  \section{Tsunami scenarios}
149    \label{sec:tsunami_scenarios}
150    \input{tsunami_scenario}
151   
152  \section{Inundation modelling results}
153     \label{sec:results}
154     \input{results}
155     \input{interpretation}
156     
157"""
158fid.write(s)
159
160# Assign titles to each production section
161# Must specify one name per section
162for i, name in enumerate(production_dirs.keys()):
163
164    s = '\subsection{%s} \n \n' %production_dirs[name]     
165    fid.write(s)
166   
167    s = '\input{%s} \n \clearpage \n \n' %latex_output[i]
168    fid.write(s)
169
170
171# Closing
172
173s = """
174   \section{Damage modelling}
175     \input{damage}
176     
177   \section{Summary}
178     \input{summary}
179     
180   \section{References}
181
182   \section{Metadata}
183     \label{sec:metadata}
184     \input{metadata}
185
186\end{document}
187"""
188fid.write(s)
Note: See TracBrowser for help on using the repository browser.