source: production/onslow_2006/make_report.py @ 2944

Last change on this file since 2944 was 2944, checked in by sexton, 18 years ago

updates

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