Index: /anuga_work/production/broome_2006/get_timeseries.py
===================================================================
--- /anuga_work/production/broome_2006/get_timeseries.py	(revision 4580)
+++ /anuga_work/production/broome_2006/get_timeseries.py	(revision 4580)
@@ -0,0 +1,42 @@
+"""
+Generate images of "gauges" for production run
+
+Inputs:
+
+production dirs: dictionary of production directories with a
+                 association to that simulation run, eg high tide,
+                 low tide and MSL.
+                    
+Outputs:
+
+* figures used for report stored in the report_figure directory
+
+"""
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries
+
+# bulli event
+production_dirs = {'20070518_060438_run_final_0_nbartzis': ''}
+
+swwfiles = {}    
+for label_id in production_dirs.keys():
+    
+    file_loc = project.outputdir + label_id + sep
+    swwfile = file_loc + project.basename + '.sww'
+    swwfiles[swwfile] = label_id
+        
+    texname, elev_output = sww2timeseries(swwfiles,
+                                          project.beach_gauges,
+                                          production_dirs,
+                                          report = False,
+                                          plot_quantity = ['stage', 'speed'],
+                                          generate_fig = True,
+                                          surface = False,
+                                          time_min = None,
+                                          time_max = None,
+                                          time_unit = 'hours',
+                                          title_on = False,
+                                          use_cache = True,
+                                          verbose = True)
+                                      
Index: /anuga_work/production/broome_2006/project.py
===================================================================
--- /anuga_work/production/broome_2006/project.py	(revision 4579)
+++ /anuga_work/production/broome_2006/project.py	(revision 4580)
@@ -111,4 +111,5 @@
 
 #gauges
+beach_gauges = 'beach_gauges.csv'
 gauge_name = 'broome_gauges.csv'
 gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep
Index: /anuga_work/production/dampier_2006/plot_for_map.py
===================================================================
--- /anuga_work/production/dampier_2006/plot_for_map.py	(revision 4580)
+++ /anuga_work/production/dampier_2006/plot_for_map.py	(revision 4580)
@@ -0,0 +1,85 @@
+"""Read in csv files and plot time series
+
+"""
+
+import project
+from pylab import plot, xlabel, ylabel, savefig, ion, hold, axis, close, figure
+from os import sep
+ 
+time_dir1 = '20070419_065050_run'# HAT dampier
+directory = project.output_dir
+filenames = [directory + time_dir1 + sep + 'gauges_time_series_p12.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_p13.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_p14.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_p15.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_p20.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_p21.csv',
+             directory + time_dir1 + sep + 'gauges_time_series_p22.csv',
+             directory + time_dir1 + sep + 'gauges_time_series_p23.csv']
+
+def get_time_series_from_file(filename):
+    fid = open(filename)
+    lines = fid.readlines()
+    fid.close()
+    
+    t = []
+    stage = []
+    depth = []
+    speed = []
+    momentum = []
+    for line in lines[1:]:
+        fields = line.split(',')
+        t.append((float(fields[0])/3600.0+4000./3600.)) # 4000 for Dampier run
+        stage.append(float(fields[1]))
+        depth.append(float(fields[1])-float(fields[4]))
+        speed.append(float(fields[3]))
+        momentum.append(float(fields[2]))        
+    return t, stage, depth, speed, momentum
+
+max_st = 0.
+max_sp = 0.
+max_mom = 0.
+min_st = 0.
+min_sp = 0.
+min_mom = 0.
+max_t = 0.0
+
+for filename in filenames:
+    t, stage, depth, speed, momentum = get_time_series_from_file(filename)
+    if max(t) > max_t: max_t = max(t)
+    if max(stage) > max_st: max_st = max(stage)
+    if max(speed) > max_sp: max_sp = max(speed)
+    if max(momentum) > max_mom: max_mom = max(momentum)
+    if min(stage) < min_st: min_st = min(stage)
+    if min(speed) < min_sp: min_sp = min(speed)
+    if min(momentum) < min_mom: min_mom = min(momentum)
+
+#stage_axis = ([5000./3600.,max_t, min_st, max_st])
+#speed_axis = ([5000/3600.,max_t, min_sp, max_sp])
+#mom_axis = ([5000/3600.,max_t, min_mom, max_mom])
+
+stage_axis = ([5000./3600.,max_t, -2.5,6.5])
+    
+ion()
+
+hold(False)
+
+for i, filename in enumerate(filenames):
+    t, stage, depth, speed, momentum = get_time_series_from_file(filename)
+
+    i1 = filename.rfind('gauges')
+    i2 = filename.rfind('csv')
+    name = filename[i1:i2-1]
+
+    community = 'dampier'
+    figure(1)
+    plot(t, stage, '-b', linewidth=1)
+    xlabel('time (hour)')
+    ylabel('wave height (m)')
+    axis(stage_axis)
+    figname = 'stage_%s_%s.png' %(name,community)
+    savefig(figname)
+
+
+close('all')
+
Index: /anuga_work/production/exmouth_2006/get_timeseries.py
===================================================================
--- /anuga_work/production/exmouth_2006/get_timeseries.py	(revision 4580)
+++ /anuga_work/production/exmouth_2006/get_timeseries.py	(revision 4580)
@@ -0,0 +1,42 @@
+"""
+Generate images of "gauges" for production run
+
+Inputs:
+
+production dirs: dictionary of production directories with a
+                 association to that simulation run, eg high tide,
+                 low tide and MSL.
+                    
+Outputs:
+
+* figures used for report stored in the report_figure directory
+
+"""
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries
+
+# bulli event
+production_dirs = {'20070528_061822_run_final_1.4_dampier_nbartzis': ''}
+
+swwfiles = {}    
+for label_id in production_dirs.keys():
+    
+    file_loc = project.outputdir + label_id + sep
+    swwfile = file_loc + project.basename + '.sww'
+    swwfiles[swwfile] = label_id
+        
+    texname, elev_output = sww2timeseries(swwfiles,
+                                          project.beach_gauges,
+                                          production_dirs,
+                                          report = False,
+                                          plot_quantity = ['stage', 'speed'],
+                                          generate_fig = True,
+                                          surface = False,
+                                          time_min = None,
+                                          time_max = None,
+                                          time_unit = 'hours',
+                                          title_on = False,
+                                          use_cache = True,
+                                          verbose = True)
+                                      
Index: /anuga_work/production/exmouth_2006/project.py
===================================================================
--- /anuga_work/production/exmouth_2006/project.py	(revision 4579)
+++ /anuga_work/production/exmouth_2006/project.py	(revision 4580)
@@ -138,4 +138,5 @@
 
 #gauges
+beach_gauges = 'beach_gauges.csv'
 gauge_name = 'exmouth_gauges.csv'
 gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep
