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

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

(i) incorporating new supply of interpolated data for Broome (ii) updating report to look at MOST versus ANUGA for Hobart scenario

File size: 5.3 KB
RevLine 
[3965]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
[3972]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('Water Depth')
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
[3965]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#
[3972]52production_dirs = {'20061022_224422': 'Mw 8-7', # refined around paleo sites
[3965]53                   'MOST': 'MOST'} # MOST input for Mw 8-7
54
[3972]55gauge_map = 'gauges_map_bom.jpg'
[3965]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                                      surface = False,
75                                      time_min = None,
76                                      time_max = None,
77                                      title_on = False,
78                                      verbose = True)
79
80latex_output.append(texname)
81
[3972]82elevfiles = {}
83for label_id in production_dirs.keys():
84   
85    file_loc = project.outputdir + label_id + sep
86    elevfile = file_loc + 'gauges_maxmins' + '.csv'
87    if label_id == 'MOST':
88        elevfile = project.boundarydir + 'gauges_maxmins' + '.csv'
89    elevfiles[elevfile] = label_id
90
91figname = 'compare_elev.png'
92print_elev(elevfiles,production_dirs,report_dir+figname)
93
[3965]94# Start report generation
95report_name = reportdir + 'boundary_report.tex'
96fid = open(report_name, 'w')
97
98s = """
99% This is based on an automatically generated file (by make_report.py).
100%
101% Manual parts are:
102% * an abstract must be written in abstract.tex
103% * an introduction must be written in introduction.tex; a basic outline and
104%   some of the core inputs are already in place
105% * outline of the modelling methodology provided in modelling_methodology.tex
106% * the tsunami-genic event should be discussed in tsunami_scenario.tex
107% * an computational_setup.tex file needs to be written for the particular scenario
108% * the interpretation of the results needs to be written to interpretation.tex
109% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
110% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
111% * a summary must be written into summary.tex
112% * metadata for the scenario data to be included in metadata.tex
113
114\documentclass{article}
115
116\usepackage{ae} % or {zefonts}
117\usepackage[T1]{fontenc}
118\usepackage[ansinew]{inputenc}
119\usepackage{amsmath}
120\usepackage{amssymb}
121\usepackage{graphicx}
122\usepackage{color}
123\usepackage[colorlinks]{hyperref}
124\usepackage{lscape} %landcape pages support
125\usepackage{setspace}
126\usepackage{rotating}
127\include{appendix}
128\setstretch{1.25}
129\\topmargin 0pt
130\oddsidemargin 0pt
131\evensidemargin 0pt
132\marginparwidth 0.5pt
133\\textwidth \paperwidth
134\\advance\\textwidth -2in
135
136"""
137fid.write(s)
138
139s = """
140\date{\\today}
141%\\author{Geoscience Australia}
142
143\\begin{document}
[3972]144\\title{Comparison between ANUGA and MOST - Hobart}
[3965]145\maketitle
146"""
147fid.write(s)
148
[3972]149s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[scale=0.6]{../report_figures/%s}}' %gauge_map
[3965]150fid.write(s)
151
152= """
153\caption{Point locations used for boundary investigation.} 
154\label{fig:points}
155\end{figure}
156"""
157fid.write(s)
[3972]158
159s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{%s}}' %figname
160fid.write(s)
161
162= """
163\caption{Elevation data for ANUGA and MOST.} 
164\label{fig:elevation}
165\end{figure}
166"""
167fid.write(s)
168
[3965]169s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
170fid.write(s)
171
172s="""
173\end{document}
174"""
175fid.write(s)
Note: See TracBrowser for help on using the repository browser.