1 | """ |
---|
2 | Read in event time series and determine max stage for Ph2 comparison |
---|
3 | Compare with Green's function (no focussing) |
---|
4 | Compare with ANUGA outputs (full model, 250m no polys, 250m all polys) |
---|
5 | Leharne Fountain and Jane Sexton, 2008 |
---|
6 | """ |
---|
7 | |
---|
8 | import project |
---|
9 | from pylab import plot, xlabel, ylabel, savefig, ion, close, axis, title, legend, grid, figure |
---|
10 | from os import sep |
---|
11 | |
---|
12 | ################################################### |
---|
13 | # Relevant definitions |
---|
14 | ################################################### |
---|
15 | |
---|
16 | def get_max_boundary_data(filename): |
---|
17 | from anuga.utilities.numerical_tools import mean |
---|
18 | fid = open(filename) |
---|
19 | lines = fid.readlines() |
---|
20 | fid.close() |
---|
21 | stage = [] |
---|
22 | for line in lines[1:]: |
---|
23 | fields = line.split(',') |
---|
24 | stage.append(float(fields[3])) |
---|
25 | return mean(stage) |
---|
26 | |
---|
27 | def get_stage_data(filename,depth,no_models): |
---|
28 | from anuga.utilities.numerical_tools import mean |
---|
29 | fid = open(filename) |
---|
30 | lines = fid.readlines() |
---|
31 | fid.close() |
---|
32 | |
---|
33 | mean_stages = zeros((len(depth),no_models), Float) |
---|
34 | max_stages = zeros((len(depth),no_models), Float) |
---|
35 | for i in range(no_models): |
---|
36 | stage5 = [] |
---|
37 | stage10 = [] |
---|
38 | stage20 = [] |
---|
39 | stage50 = [] |
---|
40 | for line in lines[1:]: |
---|
41 | fields = line.split(',') |
---|
42 | x = float(fields[0]) |
---|
43 | # based on csv file output from ArcGIS: depth, x,y, no poly, all poly, and orig |
---|
44 | y = float(fields[i+3]) |
---|
45 | if x == -depth[0]: |
---|
46 | stage5.append(y) |
---|
47 | if x == -depth[1]: |
---|
48 | stage10.append(y) |
---|
49 | if x == -depth[2]: |
---|
50 | stage20.append(y) |
---|
51 | if x == -depth[3]: |
---|
52 | stage50.append(y) |
---|
53 | |
---|
54 | mean_stages[:,i] = [mean(stage5), mean(stage10), mean(stage20), mean(stage50)] |
---|
55 | max_stages[:,i] = [max(stage5), max(stage10), max(stage20), max(stage50)] |
---|
56 | return mean_stages, max_stages |
---|
57 | |
---|
58 | ################################################### |
---|
59 | # Determine max stage at boundary points |
---|
60 | ################################################### |
---|
61 | |
---|
62 | event_number = 27283 |
---|
63 | boundary_mean = get_max_boundary_data(project.boundaries_dir+str(event_number)+sep+'max_sts_stage.csv') |
---|
64 | |
---|
65 | ################################################### |
---|
66 | # Read in max data from all models |
---|
67 | ################################################### |
---|
68 | |
---|
69 | from Numeric import zeros, Float |
---|
70 | directory = project.home+project.state+sep+project.scenario+sep+'map_work' |
---|
71 | depth = [5.0,10.,20.,50.] |
---|
72 | no_models = 3 |
---|
73 | filename = directory + sep + 'perth_ph2_compare_v5.csv' |
---|
74 | mean_stages, max_stages = get_stage_data(filename, depth, no_models) |
---|
75 | |
---|
76 | ################################################### |
---|
77 | # Compare with Green's function and plot |
---|
78 | ################################################### |
---|
79 | |
---|
80 | from anuga.abstract_2d_finite_volumes.util import greens_law |
---|
81 | from Numeric import arange |
---|
82 | d1 = 100. |
---|
83 | d2 = arange(d1,1,-0.1) |
---|
84 | h1 = boundary_mean |
---|
85 | green = [] |
---|
86 | for d in d2: |
---|
87 | h2 = greens_law(d1,d,h1) |
---|
88 | green.append(h2) |
---|
89 | |
---|
90 | ion() |
---|
91 | figure(1) |
---|
92 | plot(depth,mean_stages[:,2],'>g',d2,green,'-g') |
---|
93 | xlabel('depth (m)') |
---|
94 | ylabel('stage (m)') |
---|
95 | title('ANUGA outputs (average stage) versus Green\'s approximation \n \ |
---|
96 | for event 27283 at Perth') |
---|
97 | legend(['original','Green\'s law']) |
---|
98 | #axis([5,105,min(min(stages))*0.9,max(max(stages))*1.1]) |
---|
99 | grid(True) |
---|
100 | figname = 'ph2compare_perth_mean_ORIG_' + str(event_number) + '_mean' |
---|
101 | savefig(figname) |
---|
102 | |
---|
103 | figure(2) |
---|
104 | plot(depth,mean_stages[:,1],'+r',depth,mean_stages[:,2],'>g',d2,green,'-g') |
---|
105 | xlabel('depth (m)') |
---|
106 | ylabel('stage (m)') |
---|
107 | title('ANUGA outputs (average stage) versus Green\'s approximation \n \ |
---|
108 | for event 27283 at Perth') |
---|
109 | legend(['250m poly','original','Green\'s law']) |
---|
110 | #axis([5,105,min(min(stages))*0.9,max(max(stages))*1.1]) |
---|
111 | grid(True) |
---|
112 | figname = 'ph2compare_perth_mean_250AP_' + str(event_number) + '_mean' |
---|
113 | savefig(figname) |
---|
114 | |
---|
115 | figure(3) |
---|
116 | plot(depth,mean_stages[:,0],'ob',depth,mean_stages[:,1],'+r',depth,mean_stages[:,2],'>g',d2,green,'-g') |
---|
117 | xlabel('depth (m)') |
---|
118 | ylabel('stage (m)') |
---|
119 | title('ANUGA outputs (average stage) versus Green\'s approximation \n \ |
---|
120 | for event 27283 at Perth') |
---|
121 | legend(['250m no poly','250m poly','original','Green\'s law']) |
---|
122 | #axis([5,105,min(min(stages))*0.9,max(max(stages))*1.1]) |
---|
123 | grid(True) |
---|
124 | figname = 'ph2compare_perth_mean_ALL_' + str(event_number) + '_mean' |
---|
125 | savefig(figname) |
---|
126 | |
---|
127 | figure(4) |
---|
128 | plot(depth,max_stages[:,0],'ob',depth,max_stages[:,1],'+r',depth,max_stages[:,2],'>g',d2,green,'-g') |
---|
129 | xlabel('depth (m)') |
---|
130 | ylabel('stage (m)') |
---|
131 | title('ANUGA outputs (max stage) versus Green\'s approximation \n \ |
---|
132 | for event 27283 at Perth') |
---|
133 | legend(['250m no poly','250m poly','original','Green\'s law']) |
---|
134 | #axis([5,105,min(min(stages))*0.9,max(max(stages))*1.1]) |
---|
135 | grid(True) |
---|
136 | figname = 'ph2compare_perth_max_ALL_' + str(event_number) + '_mean' |
---|
137 | savefig(figname) |
---|
138 | close('all') |
---|
139 | |
---|