-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRyy.py
More file actions
51 lines (41 loc) · 2.26 KB
/
Copy pathRyy.py
File metadata and controls
51 lines (41 loc) · 2.26 KB
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
import pandas as pd
import matplotlib.pyplot as plt
import scipy
import numpy as np
from scipy import integrate
from .uniqueFinder import uniqueFinder
def Ryy(data):
data = data.copy()
data = data[data['DisplacementLDA [V]'] != 0.00]
data.reset_index(drop=True, inplace=True)
data = data.sort_values('DisplacementLDA [V]').reset_index(drop=True)
data = uniqueFinder(data)
data['depth[cm]'] = data['uniqueDisplacement'].groupby(data['uniqueDisplacement']).transform(lambda x:np.round(-2.4953*x+25.753,2))
## Velocity components calcuation
data['U'] = data['Vel1 [V]'].groupby(data['depth[cm]']).transform(lambda x: 0.096*(data['Vel2 [V]']-x))
data['V'] = data['Vel1 [V]'].groupby(data['depth[cm]']).transform(lambda x: 0.096*(x+data['Vel2 [V]']))
## Velocity fluctuation calcuation
data['uprime'] = data['U'].groupby(data['depth[cm]']).transform(lambda x: x - x.mean())
data['vprime'] = data['V'].groupby(data['depth[cm]']).transform(lambda x: x - x.mean())
data['vv_prime'] = data['vprime']*data['vprime'] ## Stress calculation
#waterDepth = data['depth[cm]'].groupby(data['depth[cm]']).mean().iloc[-1] ## water depth
'''
To calculate the average velocity
'''
totalDepth = data['depth[cm]'].groupby(data['depth[cm]']).mean().iloc[-1] - data['depth[cm]'].groupby(data['depth[cm]']).mean().iloc[0]
u_avg = scipy.integrate.simps(np.abs(data['U'].groupby(data['depth[cm]']).mean()), data['depth[cm]'].groupby(data['depth[cm]']).mean()) / totalDepth
'''
To calculate friction velocity
'''
upstreamWL = np.mean(38.01-3.76*data['WaterLevel1 [v]'])
#print('upStreamWL', upstreamWL)
downstreamWL = np.mean(36.42-3.8*data['WaterLevel3 [V]'])
#print('downStreamWL', downstreamWL)
diffWL = np.abs(upstreamWL - downstreamWL)
waterDepth = (upstreamWL + downstreamWL)/2
dx = 6 # horizontal length between two water levels
dHdx = (diffWL/100)/dx # energy slope : water level is in centimeter, therefore need to change in meter
#print('energy gradient', dHdx)
R = (waterDepth/100 * 0.4)/(2*waterDepth/100 + 0.04) # hydraulic radius R = Area/Perimeter
Ustar = np.sqrt(9.81*(waterDepth/100)*dHdx)
return data['vv_prime'].groupby(data['depth[cm]']).mean(), waterDepth, u_avg