source: production/onslow_2006/make_report.py @ 2837

Last change on this file since 2837 was 2837, checked in by ole, 18 years ago

Cosmetics

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