This commit is contained in:
2019-01-10 16:48:08 +01:00
parent 3a08775210
commit 03bce16acc
2 changed files with 141 additions and 88 deletions

View File

@@ -710,35 +710,21 @@ class HelicalScan(MotionBase):
res=(cx,cz,w,fy)
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):
def calcParam1Pt(self,x=(-241.,-162.),
y=(575.,175.),
z=(-1401.,-1802.),
w=1.2):
'''
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 !!!
this 1 point coordinate transformation can be used.
it needs 1 point at start and 1 point at end of the crystal
'''
#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)
#x: x position at y0 and y1 : (x_y0, x_y1)
#y: lower and upper cristal point (y0, y1)
#z: x position at y0 and y1 : (z_y0, z_y1)
#w: stage angle in radians
# param[i]=(z_i, y_i, x_i, r_i,phi_i)
# z_i not changed
@@ -747,41 +733,73 @@ class HelicalScan(MotionBase):
# r_i calculate
# phi_i calculate
try:
param=self.param
except AttributeError as e:
raise AttributeError('calcParam must be called first')
for i in range(len(y)):
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-w)
pass
def calcParam2Pt(self,x=((-241.,96.),(-162.,-293.)),
y=(575.,175.),
w=(1.2,1.4)):
'''
the rotation center of the stage does not change for a new cristal.
after the function calcParam was called once,
this 2 point coordinate transformation can be used.
it needs 2 point at start and 2 point at end of the crystal
'''
#x: ((x_w0y0, x_w1y0),(x_w0y1, x_w1y1)
#y: lower and upper cristal point (y0, y1)
#w: start and end stage angle in radians (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)
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.)),
y=(575.,175.),
z=((-1401.,-1401.,-1802.),(-1802.,-1303.,-1402.))):
'''
calculates coordinate parameters out of measurements at
aequidistant angles (typically 0,120,240 deg)
if a needle tip is used to calibrate (only one y value) use:
x=(x_meas,x_meas), (x_meas is a nx1 array)
z=(x_meas,x_meas), (z_meas is a nx1 array)
y=(y_meas,x_meas+ofs), (y_meas is a value, ofs is any value>0 recommended 100.)
'''
# param[i]=(z_i, y_i, x_i, r_i,phi_i)
#real measured values:
#y : 2x1 array : y position were the measurements were taken
#x : 3x2 array : 3 measurements at angle 0,120,240 for y[0] and y[1]