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

Add method to downsample EBSD patterns while maintaining data type range #592

Merged
merged 7 commits into from
Jan 13, 2023

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Jan 13, 2023

Description of the change

HyperSpy's Signal2D.rebin() is a powerful tool for binning, but it does not rescale intensities. This can lead to memory problems. This PR adds a EBSD.downsample() method which rescales intensities after binning before overwriting each pattern inplace. It only supports one integer binning factor which must be a divisor of both detector dimensions. Which data type to rescale intensities to can be specified. This of course leads to contrast between patterns being lost.

Calling EBSD.rebin() followed by EBSD.rescale_intensity() effectively gives the same result as calling EBSD.downsample().

I also sorted EBSD methods into groups based on "types" (tools, feature maps, intensity processing [including downsample()], indexing etc.). This is the reason for the relatively large git diff.

Closes #464.

Progress of the PR

Minimal example of the bug fix or new feature

>>> import matplotlib.pyplot as plt
>>> import kikuchipy as kp
>>> s = kp.data.silicon_ebsd_moving_screen_in()
>>> s.remove_static_background()
>>> s2 = s.rebin(scale=(2, 2), dtype=s.data.dtype)
>>> s3 = s.deepcopy()
>>> s3.downsample(2)
>>> fig, (ax0, ax1) = plt.subplots(ncols=2)
>>> ax0.imshow(s2.data)
>>> ax1.imshow(s3.data)

test

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 release.py, .zenodo.json and
    .all-contributorsrc with the table 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>
@hakonanes hakonanes added the enhancement New feature or request label Jan 13, 2023
@hakonanes hakonanes added this to the v0.8.0 milestone Jan 13, 2023
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 merged commit 3106c75 into pyxem:develop Jan 13, 2023
@hakonanes hakonanes deleted the add-downsample-method branch January 13, 2023 16:57
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.

Alternative downsampling to the one from HyperSpy
1 participant