Open P-Mousley opened 1 month ago
Hi Philip, Thanks for the report, I will let Edgar deal with this since I am not the most competent on this topic. Cheers, Jerome
Hi, Philip. Thanks a lot for the issue. Indeed, there is an inconsistency with the exit_angle equation. However, to be consistent with the way I build the q equations, the correct equation is:
numpy.arctan2(y, numpy.sqrt(z ** 2 + x ** 2))
I use this exit_angle before applying the incident_angle and tilt_angle rotation matrix, so this exit_angle is a magnitude relative to the direct beam axis: it's the angle between kf and kf_xy
So, you're right that it depends on x, but it's a magnitude of the pixel position (only dependent of the poni and independent of the sample rotations). Again, this is my 'exit_angle' that I define like this, and then I apply the two rotation matrix to transform the q vector into the sample reference.
These days, I will include these corrections, also I will clarify the API with the equations, which are quite bulky.
Although I understand that the grazing incidence community calls exit_angle
a magnitude relative to the horizon of the thin film sample, so it's a magnitude of the sample reference frame that, of course, depends on both incident_angle
and tilt_angle
. For my approach, what I call now vertical and horizontal exit angles are actually the components of the classic scattering_angle
(2theta) from the powder diffraction point of view, which is I think the more "pyFAInic" way to implement this.
It would be happy anyway to include this grazing_incidence exit_angle
unit in the API.
Thank you for the explanation - I think the new vector component calculations make sense to me.
If i have understood correctly the rot1,rot2,rot3
from the PONI file are used to update the XYZ in the labframe for the exit vector using equations defined in pyFAI/src/pyFAI/ext/_geometry.pyx . The updated XYZ is then passed to your updated equations in units.py to calculated the Q vector components, taking account of incident_angle
and tilt_angle
i still have two questions:
incident_angle
and tilt_angle
you can no longer useunit_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, I am not a fiber guy so I can only answer for your second point. I wanted the last rotation to be free along Debye-Scherrer rings. There was no specific reason for the order of the rotation around vertical and horizontal axis of the detector and honestly, when I started pyFAI, I did not consider it would ever be used in conjunction with a diffractometer since everybody was happy with a detector mounted normal to the beam. Now pyFAI is used by thousands of users and PONI-files are distributed to all our users. Changing something so central is just not an option. But I can try to help in the math/trigonometry for converting geometries ... and this is something we would like to address for pyFAI2 (pluggable geometries)
Hello, I have had a look at the conversion equations to get a rot1,rot2 value pair for a set value of gamma and delta. However it seems impossible to get a direct conversion because pyFAI applies the same rot1 and rot2 values to the whole image. When comparing the two methods of positioning the detector (either rot1 then rot2, or delta then gamma) there is always a mismatch with the image vectors even if the central pixel overlaps perfectly. the attached plot shows this mismatch:
Screencast from 29-10-24 15:41:43.webm
Do 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.
https://pypi.org/project/transformations/
There is a snapshot of this library in pyFAI.third_party.transformations
which should be usable for this purpose.
Hello @P-Mousley , could you share with us how you calculate coordinates in your script?
Hello, I have had a look at the conversion equations to get a rot1,rot2 value pair for a set value of gamma and delta. However it seems impossible to get a direct conversion because pyFAI applies the same rot1 and rot2 values to the whole image. When comparing the two methods of positioning the detector (either rot1 then rot2, or delta then gamma) there is always a mismatch with the image vectors even if the central pixel overlaps perfectly. the attached plot shows this mismatch:
* the blue square the detector at all angels at 0 * the orange square for rotation of delta then gamma * the green square for rotation of rot1 then rot2.
Screencast.from.29-10-24.15.41.43.webm
Do 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?
Hello @P-Mousley , could you share with us how you calculate coordinates in your script?
Hello, I have had a look at the conversion equations to get a rot1,rot2 value pair for a set value of gamma and delta. However it seems impossible to get a direct conversion because pyFAI applies the same rot1 and rot2 values to the whole image. When comparing the two methods of positioning the detector (either rot1 then rot2, or delta then gamma) there is always a mismatch with the image vectors even if the central pixel overlaps perfectly. the attached plot shows this mismatch:
* the blue square the detector at all angels at 0 * the orange square for rotation of delta then gamma * the green square for rotation of rot1 then rot2.
Screencast.from.29-10-24.15.41.43.webm Do 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?
Hello @mjdiff ,
To calculate the co-ordinates in the script I used simple rotation matrices from scipy around the x,y,or z axis.
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.
Great ... Thanks for your work. Can we reuse it in the documentation ?
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.