forked from ZeitM/MAZeitler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlphaCorr.py
140 lines (95 loc) · 2.92 KB
/
AlphaCorr.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
def isfloat(num):
try:
float(num)
return True
except ValueError:
return False
with open ("C:/Uni/Masterarbeit/TestAlphaCorr/cellTypes", "r") as fp:
HoleCells=[]
startIndex=0
lineIndex=0
count=0
for line in fp:
if "boundary" in line:
break
if line[0]=="0" or line[0]=="1" or line[0]=="2":
count+=1
if startIndex==0:
startIndex=lineIndex
if line[0]=="2":
HoleCells.append(lineIndex-startIndex)
lineIndex+=1
print(len(HoleCells))
print(count)
newAlpha=open ("C:/Uni/Masterarbeit/TestAlphaCorr/newAlpha.water", "w")
with open ("C:/Uni/Masterarbeit/TestAlphaCorr/alpha.water", "r") as fp:
corrLoop=True
i=0
startIndexWater=0
lineIndexWater=0
countWater=0
for line in fp:
if "boundary" in line:
corrLoop=False
if isfloat(line) and corrLoop==True:
if float(line)<=2:
countWater+=1
if startIndexWater==0:
startIndexWater=lineIndexWater
if HoleCells[i]==lineIndexWater-startIndexWater:
newAlpha.write("0")
newAlpha.write("\n")
if i<len(HoleCells)-1:
i+=1
else:
newAlpha.write(line)
lineIndexWater+=1
print(countWater)
newp=open ("C:/Uni/Masterarbeit/TestAlphaCorr/newP", "w")
with open ("C:/Uni/Masterarbeit/TestAlphaCorr/p", "r") as fp:
corrLoop=True
i=0
startIndexp=0
lineIndexp=0
countp=0
for line in fp:
if "boundary" in line:
corrLoop=False
if isfloat(line) and corrLoop==True:
if float(line)<=2:
countp+=1
if startIndexp==0:
startIndexp=lineIndexp
if HoleCells[i]==lineIndexp-startIndexp:
newP.write("0")
newP.write("\n")
if i<len(HoleCells)-1:
i+=1
else:
newP.write(line)
lineIndexp+=1
print(countp)
newU=open ("C:/Uni/Masterarbeit/TestAlphaCorr/newU", "w")
with open ("C:/Uni/Masterarbeit/TestAlphaCorr/U", "r") as fp:
corrLoop=True
i=0
startIndexU=0
lineIndexU=0
countU=0
for line in fp:
if "boundary" in line:
corrLoop=False
if isfloat(line) and corrLoop==True:
if float(line)<=2:
countU+=1
if startIndexU==0:
startIndexU=lineIndexU
if HoleCells[i]==lineIndexU-startIndexU:
newU.write("0")
newU.write("\n")
if i<len(HoleCells)-1:
i+=1
else:
newU.write(line)
lineIndexU+=1
print(countU)