-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect calculation of exit angle for Q vector #2295
Comments
Hi Philip, |
Although I understand that the grazing incidence community calls |
Thank you for the explanation - I think the new vector component calculations make sense to me. i still have two questions:
unit_qip = "qip_nm^-1"
unit_qoop = "qoop_nm^-1" instead you need to use the grazing incidence fiber units e.g. unit_qip = get_unit_fiber(name="qip_nm^-1", incident_angle=0.2, tilt_angle=0.4, sample_orientation=1)
unit_qoop = get_unit_fiber(name="qoop_nm^-1", incident_angle=0.2, tilt_angle=0.4, sample_orientation=1)
|
Hi Philip, |
Hello,
Screencast.from.29-10-24.15.41.43.webmDo you have any more details of what other users have been doing if they want to use pyFAI for images taken with diffractometers where the delta motion is stacked ontop of the gamma motion? |
I believe that if the two rotation are actually inverted (rot1+rot2 vs gamma+delta), the solution is to use an Euler transformation library like the one from Christoph Gohlke which is able to match any of many set of Euler angle. |
Hello @P-Mousley , could you share with us how you calculate coordinates in your script?
|
Hello @mjdiff , To calculate the co-ordinates in the script I used simple rotation matrices from scipy around the x,y,or z axis. Expand code used for rotation calculationimport matplotlib.pyplot as plt
from scipy.spatial.transform import Rotation as R
import transformations as tf
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as wg
%matplotlib qt
ax = plt.axes([0,0,0.95,0.95],projection ='3d')
def drawline(vec1,vec2,axs,col):
axs.plot([vec1[0],vec2[0]],[vec1[1],vec2[1]],[vec1[2],vec2[2]],color = col)
def drawdet(veclist,ax,col):
drawline(veclist[0],veclist[1],ax,col)
drawline(veclist[1],veclist[2],ax,col)
drawline(veclist[2],veclist[3],ax,col)
drawline(veclist[3],veclist[0],ax,col)
drawline([0,0,0],veclist[4],ax,col)
def drawplots(gamma,delta,rot1,rot2,rot3):
ax.cla()
# Set the axis labels
ax.set_xlabel('z')
ax.set_ylabel('x')
ax.set_zlabel('y')
rotdelta=R.from_euler('y', -delta, degrees=True)
rotgamma=R.from_euler('z',gamma,degrees=True)
rot1mat=R.from_euler('y', -rot2, degrees=True)
rot2mat=R.from_euler('z',rot1,degrees=True)
rot3mat=R.from_euler('x',rot3,degrees=True)
veclist=[[4,0.5,0.5],[4,0.5,-0.5],[4,-0.5,-0.5],[4,-0.5,0.5],[4,0,0]]
totalrot=rotgamma*rotdelta
totalrot2=rot3mat*rot2mat*rot1mat
rotvecs1=[]
rotvecs2=[]
for vec in veclist:
rotvecs1.append(totalrot.apply(vec))
rotvecs2.append(totalrot2.apply(vec))
drawdet(veclist,ax,'blue')
drawdet(rotvecs1,ax,'orange')
drawdet(rotvecs2,ax,'green')
ax.set_zlim(-4,4)
ax.set_ylim(-4,4)
ax.set_xlim(-4,4)
gammaslide=wg.FloatSlider(min=-10, max=90, step=0.001, value=0)
deltaslide=wg.FloatSlider(min=-10, max=90, step=0.001, value=0)
rot1slide=wg.FloatSlider(min=-90, max=90, step=0.001, value=0)
rot2slide=wg.FloatSlider(min=-90, max=90, step=0.001, value=0)
rot3slide=wg.FloatSlider(min=-90, max=90, step=0.001, value=0)
interact(drawplots,axs=ax,gamma=gammaslide,delta=deltaslide,rot1=rot1slide,rot2=rot2slide,rot3=rot3slide) The transformations library @kif recommend earlier has allowed me to calculate the corresponding values for rot1,rot2,rot3 which are equivalent to a delta +gamma pair of diffractometer angles - see code example below. Expand code used for converting delta,gamma into rot1,rot2,rot3 def gamdel2rots(self,gamma,delta):
"""
Parameters
----------
gamma : float
angle rotation of gamma diffractometer circle in degrees.
delta : float
angle rotation of delta diffractometer circle in degrees.
Returns
-------
rots : list of rotations rot1,rot2,rot3 in radians to be using by pyFAI.
"""
rotdelta=R.from_euler('y', -delta, degrees=True)
rotgamma=R.from_euler('z',gamma,degrees=True)
totalrot=rotgamma*rotdelta
fullrot=np.identity(4)
fullrot[0:3,0:3]=totalrot.as_matrix()
vals=tf.euler_from_matrix(fullrot,'rxyz')
rots=vals[2],-vals[1],vals[0]
return rots |
Great ... Thanks for your work. Can we reuse it in the documentation ? |
Yes, happy for you to use my code |
I think that the calculation performed when requesting Q units for 2d map calculations appears to be only valid when x=0, which does not work if you want to move the detector using rot2.
The function eq_exitangle that has the issue is here
the current version is simply
which does not take into account the effect of x, and also assumes that the exit vector is aligned with the incident angle
a possible correction is as follows:
Let me know if i have understood the function correctly, and if the proposed correction is suitable.
The text was updated successfully, but these errors were encountered: