Commit 530807b9 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Handle NaN in FlatField class

parent 56adb16a
......@@ -190,6 +190,12 @@ class FlatFieldArrays:
self._dark = dark
return self._dark
def remove_invalid_values(self, img):
if self.nan_value is None:
return
invalid_mask = np.logical_not(np.isfinite(img))
img[invalid_mask] = self.nan_value
def normalize_radios(self, radios):
"""
Apply a flat-field normalization, with the current parameters, to a stack
......@@ -211,6 +217,7 @@ class FlatFieldArrays:
if do_flats_distortion_correction:
flat = self.distortion_correction.estimate_and_correct(flat, radio_data)
radios[i] = radio_data / flat
self.remove_invalid_values(radios[i])
return radios
......@@ -225,6 +232,7 @@ class FlatFieldArrays:
if self.distortion_correction is not None:
flat = self.distortion_correction.estimate_and_correct(flat, radio)
radio /= flat
self.remove_invalid_values(radio)
return radio
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment