-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverbank.py
334 lines (238 loc) · 8.44 KB
/
Overbank.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#%%
import math
def overbank(xcoordinates, ycoordinates, width, increment, link):
xlink = link
inc = increment
npts = len(xcoordinates)
angle = [0]
xsec_angle = [0]
ave_angle = [0]
ave_profile = [0]
quad_flag = [0]
ave_quad_flag = [0]
lob_dx = []
lob_dy = []
rob_dx = []
rob_dy = []
overbank_section = []
temp1 = []
for i in range(0,npts-1):
dx = float(xcoordinates[i+1]) - float(xcoordinates[i])
dy = float(ycoordinates[i+1]) - float(ycoordinates[i])
if (dx == 0.0):
dx = 0.0001
if (dy == 0.0):
dy = 0.0001
angle1 = math.degrees(math.atan(dy/dx))
# Quadrant I - 0 degrees to 90 degrees
if (dx > 0.0 and dy > 0.0):
ave_angle1 = angle1 + 90
angle1 = angle1
xsec_angle1 = 180 - ave_angle1
quad_flag1 = 1
# Quadrant II - 270 degress to 360 degress
if (dx > 0.0 and dy < 0.0):
angle1 = 360 + angle1
ave_angle1 = angle1 + 90 - 360
xsec_angle1 = ave_angle1
quad_flag1 = 2
# Quadrant III - 180 degrees to 270 degrees
if (dx < 0.0 and dy < 0.0):
angle1 = 180 + angle1
ave_angle1 = angle1 + 90
xsec_angle1 = 360 - ave_angle1
quad_flag1 = 3
# Quadrant IV - 90 degrees to 180 degrees
if (dx < 0.0 and dy > 0.0):
angle1 = 180 - abs(angle1)
ave_angle1 = angle1 + 90
xsec_angle1 = ave_angle1 - 180
quad_flag1 = 4
angle.append(angle1)
ave_angle.append(ave_angle1)
xsec_angle.append(xsec_angle1)
quad_flag.append(quad_flag1)
for i in range(0,npts):
if (i == 0):
if (quad_flag[1] == 1):
l_x = -1
l_y = 1
if (quad_flag[1] == 2):
l_x = 1
l_y = 1
if (quad_flag[1] == 3):
l_x = 1
l_y = -1
if (quad_flag[1] == 4):
l_x = -1
l_y = -1
l_x = l_x * math.cos(xsec_angle[1]*3.1415927/180)*width
l_y = l_y * math.sin(xsec_angle[1]*3.1415927/180)*width
r_x = -1 * l_x
r_y = -1 * l_y
lob_dx.append(l_x)
lob_dy.append(l_y)
rob_dx.append(r_x)
rob_dy.append(r_y)
if (i == npts -1):
if (quad_flag[i] == 1):
l_x = -1
l_y = 1
if (quad_flag[i] == 2):
l_x = 1
l_y = 1
if (quad_flag[i] == 3):
l_x = 1
l_y = -1
if (quad_flag[i] == 4):
l_x = -1
l_y = -1
l_x = l_x * math.cos(xsec_angle[npts-1]*3.1415927/180)*width
l_y = l_y * math.sin(xsec_angle[npts-1]*3.1415927/180)*width
r_x = -1 * l_x
r_y = -1 * l_y
lob_dx.append(l_x)
lob_dy.append(l_y)
rob_dx.append(r_x)
rob_dy.append(r_y)
if (i > 0 and i < npts -1):
if (quad_flag[i] == 1):
l_x = -1
l_y = 1
if (quad_flag[i] == 2):
l_x = 1
l_y = 1
if (quad_flag[i] == 3):
l_x = 1
l_y = -1
if (quad_flag[i] == 4):
l_x = -1
l_y = -1
l_x = l_x * math.cos(xsec_angle[i]*3.1415927/180)*width
l_y = l_y * math.sin(xsec_angle[i]*3.1415927/180)*width
r_x = -1 * l_x
r_y = -1 * l_y
lob_dx.append(l_x)
lob_dy.append(l_y)
rob_dx.append(r_x)
rob_dy.append(r_y)
l_x = float(xcoordinates[i]) + l_x
l_y = float(ycoordinates[i]) + l_y
r_x = float(xcoordinates[i]) + r_x
r_y = float(ycoordinates[i]) + r_y
# This Section averages the Overbank Cross Section Profile from U/S to D/S
for i in range (0, npts):
if (i == 0):
ave_angle[i] = ave_angle[1]
xsec_angle[i] = xsec_angle[1]
ave_quad_flag[i] = quad_flag[1]
if (ave_quad_flag[i] == 1):
l_x = -1
l_y = 1
if (ave_quad_flag[i] == 2):
l_x = 1
l_y = 1
if (ave_quad_flag[i] == 3):
l_x = 1
l_y = -1
if (ave_quad_flag[i] == 4):
l_x = -1
l_y = -1
if(i == npts-1):
ave_angle[i] = ave_angle[i]
xsec_angle[i] = xsec_angle[i]
ave_quad_flag.append(quad_flag[i])
if (ave_quad_flag[i] == 1):
l_x = -1
l_y = 1
if (ave_quad_flag[i] == 2):
l_x = 1
l_y = 1
if (ave_quad_flag[i] == 3):
l_x = 1
l_y = -1
if (ave_quad_flag[i] == 4):
l_x = -1
l_y = -1
if (i > 0 and i < npts-1):
ave_angle[i] = (ave_angle[i] + ave_angle[i+1])/2
if (ave_angle[i] == 0.0):
ave_angle[i] == 0.0001
if (ave_angle[i] == 90.0):
ave_angle[i] = 90.0001
if (ave_angle[i] == 180.0):
ave_angle[i] == 180.0001
if (ave_angle[i] == 270.0):
ave_angle[i] == 270.0001
if (ave_angle[i] == 360.0):
ave_angle[i] == 0.0001
if ((ave_angle[i] - 90) > 0):
ave_profile.append(ave_angle[i] - 90)
else:
ave_profile.append(360 + (ave_angle[i] - 90))
if (ave_profile[i] >0.0 and ave_profile[i]<= 90.0):
ave_quad_flag.append(1)
xsec_angle[i] = 180 - ave_angle[i]
l_x = -1
l_y = 1
if (ave_profile[i] >270.0 and ave_profile[i]<= 360.0):
ave_quad_flag.append(2)
xsec_angle[i] = ave_angle[i]
l_x = 1
l_y = 1
if (ave_profile[i] >180.0 and ave_profile[i]<= 270.0):
ave_quad_flag.append(3)
xsec_angle[i] = 360 - ave_angle[i]
l_x = 1
l_y = -1
if (ave_profile[i] >90.0 and ave_profile[i]<= 180.0):
ave_quad_flag.append(4)
xsec_angle[i] = ave_angle[i] - 180
l_x = -1
l_y = -1
l_x = l_x * math.cos(xsec_angle[i]*3.1415927/180)*width
l_y = l_y * math.sin(xsec_angle[i]*3.1415927/180)*width
r_x = -1 * l_x
r_y = -1 * l_y
if (i == npts-1):
dx1 = float((xcoordinates[i-1] - xcoordinates[i]))
dy1 = float((ycoordinates[i-1] - ycoordinates[i]))
dx1 = dx1 + 0.0001
slope = dy1/dx1
# Moving the last overbank cross section back by a specified distance
move = 0.1 * dx1
x = xcoordinates[i] + move
y = ycoordinates[i] + slope * (x-xcoordinates[i])
l_x = x + l_x
l_y = y + l_y
r_x = x + r_x
r_y = y + r_y
else:
x = xcoordinates[i]
y = ycoordinates[i]
l_x = x + l_x
l_y = y + l_y
r_x = x + r_x
r_y = y + r_y
# Computing the Incremental Points for each Overbank Cross Section
# Left Overbank Computations
temp1 = [(l_x, l_y)]
slope = (y - l_y)/(x - l_x)
num_inc = int(width / inc)
dx1 = (x - l_x)/num_inc
for i in range(1, num_inc):
x1 = l_x + i * dx1
y1 = l_y + slope * (x1 - l_x)
x_y = (x1, y1)
temp1.append(x_y)
# Right Overbank Computations
slope = (r_y - y)/(r_x - x)
dx1 = (r_x - x)/num_inc
for i in range(1, num_inc):
x1 = x + i * dx1
y1 = y + slope * (x1 - x)
x_y = (x1, y1)
temp1.append(x_y)
overbank_section.append(temp1)
return overbank_section
#%%