Neighbor based analysing tool - #642
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Thank you @Tagebh, the functionality in your comment will be very useful to have in orix! When adding your own commits, can you use the develop branch as the target branch here in the orix repo? |
|
Hey @hakonanes I changed the PR so it commits to the developer branch, and I added the code to orix/crystal_map/_neighbors.py. I also made the PR ready for review |
|
Great, thank you! Just to confirm, is it fine with you if I push to your branch? I plan to push stuff like tests, documentation, and perhaps some restructuring of your file. Alternatively, I can make a PR to the develop branch in your fork, so you can go through my suggested changes before being visible here. |
|
@hakonanes and @Tagebh , do either of you care if I try tackling this actually? Same comment as @hakonanes, making pushes directly to the original branch. @hakonanes, if you've already started, ignore this comment, there are plenty of other things for me to do in ORIX. Also, general question: how do we feel about this pattern of keeping all the neighborhood functions in a |
|
@argerlt, as for me you are more than welcome to tackle this problem if you want to. I don't really know if @hakonanes has started or not, so it's probably best to wait for him to answer as well. I feel like that it's natural to add new neighborhood functions into |
|
@Tagebh, sorry this took so long, thank you for your patience. Some starting notes:
to something like this:
|
for more information, see https://pre-commit.ci
|
^ If you click on pre-commit.ci's commit above, you can see what rules it enforced. |
|
@Tagebh, I added some comments and suggested changes as a review, feel free to ask for clarification or suggest alternatives. Also, once these changes are made, you/we will need to write unit tests and examples. |
|
As discussed off GitHub, @argerlt, I think the public API from this PR should be the kernel average misorientation calculation only. How we handle the other functions internally is then of secondary nature, thankfully. We can look to make more functions public afterwards, if needed. |
|
And it's my understanding from @Tagebh that you can make changes to his branch directly. |
|
@argerlt, if you don't have time, I can wrap this up. Up to you. |
Co-authored-by: Austin Gerlt <argerlt@gmail.com>
Went from reviewer to writer, so "approving" this feels a bit too much like skipping review all together
|
@hakonanes , sorry this took me a bit to get back around to. I swapped the functions around amd resolved my own review comments. I'll finish up some changes and documentation, then ping you when this is ready for review. |
|
Sounds good. |
Description of the change
I am currently working on hybrid indexing as part of my master at NTNU, and I also wrote a project thesis on hybrid indexing in the autumn of last year, where I used the hybrid indexing tutorial made på Håkon as a starting point. As part of this work I have made a Kernel Average Misorientation (KAM) tool based on the code from @argerlt in issue #531.
Progress of the PR
I have structured the code so it has the potential to be used for many things involving neighbors (not only KAM).
The Neighbors() function performs the general preperations to do neighbor-based calculations on a xmap or any 2d array really, and can be used on it's own to do whatever you want with neighbors.
The neighbor_misorientation() and KAM_calc() then uses Neighbors() to make a KAM map.
I have also included a slight variation of KAM which I am calling Number of Same Neighbors, which also uses the results from Neighbors() and neighbor_misorientation() but does a slightly different calculation. A user defines what degree of misorientation that counts as a "different" orientation, and then it counts how many neighbors has the same orientation as a central point, where each point in the dataset acts as a central point once.
Here is the functions as .py file
_neighbors.py
The reulting KAM and NDN (Number of different neigbors (NDN) = total neighbors - NSN) map using a 3x3 binary kernel (8 neighbors with equal weighting) could look something like this (using one of the nickel datasets already in kikuchipy):
I have also made a small jupyter notebook that I used to test the functions
test_neighbors.ipynb
Here is an example from that notebook where the amount of equal colored neighbors is counted in a small dummy dataset
The output with a 3x3 binary footprint

The output when the footprint is 3x3 and not binary (0.5 in the corners)

I do not have any experience with git hub, so I do not really know how to impliment it, but I hope this seems usefull and that someone wants to pick it up.
Kind regards
Tage
For reviewers
__init__.py.section in
CHANGELOG.rst.__credits__inorix/__init__.pyand in.zenodo.json.