add calcParamFast to helicascan
This commit is contained in:
@@ -710,6 +710,75 @@ class HelicalScan(MotionBase):
|
|||||||
res=(cx,cz,w,fy)
|
res=(cx,cz,w,fy)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def calcParamFast(self,x=((-241.,96.),(-162.,-293.)),
|
||||||
|
y=(575.,175.),
|
||||||
|
z=((-1401.,-1401.),(-1802.,-1303.)),
|
||||||
|
w=(1.2,1.4),
|
||||||
|
mode=1):
|
||||||
|
'''
|
||||||
|
the rotation center of the stage does not change for a new cristal.
|
||||||
|
after the function calcParam was called once,
|
||||||
|
this faster coordinate transformation can be used.
|
||||||
|
FOR SMALL ANGLES USE MODE==0.
|
||||||
|
!!! THIS CODE IS NOT YET TESTED !!!
|
||||||
|
'''
|
||||||
|
#x: ((x_w0y0, x_w1y0),(x_w0y1, x_w1y1)
|
||||||
|
#y: lower and upper cristal point
|
||||||
|
#z: distance, similar to x
|
||||||
|
#w: start and end angle in radians
|
||||||
|
#mode 0:use x and z needs to define 1 point at start and 1 point at end
|
||||||
|
# 1:use x change with 2 angles needs to define 2 point at start and 2 point at end
|
||||||
|
|
||||||
|
#mode 0 uses:
|
||||||
|
#x: ((x_w0y0, None ),(None , x_w1y1)
|
||||||
|
#z: ((z_w0y0, None ),(None , z_w1y1)
|
||||||
|
#w: (w0,w1)
|
||||||
|
|
||||||
|
#mode 1 uses:
|
||||||
|
#x: ((x_w0y0, x_w1y0),(x_w0y1, x_w1y1)
|
||||||
|
#z: ((None, None ),(None , None )
|
||||||
|
#w: (w0,w1)
|
||||||
|
|
||||||
|
|
||||||
|
# param[i]=(z_i, y_i, x_i, r_i,phi_i)
|
||||||
|
# z_i not changed
|
||||||
|
# y_i trivial
|
||||||
|
# x_i not changed
|
||||||
|
# r_i calculate
|
||||||
|
# phi_i calculate
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
param=self.param
|
||||||
|
except AttributeError as e:
|
||||||
|
raise AttributeError('calcParam must be called first')
|
||||||
|
|
||||||
|
if mode==0:
|
||||||
|
for i in range(len(y)):
|
||||||
|
# param[i]=(z_i, y_i, x_i, r_i,phi_i)
|
||||||
|
r_i =np.sqrt(x[i]**2+z[i]**2)
|
||||||
|
phi_i=np.arctan2(z[i],x[i])
|
||||||
|
param[i, 1]=y[i]
|
||||||
|
param[i, 3:]=(r_i,phi_i)
|
||||||
|
else: #mode==1:
|
||||||
|
for i in range(len(y)):
|
||||||
|
# param[i]=(z_i, y_i, x_i, r_i,phi_i)
|
||||||
|
r_i=np.sqrt(x[i]**2+z[i]**2)
|
||||||
|
x0=x[i][0]-param[i,2]
|
||||||
|
x1=x[i][1]-param[i,2]
|
||||||
|
ww=w[i]
|
||||||
|
if x0>x1:
|
||||||
|
phi_i=np.arctan2(np.cos(ww)-x1/x0,np.sin(ww))
|
||||||
|
r_i =x0/np.cos(phi_i)
|
||||||
|
else:
|
||||||
|
phi_i=np.arctan2(np.cos(ww)-x0/x1,np.sin(ww))
|
||||||
|
r_i =x1/np.cos(phi_i)
|
||||||
|
param[i, 1]=y[i]
|
||||||
|
param[i, 3:]=(r_i,phi_i)
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def calcParam(self,x=((-241.,96.,-53.),(-162.,-293.,246.)),
|
def calcParam(self,x=((-241.,96.,-53.),(-162.,-293.,246.)),
|
||||||
y=(575.,175.),
|
y=(575.,175.),
|
||||||
z=((-1401.,-1401.,-1802.),(-1802.,-1303.,-1402.))):
|
z=((-1401.,-1401.,-1802.),(-1802.,-1303.,-1402.))):
|
||||||
|
|||||||
Reference in New Issue
Block a user