Repository navigation
Fix get_map_data() and slicing for crystal maps whose coordinates do not start at zero - #694
Open
aaronkanzer wants to merge 1 commit into
Open
aaronkanzer wants to merge 1 commit into
aaronkanzer wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CrystalMap.get_map_data()and slicing assume the map's x and y coordinates start at 0. If they start anywhere else, columns or rows are silently dropped, or the result is an empty array. This happens with an .ang file exported for a region of interest that keeps its original coordinates, or with a map built from stage coordinates.Observed on 0.15.0 and develop:
Expected: a (3, 4) array whose rows are all
[1. 2. 3. 4.].With an x origin of 10 and a step of 0.5,
get_map_data()returns shape (3, 0). Slicing (xmap[:2]) raisesValueError: could not broadcast input array from shape (3,4) into shape (3,0). The same happens afterorix.io.load()of an .ang file whose x column starts at 10.Cause:
CrystalMap._data_slices_from_coordinates()turns coordinates into array indices withround(c / step). Those indices are then used on arrays of the original map shape, so they are only correct when the smallest coordinate is 0.Fix: make the slices relative to the first point of the full map. Maps that start at 0 are unchanged. A regression test covers
get_map_data()and slicing on a map with an offset origin.