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
Azimuthal integral off-by-one bugfix #1058
Azimuthal integral off-by-one bugfix #1058
Conversation
It seems the docs failed because I assumed a |
Non-flat Ewald's sphere seems to work now, but apart from manually inspecting some plots with exaggerated pixel sizes and camera lengths I don't know how to test it... The implementation now calculates the extent in cartesian space for each pixel, accounting for the curvature of Ewald's sphere where applicable. |
Marking as draft, some unrelated tests fail now and I don't have more time today |
@viljarjf Do you want me to look at this later? I can help with the failing tests and review. |
@CSSFrancis If you want, sure! I believe the tests fail because I changed the way the center index was calculated in |
It was the center coordinates. The pixel coordinate of |
I also want to add support for the I have the code ready, but it might fit better in another PR? Alternatively, I could change the subject of this PR to be more broad. |
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.
@viljarjf This is good, thanks for cleaning up my mistakes :)
We should also make an example showing how pixels are defined in pyxem. In this case we use the center of the pixel to determine the coordinates rather than the upper right hand corner?
@viljarjf I think this is good! Any chance you can look over the example I just added regarding the coordinate conventions. |
Let's add that as a separate PR as this one seems good to go. If only to let you run the CI without approval :) |
@viljarjf Do you want to update the changelog as well? |
Fixes an off-by-one error in azimuthal integration
Checklist
What does this PR do? Please describe and/or link to an open issue.
An off-by-one error meant the final row and column of the signal was ignored when transforming to polar coordinates with
Diffraction2D.get_azimuthal_integral2d
.In the old code, the new test fails for all
corner != (0, 0)
, i.e. all corners at the last row and/or column.The new implementation calculates the extent in cartesian space of each pixel, accounting for the curvature of Ewald's sphere where applicable, and uses those for
utils._azimuthal_integrations._get_factors
.The previous implementation relied on the
Calibration.axes
, where the final element was not included due to the off-by-one error. Furthermore, from looking at hyperspy plots with few signal pixels, the coordinates of the axes represent the centers rather than the edges of the pixels, which is now accounted for