Fix energy_correction wavelength shape bug#957
Open
psavery wants to merge 3 commits into
Open
Conversation
…elength This issue only uccrs when a wavelength correction was being applied, via the beam energy correction features. objFuncFitGrain reshapes tVec_c to (3, 1), so tvec_c[ind] (and tvec_s[ind]) returned a length-1 array rather than a scalar. That made the corrected wavelength a (1,) array, which oscill_angles_of_hkls interpreted as a per-reflection wavelength array (1 value vs N hkls), producing NaN angles and a spurious "Infeasible parameters for hkls" RuntimeError whenever energy_correction was set (even with slope=0). Ravel tvec_c/tvec_s so position is a scalar and the corrected wavelength keeps the input's dimensionality. Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
getHKLID may return a list, so `active_hklIDs == input_hklID` is a scalar that np.where() rejects. Wrap it in np.asarray. Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
apply_correction_to_wavelength now np.ravel()s tvec_s, so the env fixture must provide a real instr.tvec (np.zeros(3)); a bare MagicMock ravels to an empty array -> IndexError. Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #957 +/- ##
=======================================
Coverage 73.55% 73.55%
=======================================
Files 148 148
Lines 22915 22915
=======================================
Hits 16855 16855
Misses 6060 6060 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Overview
This issue only occurs when a wavelength correction was being applied, via the beam energy correction features.
objFuncFitGrain reshapes tVec_c to (3, 1), so tvec_c[ind] (and tvec_s[ind]) returned a length-1 array rather than a scalar. That made the corrected wavelength a (1,) array, which oscill_angles_of_hkls interpreted as a per-reflection wavelength array (1 value vs N hkls), producing NaN angles and a spurious "Infeasible parameters for hkls" RuntimeError whenever energy_correction was set (even with slope=0). Ravel tvec_c/tvec_s so position is a scalar and the corrected wavelength keeps the input's dimensionality.
Affected Workflows
HEDM
Documentation Changes
None