source: anuga_work/production/hobart_2006/make_report_boundary_BOM.py @ 4228

Last change on this file since 4228 was 4228, checked in by sexton, 17 years ago

(1) add building damage scripts for the study areas and update project.py (2) update report generation scripts (3) update Gantt chart (4) report updates to reflect URS input

File size: 5.4 KB
Line 
1from os import getcwd, sep, altsep, mkdir, access, F_OK
2import project
3from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
4
5def print_elev(elevfiles,production_dirs,figname):
6    from pylab import plot, xlabel, ylabel, hold, ion, legend, savefig, close
7    ion()
8    hold(True)
9    cstr = ['g', 'r', 'b', 'c', 'm', 'y', 'k']
10    j = -1
11    leg_label = []
12    for elevfile in elevfiles.keys():
13        x, elev = read_file(elevfile)
14        leg_label.append(production_dirs[elevfiles[elevfile]])
15        j += 1
16        plot(x, elev, '-', c = cstr[j])
17    xlabel('Easting')
18    ylabel('Elevation')
19    legend((leg_label),loc='upper right')
20    savefig(figname)
21    close('all')
22    return
23
24def read_file(filename):
25    fid = open(filename)
26    lines = fid.readlines()
27    fid.close()
28    x = []
29    elev = []
30    i = -1
31    for line in lines[:]:
32        i += 1
33        fields = line.split(',')
34        x.append(float(fields[3].strip(' ')))
35        elev.append(float(fields[2].strip(' ')))
36    return x, elev
37
38# Derive scenario name
39p = getcwd().split(sep)
40scenario = p[-1] # Last element of absolute CWD path
41scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
42test = scenario_name.split('_')
43if len(test) <> 1:
44    scenario_name = '%s %s' %(test[0], test[1])
45   
46# Create report directory
47reportdir = getcwd()+sep+'report'+sep
48if access(reportdir,F_OK) == 0:
49    mkdir (reportdir)
50   
51#
52production_dirs = {'20061022_224422': 'Mw 8-7', # refined around paleo sites
53                   'MOST': 'MOST'} # MOST input for Mw 8-7
54
55gauge_map = 'gauges_map_bom.jpg'
56
57# Create sections and graphs for each designated production directory
58latex_output = []
59swwfiles = {}
60for label_id in production_dirs.keys():
61   
62    file_loc = project.outputdir + label_id + sep
63    swwfile = file_loc + project.basename + '.sww'
64    if label_id == 'MOST':
65        swwfile = project.boundarydir + project.boundary_basename + '.sww'
66    swwfiles[swwfile] = label_id
67
68texname, elev_output = sww2timeseries(swwfiles,
69                                      project.gauge_filename_bom,
70                                      production_dirs,
71                                      report = True,
72                                      reportname = 'latexoutput_boundary',
73                                      plot_quantity = ['stage', 'speed'],
74                                      generate_fig = True,
75                                      surface = False,
76                                      time_min = None,
77                                      time_max = None,
78                                      title_on = False,
79                                      verbose = True)
80
81latex_output.append(texname)
82
83elevfiles = {}
84for label_id in production_dirs.keys():
85   
86    file_loc = project.outputdir + label_id + sep
87    elevfile = file_loc + 'gauges_maxmins' + '.csv'
88    if label_id == 'MOST':
89        elevfile = project.boundarydir + 'gauges_maxmins' + '.csv'
90    elevfiles[elevfile] = label_id
91
92figname = 'compare_elev.png'
93print_elev(elevfiles,production_dirs,reportdir+figname)
94
95# Start report generation
96report_name = reportdir + 'boundary_report.tex'
97fid = open(report_name, 'w')
98
99s = """
100% This is based on an automatically generated file (by make_report.py).
101%
102% Manual parts are:
103% * an abstract must be written in abstract.tex
104% * an introduction must be written in introduction.tex; a basic outline and
105%   some of the core inputs are already in place
106% * outline of the modelling methodology provided in modelling_methodology.tex
107% * the tsunami-genic event should be discussed in tsunami_scenario.tex
108% * an computational_setup.tex file needs to be written for the particular scenario
109% * the interpretation of the results needs to be written to interpretation.tex
110% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
111% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
112% * a summary must be written into summary.tex
113% * metadata for the scenario data to be included in metadata.tex
114
115\documentclass{article}
116
117\usepackage{ae} % or {zefonts}
118\usepackage[T1]{fontenc}
119\usepackage[ansinew]{inputenc}
120\usepackage{amsmath}
121\usepackage{amssymb}
122\usepackage{graphicx}
123\usepackage{color}
124\usepackage[colorlinks]{hyperref}
125\usepackage{lscape} %landcape pages support
126\usepackage{setspace}
127\usepackage{rotating}
128\include{appendix}
129\setstretch{1.25}
130\\topmargin 0pt
131\oddsidemargin 0pt
132\evensidemargin 0pt
133\marginparwidth 0.5pt
134\\textwidth \paperwidth
135\\advance\\textwidth -2in
136
137"""
138fid.write(s)
139
140s = """
141\date{\\today}
142%\\author{Geoscience Australia}
143
144\\begin{document}
145\\title{Comparison between ANUGA and MOST - Hobart}
146\maketitle
147"""
148fid.write(s)
149
150s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[scale=0.6]{../report_figures/%s}}' %gauge_map
151fid.write(s)
152
153= """
154\caption{Point locations used for boundary investigation.} 
155\label{fig:points}
156\end{figure}
157"""
158fid.write(s)
159
160s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{%s}}' %figname
161fid.write(s)
162
163= """
164\caption{Elevation data for ANUGA and MOST.} 
165\label{fig:elevation}
166\end{figure}
167"""
168fid.write(s)
169
170s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
171fid.write(s)
172
173s="""
174\end{document}
175"""
176fid.write(s)
Note: See TracBrowser for help on using the repository browser.