os.path.join(HERE, "test_data", "v_a_20180810_13_1_0_1.fits.gz[10]")) # Create some bad data some_bad_data = copy.copy(image_fits.data) len_x, len_y = image_fits.data.shape random_x = np.random.choice(np.arange(len_x), size=10, replace=False) random_y = np.random.choice(np.arange(len_y), size=10, replace=False) for i, j in zip(random_x, random_y): some_bad_data[i, j] += 1e10 # Add a bad pixel on the spectrum some_bad_data[130, 500] += 1e10 cmask, _ = util.create_cutoff_mask(image_fits.data, cutoff=1000) bmask, _ = util.create_bad_pixel_mask(image_fits.data) bad_mask = bmask & bmask def test_add_bad_pixel_mask_numpy_array(): twodspec = spectral_reduction.TwoDSpec(log_file_name=None) twodspec.add_bad_mask(bad_mask) def test_add_bad_pixel_mask_hdu(): twodspec = spectral_reduction.TwoDSpec(log_file_name=None) twodspec.add_bad_mask(fits.ImageHDU(bad_mask.astype("int"))) def test_add_bad_pixel_mask_hdu_list(): twodspec = spectral_reduction.TwoDSpec(log_file_name=None)
def test_bad_mask_does_nothing(): bad_mask, _ = util.create_bad_pixel_mask(dummy_image) healed_image = util.bfixpix(dummy_image, bad_mask, retdat=True) assert np.sum(healed_image) == dummy_sum
def test_bad_mask_list(): bad_mask, _ = util.create_bad_pixel_mask(dummy_image_none) healed_image = util.bfixpix(dummy_image, bad_mask, retdat=True) assert np.sum(healed_image) == np.size(dummy_image_none)
def test_bad_mask_does_nothing_grow_none(): bad_mask, _ = util.create_bad_pixel_mask( dummy_image, grow=True, diagonal=True ) healed_image = util.bfixpix(dummy_image, bad_mask, retdat=False) assert np.sum(healed_image) is None
def test_bad_mask_grow(): bad_mask, _ = util.create_bad_pixel_mask( dummy_image_nan, grow=True, diagonal=True ) healed_image = util.bfixpix(dummy_image, bad_mask, retdat=True) assert np.sum(healed_image) == np.size(dummy_image)
def test_bad_mask_1D_array(): util.create_bad_pixel_mask(np.ones(100))