-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWind_profile_8ms.py.bak
59 lines (43 loc) · 1.4 KB
/
Wind_profile_8ms.py.bak
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
import numpy as np
import os
import decimal
import pandas
from collections import OrderedDict
def write_wind(invec, ii, jj,b):
Height=(np.array([np.arange(0,181,10)],dtype=float))
if b==1:
V_ref=8
elif b==2:
V_ref=12
else:
V_ref=18
alpha=invec[0]
Beta=invec[1]
print Beta
Z_hub=90.
new_Height=(Height/Z_hub).T
Height=(np.array([np.arange(0,181,10)])).T
a=len(Height)
U=np.zeros((a,1),dtype=float)
Beta1=np.zeros((a,1),dtype=float)
for i in range(0,a):
U[i,0]= V_ref*(new_Height[i,0])**alpha
Beta1[i,0]= (Beta/63)*(Height[i,0])-90*(Beta/63)
df1= ['%.3f'% x for x in Height]
df2 = ['%.3f'% x for x in U]
df3 =['%.3f'% x for x in Beta1]
name=os.sep.join(['Row_' + str(ii)+'_BIN_'+str(b),'Turbsim_inputs', str(V_ref)+'ms_Sobol_row_' + str(ii) + '.profiles'])
with open("UsrShear_8ms.profiles",'r') as f:
get_all=f.readlines()
with open(name,'w') as f2:
for i,line in enumerate(get_all,1):
if i < 12:
f2.writelines(line)
else:
for p in range(len(df1)):
if len(str(df1[p]))<5 :
f2.write(str(df1[p]) + " " + str(df2[p]) + " " + str(df3[p]) + "\n")
else:
f2.write(str(df1[p]) + " " + str(df2[p]) + " " + str(df3[p]) + "\n")
break
f2.close()