-
Notifications
You must be signed in to change notification settings - Fork 4
[WIP] Improving solid angle correction #18
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
base: master
Are you sure you want to change the base?
Conversation
|
The new calculation of solid angle follows the approach described here in Eq. (7) |
|
The attached presentation shows, on slide 16, the derivation of the solid angle correction as implemented in this merge request. It also illustrates how the old version was essentially the same, normalized to the (would-be) value of the center pixel. |
|
@JJBekx, you mean PONI-pixel (Pixel Of Normal Incidence)? It seems this original normalization is quite common. Its advantage is that it is at the scale of 1 in most cases. The disadvantage is that if comparison of data for different detector positions or different detectors is required, one has to know the calibration (PONI-detector distance and pixel dimensions) to rescale to absolute intensity values. Is it not better we leave the choice on the user? I.e. we add an option normalization: "to PONI-pixel" and "absolute"? |
zdemat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hej @JJBekx , @SAnsell has the point that in some cases (extra low angles) the numerical precision in the denominator (D^2 + px^2 + py^2), where (px^2 + py^2) << D^2, is insufficient. Would it be possible to do and expansion of (1+r)^(3/2) for r<<1? Of course there are extreme cases where e.g. (D^2 + px^2) << py^2, but they may be less common.
I agree that leaving it as an option to the user could be implemented, and would ease the transition of older versions of azint to newer ones that have this solid-angle correction. |
It'd be possible of course, but I don't see how a truncated Taylor series would provide a more exact answer. |
|
I am joining this discussion a bit late, so I might have missed something, but to me it looks like I have a not-so-pretty example here: def P_SA(xyz, pf=.99, pyfai_convention=True):
"""
Combined polarization and solid-angle correction
Parameters
----------
xyz - ndarray (3,h,w)
detector pixel coordinates as a (3,h,w) array of vectors
pf - float
polarization factor (-1 vertical, +1 horizontal)
pyfai_convention - bool
use pyFAI convention (-1 vertical, +1 horizontal)
else use Als-Nielsen convention (0 vertical, +1 horizontal)
pf = pf_pyfai*2-1
Return
---------
P_SA - ndarray (h,w)
the combined pixel-wise polarization and solid-angle correction
"""
if pyfai_convention:
pf = pf*2-1
r = np.sqrt(np.sum(xyz**2,axis=0))
v = xyz/r
p_h = v[0]**2*pf
p_v = v[1]**2*(1-pf)
p = 1.-(p_h+p_v)
r_3 = r**(-3)
SA = r_3/r_3.max()
return p*SA |
|
Hej @fgjorup do not be afraid. Our formula is correct :-) (px,py) are points on the detector plane. The z = poni.dist = D by definition. The PONI (point/pixel of normal incidence) is zero (px=0,py=0). So everything is perfectly orthogonal. That is the idea of PONI and the detector coordinate system related to PONI. All flat detectors are "perpendicular to the sample" in the single point and this PONI :-) Only the beam passing the sample point may hit the detector plane at oblique angle, i.e. not in the PONI. And the solid angle correction is about sample-detector geometry relation, not about beam. |
Hi @zdemat, So it should be: Perhaps it is worthy of note that this is not related to the choice of abs vs rel SA, and that this error is present in the main branch as well. Just for crystal-clarity: |
I see, the coordinates are in the "detector frame". As you see in my example I also calculate the polarization correction, so in that case I need to stay in the "lab frame", hence the confusion. |
Oh, @zdemat @fgjorup, you're right. p1 and p2 are pixel positions after the poni translation, but without the rotations applied. |
Trying to improve solid angle corrections. Current method might be a bit off or too simplified. This PR is a first step to make it better.
Please drop any papers, notes, or explanations that justify the changes or highlight the issues with the current approach. Would be helpful for context and future reference.
Feel free to tag others who should take a look.
@JJBekx @SAnsell @zdemat @fgjorup