source: development/momentum_sink/PCS.py @ 2878

Last change on this file since 2878 was 2664, checked in by nicholas, 19 years ago

CCS.py still produces sudden jumps in friction values, 2nd normal test or implementation of it needs to be revised.

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_half_Off_D=6.9_1116.sww'
19#swwfile_F = project.outputdir + sep  + 'buildings_Str_half_Off_D=6.89_1116.sww'
20#swwfile_B = project.outputdir + sep  + 'friction_n=6_3135.sww'
21swwfile_F = project.outputdir + sep  + 'friction_n=7_3135.sww'
22
23# gauge_depth = Numeric.arrayrange(51, 1.5*WidtH, 25) # Random special
24gauge_depth = Numeric.arrayrange(0, 5*WidtH, 25)
25gauge_breadth = 100
26gauge_locations = []
27
28for GD in gauge_depth:
29    gauge_location = [GD,gauge_breadth]
30    gauge_locations.append(gauge_location)
31
32
33#Read model output
34quantities = ['stage', 'xmomentum', 'ymomentum']
35
36f_B = file_function(swwfile_B,
37                  quantities = quantities,
38                  interpolation_points = gauge_locations,
39                  verbose = True,
40                  use_cache = True)
41
42f_F = file_function(swwfile_F,
43                  quantities = quantities,
44                  interpolation_points = gauge_locations,
45                  verbose = True,
46                  use_cache = True)
47
48
49T = Numeric.arrayrange(700,1000,10)
50#T = [ 20, 50, 100, 150, 200 ]
51
52for t in T:
53    model_time = []
54    stages_B = []
55    stages_F = []
56    elevations = []
57    momenta = []
58    velocity = []
59    for i, GL in enumerate(gauge_depth):
60
61        # mines 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, "buiding velocity"
73        #print velF, "friction velocity"
74
75        stages_B.append(wB)
76        stages_F.append(wF)
77        #elevations.append(zB)  #Should be constant over time
78        #momenta.append(mB)
79        #velocityB.append(velB)
80        #velocityF.append(velF)
81       
82    #print len(stages), "stages"
83    diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F))
84    #print diff, "difference"
85
86
87    ion()
88    hold(True)
89    subplot(211)
90   
91    plot(gauge_depth, stages_B, '-b',gauge_depth,stages_F,'-r')
92    title('Stage@Time_%d_ vs Gauge length (m)[red: fric, blue: buildings] ' %t)
93    xlabel('gauge length(m)')
94    ylabel('water depths (m)')
95    #savefig('Comp_Time%d_B_vs_F' %t)
96    hold(False)
97#savefig('Final_comp_n=%s' %fric)
98subplot(212)
99subplots_adjust(hspace = 0.4)
100plot(gauge_depth, diff, 'g')
101title('Final Differences in water levels')
102xlabel('gauge length(m)')
103ylabel('water differences (m)')
104savefig('Final_Water_diff_n=%s' %fric)
105print "finished"
106
107
Note: See TracBrowser for help on using the repository browser.