-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTKE.py
More file actions
40 lines (32 loc) · 1.65 KB
/
Copy pathTKE.py
File metadata and controls
40 lines (32 loc) · 1.65 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
import pandas as pd
import matplotlib.pyplot as plt
import scipy
import numpy as np
from scipy import integrate
from .uniqueFinder import uniqueFinder
def TKE(data):
'''
This function is to calculate turbulent kinetic energy (TKE).
'''
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['uu_prime'] = data['uprime']*data['uprime'] ## u'u'
data['vv_prime'] = data['vprime']*data['vprime'] ## v'v'
TKE = 0.5*(data['uu_prime'].groupby(data['depth[cm]']).mean()+data['vv_prime'].groupby(data['depth[cm]']).mean()) ### TKE = 1/2*(u'u'+v'v')
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
return TKE, upstreamWL