Update hyperspectral calibration function #845
Merged
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.
Describe your changes
In evaluating
pcv.hyperspectral.calibrate
to address #843, a couple issues were found.First, the original function was written assuming that the shape of the input dark and white reference images was (1, x, z) since this matched the data we worked with. @JorgeGtz noted that reference data provided in #843 had the shape (100, x, z), which caused the "memory" errors. To normalize the process for reference images with different numbers of line scans, the function is updated to average the lines (axis=0) and convert all reference inputs to the shape (1, x, z), which can be broadcast over the raw data cube shape.
Second, we realized that the calibration was done in two stages that were not connected, resulting in incorrectly calibrated output. The function was updated/simplified to do the calibration in a single vectorized operation.
Third, because calibrated values can be negative or greater than 1, we added a step to clip the values to the range 0-1. We confirmed that the resulting calibrated data are very similar to data calibrated by the manufacturer.
Last, we updated the function to utilize the
_debug
module.Type of update
Is this a: Bug fix
Associated issues
Closes #843