Skip to content

Commit

Permalink
Added tests for kill_mask and rfi_mask
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijAggarwal committed Feb 3, 2021
1 parent 515b880 commit da4a89d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,45 @@ def test_resize(cand):
cand.resize("at", size=200, axis=1, anti_aliasing=True, mode="constant")
except AttributeError:
pass

def test_rfi_mask():
fil_file = os.path.join(_install_dir, "data/28.fil")
cand = Candidate(
fp=fil_file,
dm=475.28400,
tcand=2.0288800,
width=2,
label=-1,
snr=16.8128,
min_samp=256,
device=0,
spectral_kurtosis_sigma=4,
savgol_frequency_window=15,
savgol_sigma=4,
flag_rfi=True,
)
cand.get_chunk()
assert cand.data[:, cand.rfi_mask].sum() == 0
assert cand.data[:, 172:177].sum() == 0
assert cand.data[:, ~cand.rfi_mask].sum() != 0

def test_kill_mask():
fil_file = os.path.join(_install_dir, "data/28.fil")
km = np.zeros(336, dtype='bool')
km[[10, 12, 25, 100, 300]] = True
cand = Candidate(
fp=fil_file,
dm=475.28400,
tcand=2.0288800,
width=2,
label=-1,
snr=16.8128,
min_samp=256,
device=0,
flag_rfi=False,
kill_mask=km
)
cand.get_chunk()
assert cand.data[:, cand.kill_mask].sum() == 0
assert cand.data[:, [10, 12, 300]].sum() == 0
assert cand.data[:, ~cand.kill_mask].sum() != 0

0 comments on commit da4a89d

Please sign in to comment.