1 | |
---|
2 | |
---|
3 | from os import sep, getcwd, access, F_OK, mkdir, getenv |
---|
4 | from anuga.abstract_2d_finite_volumes.util import get_data_from_file |
---|
5 | import os |
---|
6 | from Numeric import zeros, array, allclose |
---|
7 | |
---|
8 | #makes the csv files from the evolved model |
---|
9 | |
---|
10 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
11 | #user = get_user_name() |
---|
12 | data = 'data' |
---|
13 | state = 'western_australia' |
---|
14 | scenario_name = 'dampier' |
---|
15 | scenario = 'dampier_tsunami_scenario_2006' |
---|
16 | #scenario = 'test_dampier' |
---|
17 | an = 'anuga' |
---|
18 | bo = 'boundaries' |
---|
19 | |
---|
20 | #run_time = '20070305_055256_run' |
---|
21 | #run_time = '20070305_134855_run' |
---|
22 | run_time = '20070321_164505_run' |
---|
23 | |
---|
24 | topo = 'topographies' |
---|
25 | out = 'outputs' |
---|
26 | urs = 'urs' |
---|
27 | gridded = '1_10000' |
---|
28 | |
---|
29 | gauge_boundary_filename = 'gauges_time_series_first.csv' |
---|
30 | gauge_evolved_filename = 'gauges_time_series_first.csv' |
---|
31 | |
---|
32 | boundary_dir_filename = os.path.join(home,data,state,scenario,an,bo,gauge_boundary_filename) |
---|
33 | |
---|
34 | evolved_dir_filename= os.path.join(home,data,state,scenario,an,out,run_time,gauge_evolved_filename) |
---|
35 | |
---|
36 | |
---|
37 | print'evolved_dir_filename',evolved_dir_filename |
---|
38 | e_time, e_stage, e_momentum, e_speed, e_elevation = get_data_from_file(evolved_dir_filename) |
---|
39 | |
---|
40 | print'boundary_dir_filename',boundary_dir_filename |
---|
41 | b_time, b_stage, b_momentum, b_speed, b_elevation = get_data_from_file(boundary_dir_filename) |
---|
42 | |
---|
43 | |
---|
44 | # compares the 2 models |
---|
45 | j=0 |
---|
46 | b_sample = [] |
---|
47 | for i in range(len(b_time)): |
---|
48 | if j<(len(e_time)) and b_time[i] == e_time[j]: |
---|
49 | b_sample.append(float(b_stage[i])) |
---|
50 | print 'time e equal b:', b_time[i], b_stage[i],i, j, b_sample[j], e_stage[j],(len(e_time)-1) |
---|
51 | j = j +1 |
---|
52 | |
---|
53 | |
---|
54 | assert allclose (b_sample, e_stage, 2, 0.1) |
---|
55 | print "test successful" |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|