source: anuga_work/production/bunbury_storm_surge_2009/combine_gauges.py @ 7647

Last change on this file since 7647 was 7613, checked in by fountain, 14 years ago

Bunbury storm surge modelling

File size: 1.8 KB
Line 
1# Standard modules
2from os import sep
3import os, glob
4from os.path import join
5
6# Related major packages
7from anuga.utilities.csv_tools import merge_csv_key_values
8
9# Application specific imports
10from setup_model import project  # Definition of file names and polygons
11import csv
12directory = project.output_folder
13
14time_dir1 = '20090508_150215_run_final_0_51469_lfountai'
15time_dir2 = '20090511_161526_run_final_1.1_51469_kvanputt'
16time_dir3 = '20090511_165539_run_final_0_50863_lfountai'
17time_dir4 = '20090521_220101_run_final_1.1_50863_kvanputt'
18time_dir5 = '20090518_154710_run_final_0_50994_lfountai'
19time_dir6 = '20090519_160510_run_final_1.1_50994_lfountai'
20time_dir7 = '20090522_164526_run_final_0_51392_lfountai'
21time_dir8 = '20090522_164640_run_final_1.1_51392_lfountai'
22time_dir9 = '20090522_164948_run_final_0_51423_lfountai'
23time_dir10 = '20090522_165600_run_final_1.1_51423_lfountai'
24
25time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5,
26             time_dir6, time_dir7, time_dir8, time_dir9, time_dir10]
27
28data = 'stage'
29output_filename = 'gauges_combined_' + data + '.csv' 
30for time_dir in time_dirs:
31    print time_dir
32    folder = join(directory, time_dir)
33    output_file = join(folder, output_filename) 
34    #Looking for 'gauge_<alphabetic>.csv' filename
35    input_csv = glob.glob(folder + sep + 'gauge*.csv')
36   
37    csv_files = []
38    for infile in input_csv:
39        title = os.path.basename(infile)[:-4]
40        title = title.replace('gauge_', '')
41        if title in csv_files:
42            print 'Title (%s) already in use' % title
43            sys.exit(10)
44        csv_files.append([infile, title])
45
46   # print 'csv_files=%s' % str(csv_files)
47    merge_csv_key_values(csv_files, output_file,
48                         key_col='hours', data_col=data)
Note: See TracBrowser for help on using the repository browser.