forked from yetkinyilmaz/tracking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFitting.py
More file actions
33 lines (24 loc) · 757 Bytes
/
Fitting.py
File metadata and controls
33 lines (24 loc) · 757 Bytes
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
from scipy.optimize import curve_fit
from Transform import *
def circular_path(x, r, vx, vy):
return r - np.sqrt(r**2-(x-vx)**2) + vy
class TrackFitter():
def __init__(self,B):
self.B = B
pass
def fit(self,x,y):
if(len(x) < 2) :
return 0,0,0,0,0
xr,yr,phi=rotateArrayToQuadrant(x,y)
xr,yr,chg = reflect(xr,yr)
p, cov = curve_fit(circular_path, xr, yr,
p0=[200.,0.,0.],
bounds=([5.,-25.,-25.],
[1000., 25, 25]
)
)
r = p[0]
pt = self.B*r
vx = p[1]
vy = p[2]
return pt,phi,vx,vy,chg