[2927] | 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 WidtH |
---|
| 10 | # from run_friction import fric |
---|
| 11 | from pylab import * |
---|
| 12 | |
---|
| 13 | fric = 33 |
---|
| 14 | #swwfile = project.newoutputname + '.sww' |
---|
| 15 | #swwfile = project.outputname |
---|
| 16 | |
---|
| 17 | #swwfile_B = project.outputdir + sep + 'Buildings_3790.sww' |
---|
| 18 | swwfile_B = project.outputdir + sep + 'buildings_BR=17_1106.sww' |
---|
| 19 | #swwfile_B = project.outputdir + sep + 'friction_n=10_3135.sww' |
---|
| 20 | swwfile_F = project.outputdir + sep + 'friction_n=Dbl_12_25.sww' |
---|
| 21 | |
---|
| 22 | gauge_depth = Numeric.arrayrange(41.5, 5*WidtH, 25) # Random special |
---|
| 23 | #gauge_depth = Numeric.arrayrange(0, 1.5*WidtH, 25) |
---|
| 24 | gauge_breadth = 100 |
---|
| 25 | gauge_locations = [] |
---|
| 26 | |
---|
| 27 | for GD in gauge_depth: |
---|
| 28 | gauge_location = [GD,gauge_breadth] |
---|
| 29 | gauge_locations.append(gauge_location) |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | #Read model output |
---|
| 33 | quantities = ['stage', 'xmomentum', 'ymomentum'] |
---|
| 34 | |
---|
| 35 | f_B = file_function(swwfile_B, |
---|
| 36 | quantities = quantities, |
---|
| 37 | interpolation_points = gauge_locations, |
---|
| 38 | verbose = True, |
---|
| 39 | use_cache = True) |
---|
| 40 | |
---|
| 41 | f_F = file_function(swwfile_F, |
---|
| 42 | quantities = quantities, |
---|
| 43 | interpolation_points = gauge_locations, |
---|
| 44 | verbose = True, |
---|
| 45 | use_cache = True) |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | T = Numeric.arrayrange(700,1000,10) |
---|
| 49 | #T = [ 20, 50, 100, 150, 200 ] |
---|
| 50 | |
---|
| 51 | for t in T: |
---|
| 52 | model_time = [] |
---|
| 53 | stages_B = [] |
---|
| 54 | stages_F = [] |
---|
| 55 | elevations = [] |
---|
| 56 | momenta = [] |
---|
| 57 | velocityB = [] |
---|
| 58 | velocityF=[] |
---|
| 59 | for i, GL in enumerate(gauge_depth): |
---|
| 60 | |
---|
| 61 | # collects data from specified time values in sww file |
---|
| 62 | wB = f_B(t, point_id = i)[0] |
---|
| 63 | uhB = f_B(t, point_id = i)[1] |
---|
| 64 | vhB = f_B(t, point_id = i)[2] |
---|
| 65 | |
---|
| 66 | wF = f_F(t, point_id = i)[0] |
---|
| 67 | uhF = f_B(t, point_id = i)[1] |
---|
| 68 | vhF = f_B(t, point_id = i)[2] |
---|
| 69 | #m = sqrt(uh*uh + vh*vh) #Absolute momentum |
---|
| 70 | velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity |
---|
| 71 | velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity |
---|
| 72 | #print velB, "building velocity" |
---|
| 73 | #print velF, "friction velocity" |
---|
| 74 | |
---|
| 75 | stages_B.append(wB) |
---|
| 76 | stages_F.append(wF) |
---|
| 77 | #momenta.append(mB) |
---|
| 78 | velocityB.append(velB) |
---|
| 79 | velocityF.append(velF) |
---|
| 80 | |
---|
| 81 | #print len(stages), "stages" |
---|
| 82 | diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F)) |
---|
| 83 | #print diff, "difference" |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | ion() |
---|
| 87 | hold(True) |
---|
| 88 | subplot(211) |
---|
| 89 | |
---|
| 90 | plot(gauge_depth, velocityB, '-b',gauge_depth,velocityF,'-r') |
---|
| 91 | title('Velocity_%d_ vs gauge length (red: fric, blue: buildings)' %t) |
---|
| 92 | xlabel('gauge length(m)') |
---|
| 93 | ylabel('water velocities (m/s)') |
---|
| 94 | #savefig('Comp_Time%d_B_vs_F' %t) |
---|
| 95 | hold(False) |
---|
| 96 | #savefig('Final_comp_n=%s' %fric) |
---|
| 97 | subplot(212) |
---|
| 98 | subplots_adjust(hspace = 0.4) |
---|
| 99 | plot(gauge_depth, diff, 'g') |
---|
| 100 | title('Final Differences in water levels') |
---|
| 101 | xlabel('gauge length(m)') |
---|
| 102 | ylabel('water differences (m)') |
---|
| 103 | savefig('Final_Water_velocities_n=%s' %fric) |
---|
| 104 | print "finished" |
---|
| 105 | |
---|
| 106 | |
---|