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

Make EBSDMasterPattern.get_patterns() allow a 2D navigation shape + minor improvements #275

Merged
merged 9 commits into from
Jan 10, 2021

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Jan 6, 2021

Description of the change

Several changes to the EBSDMasterPattern class:

  • Rename "spherical" projection to "stereographic" projection in class and IO.
  • Add a progressbar to EBSDMasterPattern.get_patterns(). The progressbar is dask's own ProgressBar().
  • Make EBSDMasterPattern.get_patterns() accept a Rotation with a 2D navigation shape, i.e. of shape (ny, nx, 4), and return an EBSD signal with a (ny, nx) navigation shape.

Other changes:

  • Remove warning in pattern matching notebook about get_patterns() only working for cubic crystals.

Closes #270 and #265.

Progress of the PR

Minimal example of the bug fix or new feature

>>> from orix import sampling
>>> import kikuchipy as kp

# Spherical -> stereographic

>>> mp = kp.data.nickel_ebsd_master_pattern_small(projection="stereographic")
>>> mp.projection
stereographic

# Progressbar showing ouput navigation shape

>>> mp = kp.data.nickel_ebsd_master_pattern_small(projection="lambert")
>>> r = sampling.get_sample_fundamental(resolution=5, space_group=225)
>>> detector = kp.detectors.EBSDDetector(
    shape=s.axes_manager.signal_shape[::-1],
    pc=[0.421, 0.7794, 0.5049],
    sample_tilt=70,
    convention="tsl",
)
>>> sim = mp.get_patterns(rotations=r, detector=detector, energy=20, compute=True)
Creating a dictionary of (7467,) simulated patterns:
[########################################] | 100% Completed |  8.8s

# 2D navigation shape allowed via shape of rotations object. A finer control of chunk size,
# via number of patterns in each chunk, `chunk_size`, or number of bytes in each chunk,
# `chunk_bytes`, is possible via a new `kikuchipy.signals.util.get_chunking` function.

>>> r2 = r[:6000].reshape(60, 100)
>>> sim2 = mp.get_patterns(rotations=r2, detector=detector, energy=20, chunk_size=10)
>>> sim2
<LazyEBSD, title: , dimensions: (100, 60|60, 60)>
>>> sim2.data.chunksize
(10, 10, 60, 60)

Will add more examples as stuff is done.

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    the unreleased section in doc/changelog.rst.

@hakonanes hakonanes added the enhancement New feature or request label Jan 6, 2021
@hakonanes hakonanes added this to the v0.3.0 milestone Jan 6, 2021
@hakonanes hakonanes self-assigned this Jan 6, 2021
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes marked this pull request as draft January 6, 2021 16:00
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes marked this pull request as ready for review January 8, 2021 12:54
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes
Copy link
Member Author

@friedkitteh I would appreciate it if you could take a look at the changes made to the ebsd_master_pattern.py and test_ebsd_master_pattern.py files. You don't have to review the other files (large PR...).

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

@friedkitteh friedkitteh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logical improvements in ebsd_master_pattern.py (and the following tests)!

In the docstrings we now refer to the "Lambert projection" in 3 different ways:

  1. Lambert projection
  2. (modified) Lambert projection
  3. Rosca-Lambert projection

it would probably be beneficial to refer to them with the same name?

@hakonanes
Copy link
Member Author

1. Lambert projection

2. (modified) Lambert projection

3. Rosca-Lambert projection

Since we map 3D vectors on parts of the northern or southern hemisphere of the Kikuchi sphere (our detector) onto a 2D square grid, and Callahan and De Graef call this the modified Lambert projection, I think we should as well. I'll therefore go with "Modified Lambert projection". What do you think of this, @friedkitteh?

@friedkitteh
Copy link
Collaborator

1. Lambert projection

2. (modified) Lambert projection

3. Rosca-Lambert projection

Since we map 3D vectors on parts of the northern or southern hemisphere of the Kikuchi sphere (our detector) onto a 2D square grid, and Callahan and De Graef call this the modified Lambert projection, I think we should as well. I'll therefore go with "Modified Lambert projection". What do you think of this, @friedkitteh?

Yep - That sounds reasonable.

@hakonanes
Copy link
Member Author

Or, you know what, we could provide some more information in the naming by calling it the "square Lambert projection" instead.

@hakonanes
Copy link
Member Author

I'm glad you asked that question... I actually think we should rename the LambertProjection() to SquareLambertProjection() as well, to separate it from the Lambert equal-area projection to a 2D circle. What do you think, @friedkitteh?

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

@friedkitteh friedkitteh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is much clearer now!

@friedkitteh
Copy link
Collaborator

I'm glad you asked that question... I actually think we should rename the LambertProjection() to SquareLambertProjection() as well, to separate it from the Lambert equal-area projection to a 2D circle. What do you think, @friedkitteh?

It probably wouldn't hurt..

@hakonanes hakonanes merged commit cafe51a into pyxem:master Jan 10, 2021
@hakonanes hakonanes deleted the improve-master-pattern-class branch January 10, 2021 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EBSDMasterPattern.get_patterns() needs a progressbar
2 participants