Skip to content
Snippets Groups Projects
Commit ea135458 authored by lorenzennio's avatar lorenzennio
Browse files

Developing unittests. x fit super unstable. y fit ok, but some very off fits now and then.

parent 9570134d
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ class Analysis:
self.zPoints['Mean'],
sx = self.xPoints['Error'],
sy = self.zPoints['Error'])
xODR = odr.ODR(xData, xModel, beta0=[1, 1, 1, 1])
xODR = odr.ODR(xData, xModel, beta0=[1, 100, 100, 100])
xOUT = xODR.run()
xOUT.pprint()
"""
......@@ -124,7 +124,7 @@ class Analysis:
self.yPoints['Mean'],
sx = self.zPoints['Error'],
sy = self.yPoints['Error'])
yODR = odr.ODR(yData, yModel, beta0=[1e3, 1, 1])
yODR = odr.ODR(yData, yModel, beta0=[1e3, 100, 100])
yOUT = yODR.run()
yOUT.pprint()
"""
......
......@@ -13,5 +13,7 @@ class Particle:
DET = Detector()
DETRes = DET.detect(Particle())
ANA = Analysis(DETRes)
ANA = Analysis()
ANA.fill(DETRes)
ANA.yFit()
......@@ -7,7 +7,7 @@ class testAnalysis(unittest.TestCase):
"""
A simple test to check the angle means ans error computation.
"""
def test(self):
def testxFit(self):
#ang = np.array([6,5,6,5,8,4,8,4,7,1,7,1,10,3,10,3,None,None,None,None])
#ang = np.reshape(ang, (5,2,2))
A = Analysis()
......@@ -15,15 +15,15 @@ class testAnalysis(unittest.TestCase):
#self.assertEqual(A.results['Error'][0], 0.5)
z = np.arange(30)
y = A.yEOM([100,1,1], z)
z = np.arange(0, 30)
y = A.yEOM([1000,1,1], z)
#plt.plot(z,y)
#plt.show()
Data = []
for i in range(0,len(z)):
err = np.random.random(size=(4))
print(err)
err =0.01* np.random.random(size=(4))
#print(err)
Data.append([[0,0], [y[i]+err[0],y[i]-err[1]], [z[i]+err[2], z[i]-err[3]]])
#np.concatenate((Data,
# [[0,0], [y[i]+0.1,y[i]-0.1], [z[i]+0.1, z[i]-0.1]]), axis=0)
......@@ -34,3 +34,31 @@ class testAnalysis(unittest.TestCase):
#print(y)
#print(z)
#print(Data)
def testyFit(self):
#ang = np.array([6,5,6,5,8,4,8,4,7,1,7,1,10,3,10,3,None,None,None,None])
#ang = np.reshape(ang, (5,2,2))
A = Analysis()
#self.assertEqual(A.results['Mean'][0], 5.5)
#self.assertEqual(A.results['Error'][0], 0.5)
x = np.arange(0, 10, 0.1)
z = A.xEOM([1,10,10,100], x)
#plt.plot(z,x)
#plt.show()
Data = []
for i in range(0,len(z)):
err =0.01* np.random.random(size=(4))
#print(err)
Data.append([[x[i]+err[0],x[i]-err[1]], [0,0], [z[i]+err[2], z[i]-err[3]]])
#np.concatenate((Data,
# [[0,0], [y[i]+0.1,y[i]-0.1], [z[i]+0.1, z[i]-0.1]]), axis=0)
Data = np.array(Data)
A.fill(Data)
A.xFit()
#print(y)
#print(z)
#print(Data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment