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 pyvolution.coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn |
---|
10 | #from coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn |
---|
11 | from pylab import * |
---|
12 | #from compare_sww import gauge_locations |
---|
13 | |
---|
14 | |
---|
15 | #swwfile = project.newoutputname + '.sww' |
---|
16 | #swwfile = project.outputname |
---|
17 | swwfile_B = project.outputdir + sep + 'Buildings_3790.sww' |
---|
18 | swwfile_F = project.outputdir + sep + 'Buildings_3662.sww' |
---|
19 | #swwfile_F = project.outputdir + sep + 'friction_3135.sww' |
---|
20 | |
---|
21 | gauge_depth = Numeric.arrayrange(0, 700, 10) |
---|
22 | gauge_breadth = 100 |
---|
23 | gauge_locations = [] |
---|
24 | |
---|
25 | for GD in gauge_depth: |
---|
26 | gauge_location = [GD,gauge_breadth] |
---|
27 | gauge_locations.append(gauge_location) |
---|
28 | |
---|
29 | |
---|
30 | #Read model output |
---|
31 | quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] |
---|
32 | |
---|
33 | f_B = file_function(swwfile_B, |
---|
34 | quantities = quantities, |
---|
35 | interpolation_points = gauge_locations, |
---|
36 | verbose = True, |
---|
37 | use_cache = True) |
---|
38 | |
---|
39 | f_F = file_function(swwfile_F, |
---|
40 | quantities = quantities, |
---|
41 | interpolation_points = gauge_locations, |
---|
42 | verbose = True, |
---|
43 | use_cache = True) |
---|
44 | |
---|
45 | |
---|
46 | T = Numeric.arrayrange(0,500,20) |
---|
47 | #T = [ 20, 50, 100, 150, 200 ] |
---|
48 | |
---|
49 | for t in T: |
---|
50 | model_time = [] |
---|
51 | stages_B = [] |
---|
52 | stages_F = [] |
---|
53 | elevations = [] |
---|
54 | momenta = [] |
---|
55 | velocity = [] |
---|
56 | for i, GL in enumerate(gauge_depth): |
---|
57 | wB = f_B(t, point_id = i)[0] |
---|
58 | zB = f_B(t, point_id = i)[1] |
---|
59 | uhB = f_B(t, point_id = i)[2] |
---|
60 | vhB = f_B(t, point_id = i)[3] |
---|
61 | |
---|
62 | wF = f_F(t, point_id = i)[0] |
---|
63 | uhF = f_B(t, point_id = i)[2] |
---|
64 | vhF = f_B(t, point_id = i)[3] |
---|
65 | #m = sqrt(uh*uh + vh*vh) #Absolute momentum |
---|
66 | velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity |
---|
67 | velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity |
---|
68 | #print velB, "buiding velocity" |
---|
69 | #print velF, "friction velocity" |
---|
70 | |
---|
71 | stages_B.append(wB) |
---|
72 | stages_F.append(wF) |
---|
73 | #elevations.append(zB) #Should be constant over time |
---|
74 | #momenta.append(mB) |
---|
75 | #velocityB.append(velB) |
---|
76 | #velocityF.append(velF) |
---|
77 | |
---|
78 | #print len(stages), "stages" |
---|
79 | diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F)) |
---|
80 | #print diff, "difference" |
---|
81 | |
---|
82 | |
---|
83 | ion() |
---|
84 | hold(False) |
---|
85 | plot(gauge_depth, stages_B, '-b',gauge_depth,stages_F,'-r') |
---|
86 | title('Time_%d_ vs water depth' %t) |
---|
87 | xlabel('gauge length(m)') |
---|
88 | ylabel('water depths (m)') |
---|
89 | savefig('Comp_Time%d_B_vs_F' %t) |
---|
90 | #plot(gauge_depth, diff, 'g') |
---|
91 | #title('differences') |
---|
92 | # raw_input('Next') |
---|
93 | print "finished" |
---|
94 | |
---|
95 | |
---|