Skip to content
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

Fix projection center conversions in EBSDDetector #455

Merged
merged 20 commits into from
Oct 28, 2021

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Oct 15, 2021

Description of the change

Addresses multiple issues with conversions of projection center (PC) coordinates between conventions identified in #449, thanks to @IMBalENce. I believe the conversion will be more correct after these changes:

  • EMsoft's xpc coordinate was wrongly flipped given v4 and v5, should be correct now. Basically, with EMsoft v5, a positive xpc now gives x* > 0.5.
  • Conversion between TSL/Oxford and Bruker accounts for a potential aspect ratio not equal to 1, i.e. typically more detector columns than rows. This is necessary because TSL/Oxford defines all coordinates as fractions of detector columns, while Bruker defines y* and z* as fractions of detector height.

@IMBalENce, if you find the time, I would appreciate it if you could review the definitions below. If you do so, is it OK if I add you to the contributor list in the changelog to the next patch release, and also to the all-contributors table in the README?

We should release v0.5.3 from main after this PR is in.

Fix #449.


The EBSDDetector.__init__() docstring has these additions:

bilde


The EBSDDetector.pc_emsoft() docstring has these additions:

bilde


The EBSDDetector.pc_tsl() docstring has these additions (equivalent equations for pc_oxford()):

bilde

Progress of the PR

Minimal example of the bug fix or new feature

>>> import kikuchipy as kp
>>> detector1 = kp.detectors.EBSDDetector(
...    shape=(120, 160),
...    pc=(0.48935617839432832, 0.61856923343313686, 0.49397253582464035),
...    convention="oxford",
...    px_size=59.2,
...    binning=4,
...    sample_tilt=70.004152426213111
... )
>>> print("Bruker: ", detector1.pc[0], "\nEMsoft: ", detector1.pc_emsoft()[0], "\nOxford: ", detector1.pc_oxford()[0], "\n")
Bruker:  [0.48935618 0.17524102 0.65863005] 
EMsoft:  [1.7030115e+00 3.8971077e+01 1.8715631e+04] 
Oxford:  [0.48935618 0.61856923 0.49397254] 
>>> detector2 = kp.detectors.EBSDDetector(
...     shape=(120, 160),
...     pc=(-6.8120461, 155.88431, 18715.631),
...     convention="emsoft",
...     px_size=59.2,
...     binning=4,
...     sample_tilt=70.004152426213111
... )
>>> print("Bruker: ", detector2.pc[0], "\nEMsoft: ", detector2.pc_emsoft()[0], "\nOxford: ", detector2.pc_oxford()[0], "\n")
Bruker:  [0.4893562  0.17524102 0.65863   ] 
EMsoft:  [6.8120384e+00 1.5588431e+02 1.8715631e+04] 
Oxford:  [0.4893562  0.61856925 0.4939725 ] 

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • New contributors are added to .all-contributorsrc and the table is regenerated.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes added bug Something isn't working documentation This relates to the documentation tests This relates to the tests labels Oct 15, 2021
@hakonanes hakonanes added this to the v0.5.3 milestone Oct 15, 2021
@hakonanes
Copy link
Member Author

Pinned h5py to <= 3.4 so it works with HyperSpy <= 1.6.4. This pinning should be removed when HyperSpy 1.6.5 is released, and HyperSpy's lowest supported version should be pinned to >= 1.6.5. I've added a TODO to remember this.

@IMBalENce: I've added you to package credits and the All Contributors table.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes
Copy link
Member Author

I've set the planned release date of the v0.5.3 patch release to coming Monday November 1st.

@hakonanes
Copy link
Member Author

I'll merge after checks pass.

@hakonanes hakonanes merged commit fda2565 into pyxem:main Oct 28, 2021
@hakonanes hakonanes mentioned this pull request Nov 2, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation This relates to the documentation tests This relates to the tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants