Bug fix for isolated bad pixel correction algorithm in full_output mode
@@ -34,7 +34,7 @@ except ImportError:
def frame_fix_badpix_isolated(array, bpm_mask=None, sigma_clip=3, num_neig=5,
size=5, protect_mask=False, radius=30, cxy=None,
- mad=True, verbose=True, full_output=False):
+ mad=False, verbose=True, full_output=False):
""" Corrects the bad pixels, marked in the bad pixel mask. The bad pixel is
replaced by the median of the adjacent pixels. This function is very fast
but works only with isolated (sparse) pixels.
@@ -222,7 +222,7 @@ def cube_fix_badpix_isolated(array, bpm_mask=None, sigma_clip=3, num_neig=5,
array_out = array.copy()
if full_output:
- bpm_mask = array_out.copy()
+ final_bpm = array_out.copy()
n_frames = array.shape[0]
count_bp = 0
if frame_by_frame:
@@ -232,16 +232,14 @@ def cube_fix_badpix_isolated(array, bpm_mask=None, sigma_clip=3, num_neig=5,
for i in Progressbar(range(n_frames), desc="processing frames"):
res = frame_fix_badpix_isolated(array[i], bpm_mask=bpm_mask,
sigma_clip=sigma_clip,
- num_neig=num_neig,
- size=size,
+ num_neig=num_neig, size=size,
protect_mask=protect_mask,
- radius=radius,
- verbose=False,
+ radius=radius, verbose=False,
cxy=(cx[i],cy[i]),
full_output=full_output)
if full_output:
array_out[i] = res[0]
- bpm_mask[i] = res[1]
+ final_bpm[i] = res[1]
else:
array_out[i] = res
if verbose:
@@ -251,19 +249,19 @@ def cube_fix_badpix_isolated(array, bpm_mask=None, sigma_clip=3, num_neig=5,
if bpm_mask is None:
ind = clip_array(np.mean(array, axis=0), sigma_clip, sigma_clip,
neighbor=neigh, num_neighbor=num_neig, mad=mad)
- bpm_mask = np.zeros_like(array[0])
- bpm_mask[ind] = 1
+ final_bpm = np.zeros_like(array[0])
+ final_bpm[ind] = 1
if protect_mask:
- cir = disk((cy, cx), radius, shape=bpm_mask.shape)
- bpm_mask[cir] = 0
- bpm_mask = bpm_mask.astype('bool')
+ cir = disk((cy, cx), radius, shape=final_bpm.shape)
+ final_bpm[cir] = 0
+ final_bpm = final_bpm.astype('bool')
for i in Progressbar(range(n_frames), desc="processing frames"):
frame = array_out[i]
smoothed = median_filter(frame, size, mode='mirror')
- frame[np.where(bpm_mask)] = smoothed[np.where(bpm_mask)]
+ frame[np.where(final_bpm)] = smoothed[np.where(final_bpm)]
if verbose:
- count_bp+=np.sum(bpm_mask)
+ count_bp+=np.sum(final_bpm)
if verbose:
msg = "Done replacing {} bad pixels using the median of neighbors"
@@ -271,7 +269,7 @@ def cube_fix_badpix_isolated(array, bpm_mask=None, sigma_clip=3, num_neig=5,
timing(start)
if full_output:
- return array_out, bpm_mask
+ return array_out, final_bpm
else:
return array_out
