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

ECPMasterPattern class and readers for ECP and TKD master patterns from EMsoft's HDF5 files #476

Closed

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Nov 30, 2021

Description of the change

  • Address Reader for EMsoft simulations of electron channelig master patterns #386 and Master pattern classes and readers from EMsoft #390. These issues can be closed after this PR is merged.
  • Move most functionality in EBSDMasterPattern class to an abstract KikuchiMasterPattern class (not to be used directly), which EBSDMasterPattern now is a derived class of.
  • Add a new ECPMasterPattern class also derived from KikuchiMasterPattern.
  • Add readers for TKD (transmission kikuchi diffraction) and ECP (electron channeling pattern) master patterns from EMsoft's HDF5 files returned from their EMTKDmaster.f90 and EMECPmaster.f90 programs, respectively. The TKD reader returns a EBSDMasterPattern instance, while the ECP reader returns a ECPMasterPattern instance. All three master pattern readers, EBSD, TKD, and ECP, are derived from a private, generalized EMsoftMasterPatternReader class which holds all of the functionality in the old EBSD master pattern class. Thanks to EMsoft's generalized approach to their HDF5 files, this required very little extra work!
  • Update documentation and tests accordingly.

The ECPMasterPattern class does not have other methods than rescaling/normalization of intensities yet. That is, I decided to restrict the EBSDMasterPattern.get_patterns() to EBSD and TKD patterns. To project a part of an ECP master pattern onto a detector, we need to define a new ECPDetector. The interpolation should be the same as for EBSD/TKD patterns. For now, if it is desirable to use get_patterns() with an ECP master pattern, one can change the signal type from ECPMasterPattern to EBSDMasterPattern with mp_ecp.set_signal_type("EBSDMasterPattern").

I decided that as of now it is not necessary to create a separate TKDMasterPattern class, as the EBSDMasterPattern.get_patterns() works nicely to project parts of the TKD kikuchi sphere onto a TKD detector (EBSDDetector), as long as parameters like the sample tilt are set correctly.

Note that this PR is a substantial step towards supporting dictionary indexing for TKD patterns.

@IMBalENce, I would appreciate it if you could try out my branch to:

  • check that you can read your ECP patterns into an ECPMasterPattern.
  • try to figure out which methods the ECPMasterPattern class should have. I haven't conducted an ECP experiment before, so I wouldn't know what would be the most useful functionality to have.

See #477 for discussing ECP functionality.

Progress of the PR

  • Docstrings for all functions
  • Unit tests with pytest for all lines
  • Clean code style by running black via pre-commit
  • Find out whether we should take "combinesites" True/False into account in the EMsoft master pattern readers (can be an issue when reading the Lambert projection)
  • Find out how we can support some ECPMasterPattern.get_patterns() functionality. Should be done in a separate PR.
  • Determine whether the KikuchiMasterPattern._is_suitable_for_projection() method should be moved to EBSDMasterPattern, since it shouldn't be supported for ECP master patterns
  • Add TKD and ECP master patterns to the kikuchipy.data module for testing and documentation
  • Update reference frame user guide
  • Add some metadata information read in the readers to the returned signals' original_metadata

Minimal example of the bug fix or new feature

>>> import kikuchipy as kp
>>> mp_tkd = kp.load("au_mc_mp_30kv_tkd.h5", projection="lambert", energy=30)
>>> mp_tkd
<EBSDMasterPattern, title: au_mc_mp_30kv_tkd, dimensions: (|1001, 1001)>
>>> mp_ecp = kp.load("ni_mc_mp_20kv_ecp.h5", projection="stereographic", energy=20)
>>> mp_ecp
<ECPMasterPattern, title: ni_mc_mp_20kv_ecp, dimensions: (|1001, 1001)>
>>> mp_ecp.projection
'stereographic'
>>> mp_ecp.hemisphere
'north'
>>> mp_ecp.phase
<name: ni. space group: Fm-3m. point group: m-3m. proper point group: 432. color: tab:blue>

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>
@hakonanes hakonanes added enhancement New feature or request documentation This relates to the documentation labels Nov 30, 2021
@hakonanes hakonanes added this to the v0.6.0 milestone Nov 30, 2021
@hakonanes
Copy link
Member Author

The updated documentation can be viewed in the docs built off of this PR by ReadTheDocs:

@IMBalENce
Copy link
Contributor

Great! thank you for the effort. I have fetched your branch and will have a play. I'll put some more thought in the methods that we need in the ECPMasterPattern class.

@hakonanes
Copy link
Member Author

I'll put some more thought in the methods that we need in the ECPMasterPattern class.

Thanks. To keep this PR on the topic of the IO plugins only, I suggest we discuss ECP functionality in #477.

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

Two tests are failing due to #509, and the code style fails because of changes in the stable release of black (see pyxem/orix#273).

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

Closed in favor of #564.

@hakonanes hakonanes closed this Sep 22, 2022
@hakonanes hakonanes deleted the generalize-master-pattern-class branch September 22, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This relates to the documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants