fix(std_daq): prevent division by zero in flat correction
This commit is contained in:
@@ -148,3 +148,25 @@ def test_std_daq_live_processing_apply_flat_dark_correction_with_dark(std_daq_li
|
||||
assert isinstance(corrected_image, np.ndarray)
|
||||
assert corrected_image.shape == (100, 100)
|
||||
assert np.all(corrected_image >= 0), "Corrected image should not have negative values"
|
||||
|
||||
|
||||
def test_std_daq_live_processing_apply_flat_correction_zero_division(std_daq_live_processing):
|
||||
|
||||
# Create a mock image
|
||||
image = np.random.rand(100, 100) * 1000 + 10 # Scale to simulate a realistic image
|
||||
|
||||
# Set flat reference with epsilon values
|
||||
flat = np.ones((100, 100)) * 2
|
||||
std_daq_live_processing.references["flat_(100, 100)"] = flat
|
||||
|
||||
# Set dark reference to ones
|
||||
dark = np.ones((100, 100)) * 2
|
||||
|
||||
std_daq_live_processing.references["dark_(100, 100)"] = dark
|
||||
|
||||
# Apply flat correction
|
||||
corrected_image = std_daq_live_processing.apply_flat_dark_correction(image)
|
||||
assert isinstance(corrected_image, np.ndarray)
|
||||
assert corrected_image.shape == (100, 100)
|
||||
assert np.all(corrected_image >= 0), "Corrected image should not have negative values"
|
||||
assert np.any(corrected_image < np.inf), "Corrected image should not have infinite values"
|
||||
|
||||
Reference in New Issue
Block a user