-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.py
43 lines (38 loc) · 1.08 KB
/
Helpers.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
import math
import SpacePoint
import Globals
def chi2(pointA, pointB):
xResidual = math.pow(getattr(pointA, "x") - getattr(pointB, "y"),2)
yResidual = math.pow(getattr(pointA, "y") - getattr(pointB, "y"),2)
residual = math.sqrt(xResidual + yResidual)
return residual
def findDigitNo(value):
digitNo = int(value/Globals.CHANNELWIDTH)
return digitNo
def findCompactionDivision(value, center):
digitGroup = 0
difference = value - center
for group in range(100,1,-1):
#print group
groupSum = sumLower(group-1, center)
#print groupSum, int(math.fabs(difference))
if (math.fabs(difference) == 1):
digitGroup = (1)*(difference/math.fabs(difference))
break
elif (int(math.fabs(difference) > sumLower(group-1, center))):
#print "Yes"
#print difference, groupSum, group
if (difference == 0):
pass
else:
digitGroup = (group)*(difference/math.fabs(difference))
break
return digitGroup
def sumLower(value, mean):
total = 0
for i in range(value, 0, -1):
#print value, i
total += i
return total
#for i in range(-60,60):
# print i, findCompactionDivision(i, 30)