source: development/momentum_sink/PCS.py @ 2578

Last change on this file since 2578 was 2578, checked in by nicholas, 18 years ago

improved CCS.py to handle not sorted files in a folder, Sorter.py. Created some double friction and building scenario scripts.

File size: 3.2 KB
Line 
1"""Read in sww file, interpolate at specified locations and
2    Cross section at specified T
3
4"""
5from os import sep
6import Numeric
7import project
8from pyvolution.util import file_function
9from create_buildings import  WidtH
10# from run_friction import fric
11from pylab import *
12
13fric = 'Dbl'   
14#swwfile = project.newoutputname + '.sww'
15#swwfile = project.outputname
16
17#swwfile_B = project.outputdir + sep  + 'Buildings_3790.sww'
18swwfile_B = project.outputdir + sep  + 'buildings_Str_Off_BR=15_5_2287.sww'
19#swwfile_B = project.outputdir + sep  + 'friction_n=10_3135.sww'
20swwfile_F = project.outputdir + sep  + 'friction_n=Dbl_33_0.sww'
21
22# gauge_depth = Numeric.arrayrange(51, 1.5*WidtH, 25) # Random special
23gauge_depth = Numeric.arrayrange(0, 5*WidtH, 25)
24gauge_breadth = 100
25gauge_locations = []
26
27for GD in gauge_depth:
28    gauge_location = [GD,gauge_breadth]
29    gauge_locations.append(gauge_location)
30
31
32#Read model output
33quantities = ['stage', 'xmomentum', 'ymomentum']
34
35f_B = file_function(swwfile_B,
36                  quantities = quantities,
37                  interpolation_points = gauge_locations,
38                  verbose = True,
39                  use_cache = True)
40
41f_F = file_function(swwfile_F,
42                  quantities = quantities,
43                  interpolation_points = gauge_locations,
44                  verbose = True,
45                  use_cache = True)
46
47
48T = Numeric.arrayrange(0,1000,10)
49#T = [ 20, 50, 100, 150, 200 ]
50
51for t in T:
52    model_time = []
53    stages_B = []
54    stages_F = []
55    elevations = []
56    momenta = []
57    velocity = []
58    for i, GL in enumerate(gauge_depth):
59
60        # mines data from specified time values in sww file
61        wB = f_B(t, point_id = i)[0]
62        uhB = f_B(t, point_id = i)[1]
63        vhB = f_B(t, point_id = i)[2]
64
65        wF = f_F(t, point_id = i)[0]       
66        uhF = f_B(t, point_id = i)[1]
67        vhF = f_B(t, point_id = i)[2]
68        #m = sqrt(uh*uh + vh*vh)   #Absolute momentum
69        velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity
70        velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity                   
71        #print velB, "buiding velocity"
72        #print velF, "friction velocity"
73
74        stages_B.append(wB)
75        stages_F.append(wF)
76        #elevations.append(zB)  #Should be constant over time
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, stages_B, '-b',gauge_depth,stages_F,'-r')
91    title('Stage@Time_%d_ vs Gauge length (m)[red: fric, blue: buildings] ' %t)
92    xlabel('gauge length(m)')
93    ylabel('water depths (m)')
94    #savefig('Comp_Time%d_B_vs_F' %t)
95    hold(False)
96#savefig('Final_comp_n=%s' %fric)
97subplot(212)
98subplots_adjust(hspace = 0.4)
99plot(gauge_depth, diff, 'g')
100title('Final Differences in water levels')
101xlabel('gauge length(m)')
102ylabel('water differences (m)')
103savefig('Final_Water_diff_n=%s' %fric)
104print "finished"
105
106
Note: See TracBrowser for help on using the repository browser.