source: production/onslow_2006/make_report.py @ 2839

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

updates and setting up scripts for timeseries and report generation for Pt Hedland

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