Index: /anuga_work/production/hobart_2006/make_report_boundary.py
===================================================================
--- /anuga_work/production/hobart_2006/make_report_boundary.py	(revision 4580)
+++ /anuga_work/production/hobart_2006/make_report_boundary.py	(revision 4580)
@@ -0,0 +1,154 @@
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
+
+# Derive scenario name
+p = getcwd().split(sep)
+scenario = p[-1] # Last element of absolute CWD path
+scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
+test = scenario_name.split('_')
+if len(test) <> 1:
+    scenario_name = '%s %s' %(test[0], test[1])
+    
+# Create report directory
+reportdir = getcwd()+sep+'report'+sep
+if access(reportdir,F_OK) == 0:
+    mkdir (reportdir)
+    
+# 
+production_dirs = {'20061008_234702': 'Mw 8-7', # 2500 res, 750000 other res
+                   #'20061016_065743': 'Mw 8-7 refined', #new interior res
+                   '20061017_004409': 'Mw 8-7 refined', #new interior res
+                   '20061017_022640': 'Mw 8-7 paleo sites', #new interior res 
+                   'MOST': 'MOST'} # MOST input for Mw 8-7
+
+#production_dirs = {'20061006_062319': 'Mw 8-5', # 2500 res, 750000 other res
+#                   'MOST': 'MOST'} # MOST input for Mw 8-5
+
+gauge_map = 'boundary_gauges.jpg'
+
+# Create sections and graphs for each designated production directory
+latex_output = []
+swwfiles = {}
+for label_id in production_dirs.keys():
+    
+    file_loc = project.outputdir + label_id + sep
+    swwfile = file_loc + project.basename + '.sww'
+    if label_id == 'MOST':
+        swwfile = project.boundarydir + project.boundary_basename + '.sww'
+    swwfiles[swwfile] = label_id
+
+texname, elev_output = sww2timeseries(swwfiles,
+                                      project.gauge_filename,
+                                      production_dirs,
+                                      report = True,
+                                      reportname = 'latexoutput_boundary',
+                                      #reportname = 'latexoutput_boundary_event2',
+                                      plot_quantity = ['stage', 'speed'],
+                                      generate_fig = True,
+                                      surface = False,
+                                      time_min = None,
+                                      time_max = None,
+                                      title_on = False,
+                                      verbose = True)
+
+latex_output.append(texname)
+
+# Start report generation
+# Future: generate_report(reportdir, scenario, report_title, 
+# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
+report_name = reportdir + 'boundary_report.tex'
+#report_name = reportdir + 'boundary_report_event2.tex'
+fid = open(report_name, 'w')
+
+s = """
+% This is based on an automatically generated file (by make_report.py).
+%
+% Manual parts are:
+% * an abstract must be written in abstract.tex
+% * an introduction must be written in introduction.tex; a basic outline and
+%   some of the core inputs are already in place
+% * outline of the modelling methodology provided in modelling_methodology.tex
+% * the tsunami-genic event should be discussed in tsunami_scenario.tex
+% * an computational_setup.tex file needs to be written for the particular scenario
+% * the interpretation of the results needs to be written to interpretation.tex
+% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
+% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
+% * a summary must be written into summary.tex
+% * metadata for the scenario data to be included in metadata.tex
+
+\documentclass{article}
+
+\usepackage{ae} % or {zefonts}
+\usepackage[T1]{fontenc}
+\usepackage[ansinew]{inputenc}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{graphicx}
+\usepackage{color}
+\usepackage[colorlinks]{hyperref}
+\usepackage{lscape} %landcape pages support
+\usepackage{setspace}
+\usepackage{rotating}
+\include{appendix}
+\setstretch{1.25}
+\\topmargin 0pt
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\marginparwidth 0.5pt
+\\textwidth \paperwidth
+\\advance\\textwidth -2in
+
+"""
+fid.write(s)
+
+s = """
+\date{\\today}
+%\\author{Geoscience Australia}
+
+\\begin{document}
+\\title{Comparison between ANUGA and MOST}
+\maketitle
+"""
+fid.write(s)
+
+# Generate latex output for location points
+s = '\\begin{table} \\begin{center} \n'
+fid.write(s)
+s = '\caption{Defined point locations for %s study area.}' %scenario_name
+fid.write(s)
+s = """
+\label{table:locations}
+\\begin{tabular}{|l|l|l|l|}\hline
+\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
+"""
+fid.write(s)
+
+gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
+
+for name, gauges, elev in zip(locations, gauges, elevation):
+    east = gauges[0]
+    north = gauges[1]
+    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
+    fid.write(s)
+
+s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
+fid.write(s)
+
+s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map
+fid.write(s)
+
+s  = """
+\caption{Point locations used for boundary investigation.}  
+\label{fig:points}
+\end{figure}
+"""
+fid.write(s)
+    
+s = '\input{%s} \n \clearpage \n \n' %latex_output[0]
+fid.write(s)
+
+s="""
+\end{document}
+"""
+fid.write(s)
Index: /anuga_work/production/hobart_2006/plot_data.py
===================================================================
--- /anuga_work/production/hobart_2006/plot_data.py	(revision 4580)
+++ /anuga_work/production/hobart_2006/plot_data.py	(revision 4580)
@@ -0,0 +1,63 @@
+import project
+
+from pylab import *
+
+#import pylab as p1
+#import mpl3d.mplot3d as p3
+
+ion()
+
+# load data
+def get_data_from_file(filename):
+
+    fid = open(filename)
+    lines = fid.readlines()
+    fid.close()    
+    x = zeros((len(lines),1), Float)
+    y = zeros((len(lines),1), Float)
+    z = zeros((len(lines),1), Float)
+    i = 0
+    for line in lines[1:]:
+        fields = line.split(',')
+        x[i] = float(fields[0])
+        y[i] = float(fields[1])
+        z[i] = float(fields[2])
+        i = i + 1
+
+    return x, y, z
+
+x, y, z = get_data_from_file(project.offshore_dem_name_aho11+'.xya')
+# interpolate x,y to X,Y grid?
+
+plot(x,y,'.')
+xlabel('easting')
+ylabel('northing')
+axis([min(x),max(x),min(y),min(z)])
+import sys; sys.exit() 
+
+fig = p1.figure(1)
+ax = p3.Axes3D(fig)
+#ax.plot_surface(x,y,z)
+#ax.plot_wireframe(x,y,z)
+#ax.plot3D(ravel(x,y,z))
+ax.set_xlabel('easting')
+ax.set_ylabel('northing')
+ax.set_zlabel('elevation')
+fig.add_axes(ax)
+p1.show()
+surfacefig = 'solution_surface'
+p1.savefig(surfacefig)
+p1.close()
+
+# example 1
+X = rand(20,20)
+im = imshow(X)
+
+# example 2
+delta = 0.025
+x = y = arange(-3.0,3,delta)
+X, Y = meshgrid(x,y)
+Z1 = bivariate_normal(X,Y,1.0,1.0,0.0,0.0)
+Z2 = bivariate_normal(X,Y,1.5,0.5,1.0,1.0)
+im = imshow(Z2-Z1,interpolation='bilinear')
+axis('off')
Index: /anuga_work/production/newcastle_2006/make_report.py
===================================================================
--- /anuga_work/production/newcastle_2006/make_report.py	(revision 4580)
+++ /anuga_work/production/newcastle_2006/make_report.py	(revision 4580)
@@ -0,0 +1,343 @@
+"""
+Generate report for production run
+
+NOTE - this will only work on Windows system (as pylab not installed on unix).
+
+Inputs:
+
+report_title:    title to be included in tex file
+production dirs: dictionary of production directories with a
+                 association to that simulation run, eg high tide,
+                 low tide and MSL.
+                    
+
+Outputs:
+
+* Report generated to scenario_report.tex where the scenario relates
+the name of the production directory this script is being run from.
+* figures used for report stored in the report_figure directory
+NOTE, this directory will need to be committed, as well as
+the latex files.
+
+The report structure is
+
+* Executive Summary
+* Introduction
+* Modelling Methodology
+* Tsunami scenario
+* Data sources
+* Inundation model
+* Inundation modelling results
+* Impact modelling
+* Summary
+* Acknowledgements
+* References
+* Appendix: Metadata
+* Appendix: Time series outputs
+
+Other files included in document which require manual intervention:
+
+* an abstract must be written in abstract.tex
+* an introduction must be written in introduction.tex; a basic outline and
+  some of the core inputs are already in place
+* the tsunami-genic event should be discussed in tsunami_scenario.tex
+* a discussion of the ANUGA model is required in anuga.tex
+* a computational_setup.tex file needs to be written for the particular scenario
+* the interpretation of the results needs to be written to interpretation.tex
+* maximum inundation map names need to be included in HAT_map and LAT_map etc.
+* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
+* a summary must be written into summary.tex
+* metadata for the scenario data to be included in metadata.tex
+
+May, June 2006                    
+"""
+
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project_slide
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
+
+# Derive scenario name
+p = getcwd().split(sep)
+scenario = p[-1] # Last element of absolute CWD path
+scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
+test = scenario_name.split('_')
+if len(test) <> 1:
+    scenario_name = '%s %s' %(test[0], test[1])
+
+# Create report directory
+reportdir = getcwd()+sep+'report'+sep
+if access(reportdir,F_OK) == 0:
+    mkdir (reportdir)
+    
+# User defined inputs
+report_title = 'Tsunami inundation modelling for the NSW coastline: Generation by Submarine Mass Failures' 
+
+# WA DLI data
+production_dirs = {#'20061211_071516': 'Area B - Bulli'}
+                   #'20061212_012705': 'Area B - Shovel',
+                   #'20061212_064807': 'Area B - Yacaaba',
+                   #'20061211_060105': 'Area A - Bulli'}
+                   #'20061212_012715': 'Area A - Shovel',
+                   #'20061212_064735': 'Area A - Yacaaba',
+                   '20061211_073709': 'Area C - Bulli'}
+                   #'20061212_012802': 'Area C - Shovel',
+                   #'20061212_064757': 'Area C - Yacaaba'}
+
+do_timeseries = True
+
+is_parallel = False
+if is_parallel == True:
+    nodes = 8
+
+max_maps = {'Area A - Bulli': 'bulli_A_map',
+            'Area A - Shovel': 'bulli_B_map',
+            'Area A - Yacaaba': 'bulli_C_map',
+            'Area B - Bulli': 'shovel_A_map',
+            'Area B - Shovel': 'shovel_B_map',
+            'Area B - Yacaaba': 'shovel_C_map',
+            'Area C - Bulli': 'yacaaba_A_map',
+            'Area C - Shovel': 'yacaaba_B_map',
+            'Area C - Yacaaba': 'yacaaba_C_map'}
+
+##gauge_mapA = ''
+##gauge_mapB = ''
+##gauge_mapC = ''
+
+# Create sections and graphs for each designated production directory
+latex_output = []
+report_name = 'latexoutput'
+
+if do_timeseries == True:
+    
+    if is_parallel == True:
+
+        for i in range(nodes):
+            print 'Sending node %d of %d' %(i,nodes)
+            swwfiles = {}
+            reportname = report_name + '_%s' %(i)
+            for label_id in production_dirs.keys():
+                file_loc = project_slide.outputdir + label_id + sep
+                sww_extra = '_P%s_%s' %(i,nodes)
+                swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
+                swwfiles[swwfile] = label_id
+
+                texname, elev_output = sww2timeseries(swwfiles,
+                                                      project.gauge_filename,
+                                                      production_dirs,
+                                                      report = True,
+                                                      reportname = reportname,
+                                                      plot_quantity = ['stage', 'momentum'],
+                                                      generate_fig = True,
+                                                      surface = False,
+                                                      time_min = None,
+                                                      time_max = None,
+                                                      title_on = False,
+                                                      verbose = True)
+                
+                latex_output.append(texname)
+        
+    else:
+        swwfiles = {}
+        for label_id in production_dirs.keys():
+
+            file_loc = project_slide.outputdir + label_id + sep
+            if production_dirs[label_id] == 'Area A - Bulli':
+                scenario_dir_name = 'wollongong_tsunami_scenario_2006'
+                file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep
+            if production_dirs[label_id] == 'Area C - Bulli':
+                scenario_dir_name = 'newcastle_tsunami_scenario_2006'
+                file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep
+            swwfile = file_loc + project_slide.basename + '.sww'
+            swwfiles[swwfile] = label_id
+            
+        texname, elev_output = sww2timeseries(swwfiles,
+                                              'arrivaltime.csv',#project.gauge_filename,
+                                              production_dirs,
+                                              report = True,
+                                              reportname = report_name,
+                                              plot_quantity = ['stage', 'momentum'],
+                                              generate_fig = True,
+                                              surface = False,
+                                              time_min = None,
+                                              time_max = None,
+                                              title_on = False,
+                                              verbose = True)
+
+# Start report generation
+# Future: generate_report(reportdir, scenario, report_title, 
+# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
+report_name = reportdir + scenario + '_report.tex'
+fid = open(report_name, 'w')
+
+s = """
+% This is based on an automatically generated file (by make_report.py).
+%
+% Manual parts are:
+% * an abstract must be written in abstract.tex
+% * an introduction must be written in introduction.tex; a basic outline and
+%   some of the core inputs are already in place
+% * outline of the modelling methodology provided in modelling_methodology.tex
+% * the tsunami-genic event should be discussed in tsunami_scenario.tex
+% * an computational_setup.tex file needs to be written for the particular scenario
+% * the interpretation of the results needs to be written to interpretation.tex
+% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
+% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
+% * a summary must be written into summary.tex
+% * metadata for the scenario data to be included in metadata.tex
+
+\documentclass{article}
+
+\usepackage{ae} % or {zefonts}
+\usepackage[T1]{fontenc}
+\usepackage[ansinew]{inputenc}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{graphicx}
+\usepackage{color}
+\usepackage[colorlinks]{hyperref}
+\usepackage{lscape} %landcape pages support
+\usepackage{setspace}
+\usepackage{rotating}
+\usepackage{pdfpages}
+\include{appendix}
+\setstretch{1.25}
+\\topmargin 0pt
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\marginparwidth 0.5pt
+\\textwidth \paperwidth
+\\advance\\textwidth -2in
+\\newcommand{\degree}{\ensuremath{^\circ}}
+\\newcommand{\sech}{\operatorname{sech}}
+
+"""
+fid.write(s)
+
+s = """
+\date{\\today}
+%\\author{Geoscience Australia}
+
+\\begin{document}
+\\title{
+\\begin{figure}[hbt]
+  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
+\end{figure}
+"""
+fid.write(s)
+s = '%s} '%report_title
+fid.write(s)
+s = """
+  \maketitle
+
+    \section{Executive Summary}
+    \label{sec:execsum}
+  \input{execsum}
+
+\pagebreak
+
+  \\tableofcontents
+  
+   \section{Modelling methodology}
+    \label{sec:methodology}
+    \input{modelling_methodology}
+
+  \section{Data sources}
+    \label{sec:data}
+    \input{data}
+        
+  \section{Inundation modelling results}
+     \label{sec:results}
+         
+"""
+fid.write(s)
+
+# Generate latex output for location points
+##s = '\\begin{table} \\begin{center} \n'
+##fid.write(s)
+##s = '\caption{Defined point locations for %s study area.}' %scenario_name
+##fid.write(s)
+##s = """
+##\label{table:locations}
+##\\begin{tabular}{|l|l|l|l|}\hline
+##\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
+##"""
+##fid.write(s)
+##
+##gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
+##
+##for name, gauges, elev in zip(locations, gauges, elevation):
+##    east = gauges[0]
+##    north = gauges[1]
+##    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
+##    fid.write(s)
+##
+##s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
+##fid.write(s)
+##
+
+##s = '\\begin{figure}[hbt] \centerline{\includegraphics[scale = 0.5]{../report_figures/%s}}' %gauge_map2
+##fid.write(s)
+##s  = """
+##\caption{Point locations used for Dampier study; surrounding the facility.
+##See Appendix \\ref{sec:timeseries} for stage and momentum results.
+##}  
+##\label{fig:points2}
+##\end{figure}
+##"""
+##fid.write(s)
+    
+s = '\input{interpretation} \n'
+fid.write(s)
+
+# Assign titles to each production section 
+# Must specify one name per section
+for i, name in enumerate(production_dirs.keys()):
+
+    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
+    fid.write(s)
+
+# Closing
+
+
+s = """
+
+     \section{Summary}
+     \label{sec:summary}
+     \input{summary}
+
+     %\section{Acknowledgements}
+     %\input{acknowledgements}
+     
+    \input{references}
+
+    \\appendix
+    
+ %  \section{Metadata}
+  %   \label{sec:metadata}
+   %  \input{metadata}
+     
+\section{ANUGA modelling parameters}
+\label{sec:anugasetup}
+\input{anuga_setup}
+
+\section{Submarine Mass Failure Model}
+\label{sec:smfmodel}
+\input{smfmodel}
+
+\clearpage
+
+   \section{Time series}
+     \label{sec:timeseries}
+"""
+fid.write(s)
+
+##for i in range(len(latex_output)):
+##    if latex_output[i] <> '':
+##        s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
+##        fid.write(s)
+s = '\input{%s} \n \clearpage \n \n' %texname  
+fid.write(s)
+s="""
+\end{document}
+"""
+fid.write(s)
Index: /anuga_work/production/onslow_2006/convert_db_points.py
===================================================================
--- /anuga_work/production/onslow_2006/convert_db_points.py	(revision 4580)
+++ /anuga_work/production/onslow_2006/convert_db_points.py	(revision 4580)
@@ -0,0 +1,33 @@
+"""
+Convert DB's data from lat/long to easting/northing
+
+"""
+
+def alter_file(filename,filenameout):
+
+    from anuga.coordinate_transforms.redfearn import redfearn
+    
+    fid = open(filename)
+    lines = fid.readlines()
+    fid.close()
+    
+    fid_out = open(filenameout, 'w')
+    s = '%s,%s\n' %('easting','northing')
+    fid_out.write(s)
+    for line in lines[1:]:
+       fields = line.split(',')
+       x = float(fields[1])
+       y = float(fields[0])
+       zone, easting, northing = redfearn(x,y)
+       s = '%f,%f\n' %(easting,northing)
+       fid_out.write(s)
+
+    fid_out.close() 
+
+    return
+
+import project
+
+filename = project.gaugedir + 'db_points.txt'
+filename_out = project.gaugedir + 'db_points_convert.txt'
+alter_file(filename,filename_out)
Index: /anuga_work/production/onslow_2006/get_timeseries.py
===================================================================
--- /anuga_work/production/onslow_2006/get_timeseries.py	(revision 4579)
+++ /anuga_work/production/onslow_2006/get_timeseries.py	(revision 4580)
@@ -1,224 +1,43 @@
-"""Read in sww file, interpolate at specified locations and plot time series
+"""
+Generate images of "gauges" for production run
+
+Inputs:
+
+production dirs: dictionary of production directories with a
+                 association to that simulation run, eg high tide,
+                 low tide and MSL.
+                    
+Outputs:
+
+* figures used for report stored in the report_figure directory
 
 """
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project
+import project_urs
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries
 
-import project
-from anuga.pyvolution.util import file_function
-from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn
-from pylab import *
-from os import sep
-# from matplotlib.ticker import MultipleLocator, FormatStrFormatter
+# 
+production_dirs = {'20070608_062811_run_final_1.5_exmouth_nbartzis': ''}
 
- 
-
-time_dir = "20060426_004129" #"20060419_071046"
-directory = project.outputdir
-swwfile = directory + time_dir +sep + "source.sww"
-'''
-directory = project.boundarydir
-swwfile = directory + "SU-AU_clip.sww"
-'''
-#swwfile = project.outputname + '.sww'
-
-def get_gauges_from_file(filename):
-    fid = open(filename)
-    lines = fid.readlines()
-    fid.close()
+swwfiles = {}    
+for label_id in production_dirs.keys():
     
-    gauges = []
-    gaugelocation = []
-    for line in lines[1:]:
-        fields = line.split(',')
-        # my gauge file set up as  easting, northing locationname,
+    file_loc = project.outputdir + label_id + sep
+    swwfile = file_loc + project_urs.scenario_name + '.sww'
+    swwfiles[swwfile] = label_id
         
-        easting = float(fields[0])
-        northing = float(fields[1])
-        location = fields[2].strip()
-        print 'location',location
-        #z, easting, northing  = redfearn(lat, lon)
-        gauges.append([easting, northing])
-        gaugelocation.append(location)
-        
-    #Return gauges and raw data for subsequent storage
-    return gauges, lines, gaugelocation
-
-gauges, lines, gauge_names = get_gauges_from_file(project.gauge_filename)
-
-print 'number of gauges:   ', len(gauges)
-
-#Read model output
-quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum']
-
-f = file_function(swwfile,
-                  quantities = quantities,
-                  interpolation_points = gauges,
-                  verbose = True,
-                  use_cache = True)
-
-
-               
-from math import sqrt, atan, degrees
-from Numeric import ones
-
-N = len(gauges)
-
-for k, g in enumerate(gauges):
-    if k%((N+10)/10)==0: # diagnostics - print 10 lines
-        print 'Doing row %d of %d' %(k, N)
-
-    model_time = []
-    stages = []
-    elevations = []
-    momenta = []
-    velocity = []
-    xmom = []
-    ymom = []
-    bearings = []
-    depths = []
-
-    max_depth = 0
-    max_momentum = 0
-    max_velocity = 0
-
-    T = f.get_time()
-    due_east = 90.0*ones([len(T)])
-    due_west = 270.0*ones([len(T)])
-    maxT = max(T)
-    tstep = maxT/(len(T)-1)
-
-    for i, t in enumerate(T): # T is a list of times
-        #if tmin < t < tmax:
-        w = f(t, point_id = k)[0]
-        z = f(t, point_id = k)[1]
-        uh = f(t, point_id = k)[2]
-        vh = f(t, point_id = k)[3]
-        myloc = gauge_names[k]
-        depth = w-z
-
-        m = sqrt(uh*uh + vh*vh)   #Absolute momentum
-        vel = sqrt(uh*uh + vh*vh) / (w-z + 1.e-30) #Absolute velocity
-        angle = degrees(atan(vh/(uh+1.e-15)))
-        if (0 < angle < 90.0):
-            if vh > 0:
-                bearing = 90.0 - abs(angle)
-            if vh < 0:
-                bearing = 270.0 - abs(angle)
-        if (-90 < angle < 0):
-            if vh < 0:
-                bearing = 90.0 - abs(angle)
-            if vh > 0:
-                bearing = 270.0 - abs(angle)
-        if angle == 0:
-            bearing = 0.0
-                
-        model_time.append(t)        
-        stages.append(w)
-        elevations.append(z)  #Should be constant over time
-        momenta.append(m)
-        velocity.append(vel)
-        xmom.append(uh)
-        ymom.append(vh)
-        bearings.append(bearing)
-        depths.append(depth)
-
-        if w-z > max_depth:
-            max_depth = w-z
-        if m > max_momentum:            
-            max_momentum = m
-        if vel > max_velocity:
-            max_velocity = vel
-
-    #Plot only those gauges that have been inundated by more than a threshold
-    #if max_depth < 0.2:
-    #    print 'Skipping gauge %d' %k
-    #    continue
-
-    ion()
-    hold(False)
-
-    if elevations[0] < -10:
-        plot(model_time, stages, '-b')
-    else:    
-        plot(model_time, stages, '-b',
-             model_time, elevations, '-k')
-    #name = 'Gauge_%d: (%.1f, %.1f)' %(k, g[0], g[1])
-    name = 'Gauge_%d: (%.1f, %.1f) Location: %s' %(k, g[0], g[1], myloc)
-    title(name)
-
-    title('%s (stage)' %name)
-    xlabel('time [s]')
-    ylabel('elevation [m]')    
-    legend(('Stage', 'Bed = %.1f' %elevations[0]),
-           shadow=True,
-           loc='upper right')
-    #savefig('Gauge_%d_stage' %k)
-    #savefig('Gauge_%s_stage' %myloc)
-    savefig(project.gaugetimeseries+'Gauge_'+myloc+'_stage')
-
-    # raw_input('Next')
-    '''    
-    #Momentum plot
-    ion()
-    hold(False)
-    plot(model_time, momenta, '-r')
-    title(name)
-
-    title('%s (momentum)' %name)
-    xlabel('time [s]')
-    ylabel('sqrt( uh^2 + vh^2 ) [m^2/s]')    
-    #savefig('Gauge_%d_momentum' %k)
-    savefig('Gauge_%s_momentum' %myloc)
-    
-    # raw_input('Next')
-
-    #Bearing plot
-    ion()
-    hold(False)
-    ax = plot(model_time, bearings, '-b', model_time, due_west, '-.b',
-         model_time, due_east, '-.b')
-    title(name)
-    ax = axis([0, maxT, 0, 360])
-    text(maxT+tstep, 90, 'East')
-    text(maxT+tstep, 270, 'West')
-    #majorLocator = MultipleLocator(3600)
-    #print 'major', majorLocator[1]
-    #ax.xaxis.set_major_locator(majorLocator) #'yticklabels', range(30,390,30))
-    # set(labels,color='g',rotation=45)
-
-    title('%s (bearing)' %name)
-    xlabel('time [s]')
-    ylabel(' atan(vh/uh) [degrees from North]')    
-    #savefig('Gauge_%d_bearing' %k)
-    savefig('Gauge_%s_bearing' %myloc)
-    
-    # raw_input('Next')
-
-    #Speed plot
-    ion()
-    hold(False)
-    plot(model_time, velocity, '-r')
-    title(name)
-
-    title('%s (velocity)' %name)
-    xlabel('time [s]')
-    ylabel('sqrt( uh^2 + vh^2 ) / depth [m/s]')    
-    #savefig('Gauge_%d_speed' %k)
-    savefig('Gauge_%s_speed' %myloc)
-    '''    
-    # raw_input('Next')
-
-    whichone = 'Onslow_%s' %myloc
-#    thisfile = project.gaugetimeseries+whichone+'.csv'
-#    thisfile = directory + time_dir + sep +whichone+'.csv'
-    thisfile = directory  +whichone+'.csv'
-    
-    fid = open(thisfile, 'w')
-    s = 'Time, Depth, Momentum, Velocity \n'
-    fid.write(s)
-    for i_t, i_d, i_m, i_vel in zip(model_time, depths, momenta, velocity):
-        s = '%.2f, %.2f, %.2f, %.2f\n' %(i_t, i_d, i_m, i_vel)
-        fid.write(s)
-        
-show()
-
-
+    texname, elev_output = sww2timeseries(swwfiles,
+                                          project.td_gauges,
+                                          production_dirs,
+                                          report = False,
+                                          plot_quantity = ['stage', 'speed', 'momentum'],
+                                          generate_fig = True,
+                                          surface = False,
+                                          time_min = None,
+                                          time_max = None,
+                                          time_unit = 'hours',
+                                          title_on = False,
+                                          use_cache = True,
+                                          verbose = True)
+                                      
Index: /anuga_work/production/onslow_2006/plot_for_ATWS_ppt.py
===================================================================
--- /anuga_work/production/onslow_2006/plot_for_ATWS_ppt.py	(revision 4580)
+++ /anuga_work/production/onslow_2006/plot_for_ATWS_ppt.py	(revision 4580)
@@ -0,0 +1,164 @@
+"""Read in csv files and plot time series
+
+"""
+
+import project
+from pylab import plot, xlabel, ylabel, savefig, ion, hold, axis, close, figure
+from os import sep
+ 
+time_dir1 = '20070608_060316_run_final_1.5_onslow_nbartzis'# HAT onslow
+time_dir2 = '20070608_062811_run_final_1.5_exmouth_nbartzis'# HAT exmouth
+directory = project.outputdir
+filenames = [directory + time_dir1 + sep + 'gauges_time_series_100m.csv',
+            directory + time_dir2 + sep + 'gauges_time_series_100m.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_50m.csv',
+            directory + time_dir2 + sep + 'gauges_time_series_50m.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_20m.csv',
+            directory + time_dir2 + sep + 'gauges_time_series_20m.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_3.5m.csv',
+            directory + time_dir2 + sep + 'gauges_time_series_3.5m.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_closetown1.csv',
+            directory + time_dir2 + sep + 'gauges_time_series_closetown1.csv',
+            directory + time_dir1 + sep + 'gauges_time_series_closetown2.csv',   
+            directory + time_dir2 + sep + 'gauges_time_series_closetown2.csv']
+
+def get_time_series_from_file(filename):
+    fid = open(filename)
+    lines = fid.readlines()
+    fid.close()
+    
+    t = []
+    stage = []
+    depth = []
+    speed = []
+    momentum = []
+    for line in lines[1:]:
+        fields = line.split(',')
+        t.append((float(fields[0])/3600.0+5000./3600.))
+        stage.append(float(fields[1]))
+        depth.append(float(fields[1])-float(fields[4]))
+        speed.append(float(fields[3]))
+        momentum.append(float(fields[2]))        
+    return t, stage, depth, speed, momentum
+
+max_st = 0.
+max_sp = 0.
+max_mom = 0.
+min_st = 0.
+min_sp = 0.
+min_mom = 0.
+max_t = 0.0
+
+for filename in filenames:
+    t, stage, depth, speed, momentum = get_time_series_from_file(filename)
+    if max(t) > max_t: max_t = max(t)
+    if max(stage) > max_st: max_st = max(stage)
+    if max(speed) > max_sp: max_sp = max(speed)
+    if max(momentum) > max_mom: max_mom = max(momentum)
+    if min(stage) < min_st: min_st = min(stage)
+    if min(speed) < min_sp: min_sp = min(speed)
+    if min(momentum) < min_mom: min_mom = min(momentum)
+
+stage_axis = ([5000./3600.,max_t, min_st, max_st])
+speed_axis = ([5000/3600.,max_t, min_sp, max_sp])
+mom_axis = ([5000/3600.,max_t, min_mom, max_mom])
+
+ion()
+"""
+hold(False)
+
+for i, filename in enumerate(filenames):
+    t, stage, depth, speed, momentum = get_time_series_from_file(filename)
+
+    i1 = filename.rfind('gauges')
+    i2 = filename.rfind('csv')
+    name = filename[i1:i2-1]
+    loc = filename.rfind('1.5') + 4
+    if filename[loc] is 'o': community = 'onslow'
+    if filename[loc] is 'e': community = 'exmouth'
+
+    figure(1)
+    plot(t, stage, '-b', linewidth=1)
+    xlabel('time (hour)')
+    ylabel('wave height (m)')
+    axis(stage_axis)
+    figname = 'stage_%s_%s.png' %(name,community)
+    savefig(figname)
+
+    figure(2)
+    plot(t, speed, '-b', linewidth=1)
+    xlabel('time (hour)')
+    ylabel('speed (m/s)')
+    axis(speed_axis)
+    figname = 'speed_%s_%s.png' %(name,community)
+    savefig(figname)
+
+    figure(3)
+    plot(t, momentum, '-b', linewidth=1)
+    xlabel('time (hour)')
+    ylabel('momentum (m^2/sec)')
+    axis(mom_axis)
+    figname = 'mom_%s_%s.png' %(name,community)
+    savefig(figname)
+
+close('all')
+"""
+hold(True)
+count = 0
+figcount = 0
+cstr = ['b', 'r']
+
+filenames = [#directory + time_dir1 + sep + 'gauges_time_series_100m.csv',
+            #directory + time_dir2 + sep + 'gauges_time_series_100m.csv']
+            #directory + time_dir1 + sep + 'gauges_time_series_50m.csv',
+            #directory + time_dir2 + sep + 'gauges_time_series_50m.csv']
+            #directory + time_dir1 + sep + 'gauges_time_series_20m.csv',
+            #directory + time_dir2 + sep + 'gauges_time_series_20m.csv']
+            #directory + time_dir1 + sep + 'gauges_time_series_3.5m.csv',
+            #directory + time_dir2 + sep + 'gauges_time_series_3.5m.csv']
+            #directory + time_dir1 + sep + 'gauges_time_series_closetown1.csv',
+            #directory + time_dir2 + sep + 'gauges_time_series_closetown1.csv']
+            directory + time_dir1 + sep + 'gauges_time_series_closetown2.csv',   
+            directory + time_dir2 + sep + 'gauges_time_series_closetown2.csv']
+
+
+for i, filename in enumerate(filenames):
+    t, stage, depth, speed, momentum = get_time_series_from_file(filename)
+
+    i1 = filename.rfind('gauges')
+    i2 = filename.rfind('csv')
+    name = filename[i1:i2-1]
+    loc = filename.rfind('1.5') + 4
+    if filename[loc] is 'o': community = 'onslow'
+    if filename[loc] is 'e': community = 'exmouth'
+
+    figure(10+figcount)
+    plot(t, stage, c = cstr[i], linewidth=1)
+    xlabel('time (hour)')
+    ylabel('wave height (m)')
+    axis(stage_axis)
+    figname = 'stage_%s_both.png' %(name)
+    savefig(figname)
+
+    figure(20+figcount)
+    plot(t, speed, c = cstr[i], linewidth=1)
+    xlabel('time (hour)')
+    ylabel('speed (m/s)')
+    axis(speed_axis)
+    figname = 'speed_%s_both.png' %(name)
+    savefig(figname)
+
+    figure(30+figcount)
+    plot(t, momentum, c = cstr[i], linewidth=1)
+    xlabel('time (hour)')
+    ylabel('momentum (m^2/sec)')
+    axis(mom_axis)
+    figname = 'mom_%s_both.png' %(name)
+    savefig(figname)
+
+    count += 1
+    if int(count/2.) - count/2. is 0.0: figcount += 1
+    else:
+        figcount = 0
+  
+close('all')
Index: /anuga_work/production/onslow_2006/plot_for_talk.py
===================================================================
--- /anuga_work/production/onslow_2006/plot_for_talk.py	(revision 4580)
+++ /anuga_work/production/onslow_2006/plot_for_talk.py	(revision 4580)
@@ -0,0 +1,48 @@
+"""Read in sww file, interpolate at specified locations and plot time series
+
+"""
+
+import project
+from pylab import plot, xlabel, ylabel, savefig, ion
+from os import sep
+ 
+#time_dir = '20060704_063234'# MSL
+time_dir = '20060704_063005'# HAT
+directory = project.outputdir
+filename = directory + time_dir + sep + 'gauges_time_series_Beadon Bay east.csv'
+#filename = directory + time_dir + sep + 'gauges_time_series_Bindi Bindi Community.csv'
+
+def get_time_series_from_file(filename):
+    fid = open(filename)
+    lines = fid.readlines()
+    fid.close()
+    
+    t = []
+    stage = []
+    depth = []
+    elevation = []
+    for line in lines[1:]:
+        fields = line.split(',')
+        t.append(float(fields[0])/3600.0)
+        stage.append(float(fields[1]))
+        depth.append(float(fields[1])-float(fields[4]))
+        elevation.append(float(fields[4]))        
+    return t, stage, depth, elevation
+
+t, stage, depth, elevation = get_time_series_from_file(filename)
+
+ion()
+# find index for t around 200 mins plot(t[x:], stage[x:])
+if elevation[0] < 0:
+     plot(t, stage, '-b')
+     xlabel('time (hour)') 
+     ylabel('wave height [m]')
+else:
+     plot(t, depth, '-b')
+     xlabel('time (hour)')
+     ylabel('water depth (m)')
+
+    
+savefig('test')
+
+
Index: /anuga_work/production/onslow_2006/project.py
===================================================================
--- /anuga_work/production/onslow_2006/project.py	(revision 4579)
+++ /anuga_work/production/onslow_2006/project.py	(revision 4580)
@@ -75,4 +75,7 @@
 #for MOST
 gauge_filename = gaugedir + 'gauge_location_onslow.csv'
+gauge_filename_nsw = gaugedir + 'gauges_nsw.csv'
+beach_gauges = gaugedir + 'beach_gauges.csv'
+td_gauges = gaugedir + 'gauges_td.csv'
 gauge_filename_bindi = gaugedir + 'gauge_location_bindi.csv'
 gauges50 = gaugedir + '50_gauges.xya'
Index: /anuga_work/production/pt_hedland_2006/project.py
===================================================================
--- /anuga_work/production/pt_hedland_2006/project.py	(revision 4579)
+++ /anuga_work/production/pt_hedland_2006/project.py	(revision 4580)
@@ -127,4 +127,5 @@
 
 gauge_filename = gaugedir + 'gauge_location_port_hedland.csv'
+beach_gauges = gaugedir + 'beach_gauges.csv'
 gauge_checking = gaugedir + 'gauge_checking_test.csv'
 buildings_filename = gaugedir + 'Port_Hedland_res_Project.csv'
Index: /anuga_work/production/pt_hedland_2006/run_timeseries.py
===================================================================
--- /anuga_work/production/pt_hedland_2006/run_timeseries.py	(revision 4579)
+++ /anuga_work/production/pt_hedland_2006/run_timeseries.py	(revision 4580)
@@ -13,8 +13,8 @@
 # generate figures - see sww2timeseries for documentation
 texname = sww2timeseries(swwfile,
-                         project.gauge_filename,
+                         project.beach_gauges,
                          label_id,
                          report = False,
-                         plot_quantity = ['stage', 'velocity', 'bearing'],
+                         plot_quantity = ['stage', 'speed'],
                          time_min = None,
                          time_max = None,
Index: /anuga_work/production/sydney_2006/make_report.py
===================================================================
--- /anuga_work/production/sydney_2006/make_report.py	(revision 4580)
+++ /anuga_work/production/sydney_2006/make_report.py	(revision 4580)
@@ -0,0 +1,374 @@
+"""
+Generate report for production run
+
+NOTE - this will only work on Windows system (as pylab not installed on unix).
+
+Inputs:
+
+report_title:    title to be included in tex file
+production dirs: dictionary of production directories with a
+                 association to that simulation run, eg high tide,
+                 low tide and MSL.
+                    
+
+Outputs:
+
+* Report generated to scenario_report.tex where the scenario relates
+the name of the production directory this script is being run from.
+* figures used for report stored in the report_figure directory
+NOTE, this directory will need to be committed, as well as
+the latex files.
+
+The report structure is
+
+* Executive Summary
+* Introduction
+* Modelling Methodology
+* Tsunami scenario
+* Data sources
+* Inundation model
+* Inundation modelling results
+* Impact modelling
+* Summary
+* Acknowledgements
+* References
+* Appendix: Metadata
+* Appendix: Time series outputs
+
+Other files included in document which require manual intervention:
+
+* an abstract must be written in abstract.tex
+* an introduction must be written in introduction.tex; a basic outline and
+  some of the core inputs are already in place
+* the tsunami-genic event should be discussed in tsunami_scenario.tex
+* a discussion of the ANUGA model is required in anuga.tex
+* a computational_setup.tex file needs to be written for the particular scenario
+* the interpretation of the results needs to be written to interpretation.tex
+* maximum inundation map names need to be included in HAT_map and LAT_map etc.
+* damage modelling map names need to be included in HAT_damage and LAT_damage etc.
+* a summary must be written into summary.tex
+* metadata for the scenario data to be included in metadata.tex
+
+May, June 2006                    
+"""
+
+from os import getcwd, sep, altsep, mkdir, access, F_OK
+import project_slide
+from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file
+
+# Derive scenario name
+p = getcwd().split(sep)
+scenario = p[-1] # Last element of absolute CWD path
+scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006`
+test = scenario_name.split('_')
+if len(test) <> 1:
+    scenario_name = '%s %s' %(test[0], test[1])
+
+# Create report directory
+reportdir = getcwd()+sep+'report'+sep
+if access(reportdir,F_OK) == 0:
+    mkdir (reportdir)
+    
+# User defined inputs
+report_title = 'Tsunami inundation modelling for the NSW coastline: Generation by Submarine Mass Failures' 
+
+# WA DLI data
+production_dirs = {'20061211_071516': 'Area B - Bulli',
+                   '20061212_012705': 'Area B - Shovel',
+                   '20070322_035214': 'Area B - Yacaaba',
+                   '20070322_035135': 'Area B - Birubi',
+                   '20061211_060105': 'Area A - Bulli',
+                   '20061212_012715': 'Area A - Shovel',
+                   '20070322_035513': 'Area A - Yacaaba',
+                   '20070322_035640': 'Area A - Birubi',
+                   '20061211_073709': 'Area C - Bulli',
+                   '20061212_012802': 'Area C - Shovel',
+                   '20070331_070841': 'Area C - Yacaaba',
+                   '20070331_080432': 'Area C - Birubi',
+                   '20070322_033608': 'Area C0 - Bulli',
+                   '20070322_033716': 'Area C0 - Shovel',
+                   '20070323_012310': 'Area C0 - Yacaaba',
+                   '20070322_033350': 'Area C0 - Birubi',
+                   '20070331_080235': 'Area C2 - Bulli',
+                   '20070331_080213': 'Area C2 - Shovel',
+                   '20070401_030248': 'Area C2 - Yacaaba',
+                   '20070331_080603': 'Area C2 - Birubi',}
+
+do_timeseries = False
+
+is_parallel = False
+if is_parallel == True:
+    nodes = 8
+
+max_maps = {'Area A - Bulli': 'bulli_A_map',
+            'Area A - Shovel': 'shovel_A_map',
+            'Area A - Yacaaba': 'yacaaba_A_map',
+            'Area A - Birubi': 'birubi_A_map',
+            'Area B - Bulli': 'bulli_B_map',
+            'Area B - Shovel': 'shovel_B_map',
+            'Area B - Yacaaba': 'yacaaba_B_map',
+            'Area B - Birubi': 'birubi_B_map',
+            'Area C0 - Bulli': 'bulli_C0_map',
+            'Area C0 - Shovel': 'shovel_C0_map',
+            'Area C0 - Yacaaba': 'yacaaba_C0_map',
+            'Area C0 - Birubi': 'birubi_C0_map',
+            'Area C - Bulli': 'bulli_C_map',
+            'Area C - Shovel': 'shovel_C_map',
+            'Area C - Yacaaba': 'yacaaba_C_map',
+            'Area C - Birubi': 'birubi_C_map',
+            'Area C2 - Bulli': 'bulli_C2_map',
+            'Area C2 - Shovel': 'shovel_C2_map',
+            'Area C2 - Yacaaba': 'yacaaba_C2_map',
+            'Area C2 - Birubi': 'birubi_C2_map'}
+
+##gauge_mapA = ''
+##gauge_mapB = ''
+##gauge_mapC = ''
+
+# Create sections and graphs for each designated production directory
+latex_output = []
+report_name = 'latexoutput'
+
+if do_timeseries == True:
+    
+    if is_parallel == True:
+
+        for i in range(nodes):
+            print 'Sending node %d of %d' %(i,nodes)
+            swwfiles = {}
+            reportname = report_name + '_%s' %(i)
+            for label_id in production_dirs.keys():
+                file_loc = project_slide.outputdir + label_id + sep
+                sww_extra = '_P%s_%s' %(i,nodes)
+                swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
+                swwfiles[swwfile] = label_id
+
+                texname, elev_output = sww2timeseries(swwfiles,
+                                                      project.gauge_filename,
+                                                      production_dirs,
+                                                      report = True,
+                                                      reportname = reportname,
+                                                      plot_quantity = ['stage', 'momentum'],
+                                                      generate_fig = True,
+                                                      surface = False,
+                                                      time_min = None,
+                                                      time_max = None,
+                                                      title_on = False,
+                                                      verbose = True)
+                
+                latex_output.append(texname)
+        
+    else:
+        swwfiles = {}
+        for label_id in production_dirs.keys():
+
+            file_loc = project_slide.outputdir + label_id + sep
+            if production_dirs[label_id] == 'Area A - Bulli':
+                scenario_dir_name = 'wollongong_tsunami_scenario_2006'
+                file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep
+            if production_dirs[label_id] == 'Area C - Bulli':
+                scenario_dir_name = 'newcastle_tsunami_scenario_2006'
+                file_loc = project_slide.home+sep+project_slide.state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep+label_id+sep
+            swwfile = file_loc + project_slide.basename + '.sww'
+            swwfiles[swwfile] = label_id
+            
+        texname, elev_output = sww2timeseries(swwfiles,
+                                              'arrivaltime.csv',#project.gauge_filename,
+                                              production_dirs,
+                                              report = True,
+                                              reportname = report_name,
+                                              plot_quantity = ['stage', 'momentum'],
+                                              generate_fig = True,
+                                              surface = False,
+                                              time_min = None,
+                                              time_max = None,
+                                              title_on = False,
+                                              verbose = True)
+
+# Start report generation
+# Future: generate_report(reportdir, scenario, report_title, 
+# project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output)
+report_name = reportdir + scenario + '_report.tex'
+fid = open(report_name, 'w')
+
+s = """
+% This is based on an automatically generated file (by make_report.py).
+%
+% Manual parts are:
+% * an abstract must be written in abstract.tex
+% * an introduction must be written in introduction.tex; a basic outline and
+%   some of the core inputs are already in place
+% * outline of the modelling methodology provided in modelling_methodology.tex
+% * the tsunami-genic event should be discussed in tsunami_scenario.tex
+% * an computational_setup.tex file needs to be written for the particular scenario
+% * the interpretation of the results needs to be written to interpretation.tex
+% * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc.
+% * damage modelling maps need to be included in HAT_damage and LAT_damage etc.
+% * a summary must be written into summary.tex
+% * metadata for the scenario data to be included in metadata.tex
+
+\documentclass{article}
+
+\usepackage{ae} % or {zefonts}
+\usepackage[T1]{fontenc}
+\usepackage[ansinew]{inputenc}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{graphicx}
+\usepackage{color}
+\usepackage[colorlinks]{hyperref}
+\usepackage{lscape} %landcape pages support
+\usepackage{setspace}
+\usepackage{rotating}
+\usepackage{pdfpages}
+\include{appendix}
+\setstretch{1.25}
+\\topmargin 0pt
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\marginparwidth 0.5pt
+\\textwidth \paperwidth
+\\advance\\textwidth -2in
+\\newcommand{\degree}{\ensuremath{^\circ}}
+\\newcommand{\sech}{\operatorname{sech}}
+
+"""
+fid.write(s)
+
+s = """
+\date{\\today}
+%\\author{Geoscience Australia}
+
+\\begin{document}
+\\title{
+\\begin{figure}[hbt]
+  \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}}
+\end{figure}
+"""
+fid.write(s)
+s = '%s} '%report_title
+fid.write(s)
+s = """
+  \maketitle
+
+    \section{Executive Summary}
+    \label{sec:execsum}
+  \input{execsum}
+
+\pagebreak
+
+  \\tableofcontents
+  
+   \section{Modelling methodology}
+    \label{sec:methodology}
+    \input{modelling_methodology}
+
+  \section{Data sources}
+    \label{sec:data}
+    \input{data}
+        
+  \section{Inundation modelling results}
+     \label{sec:results}
+         
+"""
+fid.write(s)
+
+# Generate latex output for location points
+##s = '\\begin{table} \\begin{center} \n'
+##fid.write(s)
+##s = '\caption{Defined point locations for %s study area.}' %scenario_name
+##fid.write(s)
+##s = """
+##\label{table:locations}
+##\\begin{tabular}{|l|l|l|l|}\hline
+##\\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline
+##"""
+##fid.write(s)
+##
+##gauges, locations, elevation = get_gauges_from_file(project.gauge_filename)
+##
+##for name, gauges, elev in zip(locations, gauges, elevation):
+##    east = gauges[0]
+##    north = gauges[1]
+##    s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev)
+##    fid.write(s)
+##
+##s = '\\end{tabular} \n  \end{center} \n \end{table} \n \n'
+##fid.write(s)
+##
+
+##s = '\\begin{figure}[hbt] \centerline{\includegraphics[scale = 0.5]{../report_figures/%s}}' %gauge_map2
+##fid.write(s)
+##s  = """
+##\caption{Point locations used for Dampier study; surrounding the facility.
+##See Appendix \\ref{sec:timeseries} for stage and momentum results.
+##}  
+##\label{fig:points2}
+##\end{figure}
+##"""
+##fid.write(s)
+    
+s = '\input{interpretation} \n'
+fid.write(s)
+
+# Assign titles to each production section 
+# Must specify one name per section
+for i, name in enumerate(production_dirs.keys()):
+
+    s = '\input{%s} \n \clearpage \n \n' %max_maps[production_dirs[name]]
+    fid.write(s)
+
+# Closing
+
+
+s = """
+
+     \section{Summary}
+     \label{sec:summary}
+     \input{summary}
+
+     %\section{Acknowledgements}
+     %\input{acknowledgements}
+     
+    \input{references}
+
+    \\appendix
+    
+ %  \section{Metadata}
+  %   \label{sec:metadata}
+   %  \input{metadata}
+     
+\section{ANUGA modelling parameters}
+\label{sec:anugasetup}
+\input{anuga_setup}
+
+\pagebreak
+
+\section{Submarine Mass Failure Model}
+\label{sec:smfmodel}
+\input{smfmodel}
+
+\clearpage
+
+   \section{Time series}
+     \label{sec:timeseries}
+"""
+fid.write(s)
+
+##for i in range(len(latex_output)):
+##    if latex_output[i] <> '':
+##        s = '\input{%s} \n \clearpage \n \n' %latex_output[i]   
+##        fid.write(s)
+texname = 'latexoutput20061211071516'
+s = '\input{%s} \n \clearpage \n \n' %texname  
+fid.write(s)
+texname2 = 'latexoutput20061211060105'
+texname3 = 'latexoutput20061211073709'
+s = '\input{%s} \n \clearpage \n \n' %texname2
+fid.write(s)
+s = '\input{%s} \n \clearpage \n \n' %texname3
+fid.write(s)
+s="""
+\end{document}
+"""
+fid.write(s)
