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 CTF file reader and interactive crystal map plot example #451

Merged
merged 35 commits into from
May 13, 2024

Conversation

IMBalENce
Copy link
Contributor

@IMBalENce IMBalENce commented May 16, 2023

Description of the change

Following up #412, added a file reader for Oxford AZtec HKL .ctf file.
Added an example jupyter notebook for interactive plotting - clicking on an IPF map to retrieve phase name and Euler angles.

Progress of the PR

Minimal example of the bug fix or new feature

>>> from orix import io
>>> xmap = io.load("data.ctf") 
>>> xmap
Phase     Orientations         Name  Space group  Point group  Proper point group     Color
   -1      8358 (2.5%)  not_indexed         None         None                None         w
    1   322978 (97.5%)     Iron fcc        Fm-3m         m-3m                 432  tab:blue
Properties: bands, error, MAD, BC, BS
Scan unit: um

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.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@IMBalENce IMBalENce marked this pull request as ready for review May 16, 2023 08:40
@hakonanes hakonanes added enhancement New feature or request documentation Relates to the documentation labels May 16, 2023
@hakonanes hakonanes added this to the v0.12.0 milestone May 16, 2023
Copy link
Member

@hakonanes hakonanes left a comment

Choose a reason for hiding this comment

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

Thank you for this reader, @IMBalENce! It will make orix accessible to many more people.

With this PR I could read the only AZtec HKL CTF file I have on my computer (I got it from you last year). The can be simplified a lot, since many parts adopted from the .ang reader are unnecessary, I think. See comments.

The example is very nice, and a great addition to the docs! The next thing would be to navigate with the arrow keys... Another PR for another time.

examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
@@ -81,13 +81,19 @@ def loadctf(file_string: str) -> Rotation:
file_string
Path to the ``.ctf`` file. This file is assumed to list the
Euler angles in the Bunge convention in the columns 5, 6, and 7.
The starting row for the data that contains Euler angles is relevant
Copy link
Member

Choose a reason for hiding this comment

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

With the new ctf reader you're adding, I suggest to leave this function as is and instead deprecate it in favor of the new one. We can then remove it in v0.13. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. I was also planning to add a ctf file writer at some stage.

Copy link
Member

Choose a reason for hiding this comment

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

Great. Please tell me if you need some hints on deprecation.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you. If you could point me to some of the relevant information, I'd be very happy to take some reading.

Our dev docs briefly shows how to deprecate a function. You can catch a deprecation warning in tests like this.

orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
@IMBalENce
Copy link
Contributor Author

IMBalENce commented May 29, 2023

Thank you so much for your time on reviewing my changes @hakonanes. A lot of very helpful suggestions!

I just realize some of the test did not pass. I'll work on the test code.

Copy link
Member

@hakonanes hakonanes left a comment

Choose a reason for hiding this comment

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

Good work! Here are a few more comments.

I've found five different versions of the CTF format among the files collaborators have kindly shared with me over the years. Oxford Instruments, Bruker, NanoMegas ASTAR, EMsoft and MTEX can all write to this format. Your reader could read all of them (great!), but there are some slight differences and pitfalls which we need to address to support all of them. Are you OK with me contributing to your branch with a few commits to account for these differences?

Btw, I find it easiest if the reviewer resolves a conversation.

@@ -81,13 +81,19 @@ def loadctf(file_string: str) -> Rotation:
file_string
Path to the ``.ctf`` file. This file is assumed to list the
Euler angles in the Bunge convention in the columns 5, 6, and 7.
The starting row for the data that contains Euler angles is relevant
Copy link
Member

Choose a reason for hiding this comment

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

Great. Please tell me if you need some hints on deprecation.

orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
orix/io/plugins/ctf.py Outdated Show resolved Hide resolved
Comment on lines 201 to 214
0: [
"phase_id",
"x",
"y",
"bands",
"error",
"euler1",
"euler2",
"euler3",
"MAD", # Mean angular deviation
"BC", # Band contrast
"BS", # Band Slope
],
},
Copy link
Member

Choose a reason for hiding this comment

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

The columns are the same in the Bruker CTF files I have access to.

examples/plotting/interactive_IPF.py Outdated Show resolved Hide resolved
@hakonanes
Copy link
Member

@IMBalENce, do you think we could finish this work? If you don't have time, no worries, I can look at finishing myself.

@IMBalENce
Copy link
Contributor Author

@hakonanes Sorry for taking so long. It was a bit hectic lately. I'll do my best to work this out in two weeks.

@hakonanes
Copy link
Member

No problem! I've been off development myself lately.

@ondrolexa ondrolexa mentioned this pull request Dec 4, 2023
7 tasks
@IMBalENce
Copy link
Contributor Author

@hakonanes I tried my best to address each of your comments. I think most should be ok now.

I also found some issue in running pytest and can get stuck in test_io.test_load_unsupported_format. To pass all test, I temporarily comment out this section. I was wondering what would be the best practice here?

Additionally, I'm still working on the test coverage on this ctf reader. I'm hoping to complete it in a day or two.

@hakonanes
Copy link
Member

I also found some issue in running pytest and can get stuck in test_io.test_load_unsupported_format.

By stuck, do you mean that pytest hangs? Or that you get an error? It would be great if you could open an issue. We'd be much closer to a solution, then!

@pc494 pc494 mentioned this pull request Mar 26, 2024
5 tasks
@CSSFrancis
Copy link
Member

CSSFrancis commented Mar 26, 2024

Any movement on this lately? I can take a shot at debugging the failing test if that is helpful. Is that that only thing that is blocking this from merging?

@CSSFrancis
Copy link
Member

@IMBalENce The failing test is related to the fact that there used to be a warning for trying to read a .ctf file.
(And now you can!)

@IMBalENce
Copy link
Contributor Author

@CSSFrancis Sorry for the delay in moving this forward again. Thank you for the tips. I'm testing it now. Will get it back soon.

@hakonanes
Copy link
Member

I'm ready to help and review, btw.

@hakonanes
Copy link
Member

@IMBalENce, I'm looking over the PR now. I have a few suggestions for changes. I'll make a PR to your branch if that's OK.

@hakonanes hakonanes added this to the v0.13.0 milestone Apr 25, 2024
@hakonanes hakonanes changed the title Add ctf file reader and interactive IPF example Add CTF file reader and interactive crystal map plot example Apr 25, 2024
@IMBalENce
Copy link
Contributor Author

@IMBalENce, I'm looking over the PR now. I have a few suggestions for changes. I'll make a PR to your branch if that's OK.

Thank you @hakonanes. Have just merged your changes.

@hakonanes
Copy link
Member

hakonanes commented May 11, 2024

This should now be done. Could you have a brief look at my latest changes, @IMBalENce? These are the changes since you merged my PR to your branch: 2b3b7f0...a68d37e.

@hakonanes hakonanes mentioned this pull request May 11, 2024
5 tasks
Copy link
Member

@hakonanes hakonanes left a comment

Choose a reason for hiding this comment

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

The CTF reader should now be able to read files created by Oxford Instruments, Bruker, ASTAR, EMsoft, and MTEX.

Note, I've contributed code to this PR myself, so a second look my another maintainer would be appreciated.

@IMBalENce
Copy link
Contributor Author

Thank you, @hakonanes. It looks great!

@hakonanes hakonanes merged commit 006e85d into pyxem:develop May 13, 2024
13 checks passed
@hakonanes
Copy link
Member

Fantastic, thanks for having a look, @IMBalENce!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to the documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants