1 | # Standard modules |
---|
2 | from os import sep |
---|
3 | import os, glob |
---|
4 | from os.path import join |
---|
5 | |
---|
6 | # Related major packages |
---|
7 | from anuga.utilities.csv_tools import merge_csv_key_values |
---|
8 | |
---|
9 | # Application specific imports |
---|
10 | from setup_model import project # Definition of file names and polygons |
---|
11 | import csv |
---|
12 | directory = project.output_folder |
---|
13 | |
---|
14 | time_dir1 = 'Event1_MSL' |
---|
15 | time_dir2 = 'Event2_MSL' |
---|
16 | time_dir3 = '20090714_161944_run_final_0.8_58280_None_kvanputt' |
---|
17 | time_dir4 = '20090714_161740_run_final_0.8_58260_None_kvanputt' |
---|
18 | time_dir5 = '20090619_165107_run_final_0_58260_None_kvanputt' |
---|
19 | time_dir6 = '20090619_165136_run_final_0.8_58260_None_kvanputt' |
---|
20 | |
---|
21 | time_dirs = [time_dir1, time_dir2] #, time_dir3, time_dir4] |
---|
22 | |
---|
23 | data = 'stage' |
---|
24 | output_filename = 'gauges_combined_' + data + '.csv' |
---|
25 | for time_dir in time_dirs: |
---|
26 | print time_dir |
---|
27 | folder = join(directory, time_dir) |
---|
28 | output_file = join(folder, output_filename) |
---|
29 | #Looking for 'gauge_<alphabetic>.csv' filename |
---|
30 | input_csv = glob.glob(folder + sep + 'gauge_[A-Za-z]*.csv') |
---|
31 | |
---|
32 | csv_files = [] |
---|
33 | for infile in input_csv: |
---|
34 | title = os.path.basename(infile)[:-4] |
---|
35 | title = title.replace('gauge_', '') |
---|
36 | if title in csv_files: |
---|
37 | print 'Title (%s) already in use' % title |
---|
38 | sys.exit(10) |
---|
39 | csv_files.append([infile, title]) |
---|
40 | |
---|
41 | # print 'csv_files=%s' % str(csv_files) |
---|
42 | merge_csv_key_values(csv_files, output_file, |
---|
43 | key_col='hours', data_col=data) |
---|