1 | """Read in sww file, interpolate at specified locations and |
---|
2 | Cross section at specified T |
---|
3 | |
---|
4 | """ |
---|
5 | from os import sep |
---|
6 | import Numeric |
---|
7 | import project |
---|
8 | from pyvolution.util import file_function |
---|
9 | from create_buildings import porosity, WidtH |
---|
10 | # from run_friction import fric |
---|
11 | from pylab import * |
---|
12 | |
---|
13 | |
---|
14 | swwfile_B = project.outputdir + sep + 'friction_n=10_3135.sww' |
---|
15 | swwfile_F = project.outputdir + sep + 'friction_n=20_3135.sww' |
---|
16 | |
---|
17 | gauge_depth = Numeric.arrayrange(0, 2.5*WidtH, 5) |
---|
18 | gauge_breadth = 100 |
---|
19 | gauge_locations = [] |
---|
20 | |
---|
21 | for GD in gauge_depth: |
---|
22 | gauge_location = [GD,gauge_breadth] |
---|
23 | gauge_locations.append(gauge_location) |
---|
24 | |
---|
25 | |
---|
26 | #Read model output |
---|
27 | quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] |
---|
28 | |
---|
29 | f_B = file_function(swwfile_B, |
---|
30 | quantities = quantities, |
---|
31 | interpolation_points = gauge_locations, |
---|
32 | verbose = True, |
---|
33 | use_cache = True) |
---|
34 | |
---|
35 | f_F = file_function(swwfile_F, |
---|
36 | quantities = quantities, |
---|
37 | interpolation_points = gauge_locations, |
---|
38 | verbose = True, |
---|
39 | use_cache = True) |
---|
40 | |
---|
41 | |
---|
42 | T = Numeric.arrayrange(0,500,20) |
---|
43 | #T = [ 20, 50, 100, 150, 200 ] |
---|
44 | |
---|
45 | for t in T: |
---|
46 | model_time = [] |
---|
47 | stages_B = [] |
---|
48 | stages_F = [] |
---|
49 | elevations = [] |
---|
50 | momenta = [] |
---|
51 | velocity = [] |
---|
52 | for i, GL in enumerate(gauge_depth): |
---|
53 | |
---|
54 | # mines data from specified time values in sww file |
---|
55 | wB = f_B(t, point_id = i)[0] |
---|
56 | zB = f_B(t, point_id = i)[1] |
---|
57 | uhB = f_B(t, point_id = i)[2] |
---|
58 | vhB = f_B(t, point_id = i)[3] |
---|
59 | |
---|
60 | wF = f_F(t, point_id = i)[0] |
---|
61 | uhF = f_B(t, point_id = i)[2] |
---|
62 | vhF = f_B(t, point_id = i)[3] |
---|
63 | #m = sqrt(uh*uh + vh*vh) #Absolute momentum |
---|
64 | velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity |
---|
65 | velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity |
---|
66 | #print velB, "buiding velocity" |
---|
67 | #print velF, "friction velocity" |
---|
68 | |
---|
69 | stages_B.append(wB) |
---|
70 | stages_F.append(wF) |
---|
71 | #elevations.append(zB) #Should be constant over time |
---|
72 | #momenta.append(mB) |
---|
73 | #velocityB.append(velB) |
---|
74 | #velocityF.append(velF) |
---|
75 | |
---|
76 | #print len(stages), "stages" |
---|
77 | diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F)) |
---|
78 | #print diff, "difference" |
---|
79 | |
---|
80 | |
---|
81 | ion() |
---|
82 | hold(True) |
---|
83 | subplot(211) |
---|
84 | |
---|
85 | plot(gauge_depth, stages_B, '-b',gauge_depth,stages_F,'-r') |
---|
86 | title('Time_%d_ vs water depth (n=%f, BP=%f)' %(t, fric, porosity)) |
---|
87 | xlabel('gauge length(m)') |
---|
88 | ylabel('water depths (m)') |
---|
89 | #savefig('Comp_Time%d_B_vs_F' %t) |
---|
90 | hold(False) |
---|
91 | #savefig('Final_comp_n=%s' %fric) |
---|
92 | subplot(212) |
---|
93 | subplots_adjust(hspace = 0.4) |
---|
94 | plot(gauge_depth, diff, 'g') |
---|
95 | title('Final Differences in water levels') |
---|
96 | xlabel('gauge length(m)') |
---|
97 | ylabel('water differences (m)') |
---|
98 | savefig('Final_Water_diff_n=%s' %fric) |
---|
99 | print "finished" |
---|
100 | |
---|
101 | |
---|