Exemple #1
0
def test_gpu_dedisp_dmt_crop():
    file = os.path.join(_install_dir, 'data/28.fil')
    cand = Candidate(fp=file,
                     dm=10,
                     tcand=2.0288800,
                     width=2,
                     label=-1,
                     snr=16.8128,
                     min_samp=256,
                     device=0)
    cand.get_chunk()
    cand = gpu_dedisp_and_dmt_crop(cand)
    g_dmt = cand.dmt
    g_dedisp = cand.dedispersed
    assert cand.dedispersed.shape[0] == 256
    assert cand.dmt.shape[1] == 256

    cand.dedisperse()
    cand.dmtime()
    crop_start_sample_ft = cand.dedispersed.shape[0] // 2 - 256 // 2
    crop_start_sample_dmt = cand.dmt.shape[1] // 2 - 256 // 2
    c_dmt = crop(cand.dmt, crop_start_sample_dmt, 256, 1)
    c_dedisp = crop(cand.dedispersed, crop_start_sample_ft, 256, 0)

    assert np.isclose(np.sum(g_dmt - c_dmt), 0, atol=1)
    assert np.isclose(np.sum(g_dedisp - c_dedisp), 0, atol=1)
Exemple #2
0
def test_candidate_chunk_and_dedispersion():
    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)
    cand.get_chunk()
    assert np.isclose(np.mean(cand.data), 128, atol=1)
    cand.dedisperse()
    assert np.isclose(np.max(cand.dedispersed.T.sum(0)), 47527, atol=1)
    assert np.isclose(np.max(cand.dedispersets()), 47527, atol=1)
    cand.dmtime()
    assert cand.dmt.shape[0] == 256
    fnout = cand.save_h5()
    assert os.path.isfile(fnout)
    os.remove(fnout)
Exemple #3
0
def test_gpu_dmt():
    file = os.path.join(_install_dir, 'data/28.fil')
    cand = Candidate(fp=file,
                     dm=10,
                     tcand=2.0288800,
                     width=2,
                     label=-1,
                     snr=16.8128,
                     min_samp=256,
                     device=0)
    cand.get_chunk()
    cand.dmtime(target='GPU')
    g_dmt = cand.dmt
    cand.dmtime(target='CPU')
    c_dmt = cand.dmt
    assert cand.dmt.shape[0] == 256
    assert np.isclose(np.mean(g_dmt - c_dmt), 0, atol=1)
    assert np.max(g_dmt - c_dmt) / np.max(g_dmt) < 0.05