source: production/onslow_2006/make_report.py @ 2899

Last change on this file since 2899 was 2898, checked in by sexton, 19 years ago

updates to Onslow report

File size: 5.2 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 results.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
61#production_dirs = {'20060424_020426_duplictate_time_steps': 'Highest Astronomical Tide',
62#                   '20060426_004129': 'Lowest Astronomical Tide'}
63
64production_dirs = {'20060426_004129': 'Highest Astronomical Tide',
65                   '20060426_004237': 'Lowest Astronomical Tide'}
66
67# Create sections and graphs for each designated production directory
68latex_output = []
69for label_id in production_dirs.keys():
70   
71    file_loc = project.outputdir + label_id + sep
72    swwfile = file_loc + project.basename + '.sww'
73
74    texname = sww2timeseries(swwfile,
75                             project.gauge_filename,
76                             label_id,
77                             report = True,
78                             plot_quantity = ['stage', 'velocity', 'bearing'],
79                             time_min = None,
80                             time_max = None,
81                             title_on = False,
82                             verbose = True)
83
84    latex_output.append(texname)
85
86
87# Start report generation
88report_name = scenario + '_report.tex'
89fid = open(report_name, 'w')
90
91s = """
92% This is based on an automatically generated file (by make_report.py).
93%
94% Manual parts are:
95% * an abstract must be written in abstract.tex
96% * an introduction must be written in introduction.tex; a basic outline and
97%   some of the core inputs are already in place
98% * an results.tex file needs to be written for the particular scenario
99% * any data issues must be included in data_issues.tex (data.tex should
100%   be revised for future reports)
101% * the tsunami-genic event should be discussed in tsunami_scenario.tex
102% * a summary must be written into summary.tex
103% * metadata for the scenario data to be included in metadata.tex
104
105\documentclass{article}
106
107\usepackage{ae} % or {zefonts}
108\usepackage[T1]{fontenc}
109\usepackage[ansinew]{inputenc}
110\usepackage{amsmath}
111\usepackage{amssymb}
112\usepackage{graphicx}
113\usepackage{color}
114\usepackage[colorlinks]{hyperref}
115\usepackage{lscape} %landcape pages support
116\usepackage{setspace}
117\setstretch{1.25}
118\\topmargin 0pt
119\oddsidemargin 0pt
120\evensidemargin 0pt
121\marginparwidth 0.5pt
122\\textwidth \paperwidth
123\\advance\\textwidth -2in
124
125"""
126fid.write(s)
127
128s = '\\title{%s} \n' %report_title
129fid.write(s)
130
131s = """
132\date{\\today}
133\\author{Geoscience Australia}
134\\begin{document}
135  \maketitle
136 
137  \\begin{abstract}
138    \input{abstract}
139  \end{abstract}
140 
141  \\tableofcontents
142 
143  \section{Introduction}
144    \label{sec:intro}
145  \input{introduction}
146 
147  \section{Data sources}
148    \label{sec:data}
149    \input{data}
150   
151  \section{Tsunami scenarios}
152    \label{sec:tsunami_scenarios}
153    \input{tsunami_scenario}
154   
155  \section{Inundation modelling results}
156     \label{sec:results}
157     \input{results}
158     
159"""
160fid.write(s)
161
162# Assign titles to each production section
163# Must specify one name per section
164for i, name in enumerate(production_dirs.keys()):
165
166    s = '\subsection{%s} \n \n' %production_dirs[name]     
167    fid.write(s)
168   
169    s = '\input{%s} \n \clearpage \n \n' %latex_output[i]
170    fid.write(s)
171
172
173# Closing
174
175s = """
176   \section{Damage modelling}
177     \input{damage}
178     
179   \section{Summary}
180     \input{summary}
181     
182   \section{References}
183
184   \section{Metadata}
185     \label{sec:metadata}
186     \input{metadata}
187
188\end{document}
189"""
190fid.write(s)
Note: See TracBrowser for help on using the repository browser.