Пример #1
0
def test_fits_to_fil():
    # from fits
    file = os.path.join(_install_dir, "data/small.fits")
    f = Your(file)
    w = Writer(f,
               nstart=0,
               nsamp=1,
               outname="temp",
               outdir="./",
               c_min=0,
               c_max=200)
    # test with outname
    w.to_fil()
    assert os.path.isfile("temp.fil")
    y = Your("temp.fil")
    assert y.your_header.nspectra == 1
    assert y.your_header.nchans == 200
    assert (y.get_data(0, 1) - f.get_data(0, 1)[:, 0:200]).sum() == 0
    os.remove("temp.fil")

    # test without outname
    w = Writer(f, outdir="./")
    w.to_fil()
    assert os.path.isfile("small_converted.fil")
    y = Your("small_converted.fil")
    assert y.your_header.nspectra == f.your_header.nspectra
    ns = y.your_header.nspectra
    assert y.your_header.nchans == f.your_header.nchans
    assert (y.get_data(0, ns) - f.get_data(0, ns)).sum() == 0
    os.remove("small_converted.fil")
Пример #2
0
def test_gulps(your_object):
    w = Writer(
        your_object,
        nstart=1,
        nsamp=2,
        gulp=2,
        outname="temp",
        c_min=10,
        c_max=200,
        outdir="./",
    )
    w.to_fil()
    assert os.path.isfile("temp.fil")

    w = Writer(
        your_object,
        nstart=1,
        nsamp=5,
        gulp=20,
        outname="temp",
        c_min=10,
        c_max=200,
        outdir="./",
    )
    w.to_fil()
    assert os.path.isfile("temp.fil")
    os.remove("temp.fil")
Пример #3
0
def test_fil_to_fil(your_object):
    # from fil
    w = Writer(
        your_object,
        nstart=1,
        nsamp=2,
        outname="temp",
        c_min=10,
        c_max=200,
        outdir="./",
        flag_rfi=False,
        zero_dm_subt=False,
    )
    # test with outname
    w.to_fil()
    assert os.path.isfile("temp.fil")
    y = Your("temp.fil")
    assert y.your_header.nspectra == 2
    assert y.your_header.nchans == 190
    assert (y.get_data(0, 2) -
            your_object.get_data(1, 2)[:, 10:200]).sum() == 0
    os.remove("temp.fil")

    # test without outname
    w = Writer(your_object, nstart=0, nsamp=10, outdir="./", flag_rfi=True)
    w.to_fil()
    assert os.path.isfile("small_converted.fil")
    y = Your("small_converted.fil")
    assert y.your_header.nspectra == 10
    assert y.your_header.nchans == your_object.your_header.nchans
    os.remove("small_converted.fil")
Пример #4
0
def test_fil_to_fil():
    # from fil
    file = os.path.join(_install_dir, 'data/small.fil')
    f = Your(file)
    w = Writer(f)
    # test with outname
    w.to_fil(nstart=0,
             nsamp=2,
             outname='temp.fil',
             c=[0, 200],
             outdir='./',
             flag_rfi=True,
             zero_dm_subt=True)
    assert os.path.isfile('temp.fil')
    y = Your('temp.fil')
    assert y.your_header.nspectra == 2
    assert y.your_header.nchans == 200
    os.remove('temp.fil')

    # test without outname
    w.to_fil(nstart=0, nsamp=1, outdir='./')
    assert os.path.isfile('small_converted.fil')
    y = Your('small_converted.fil')
    assert y.your_header.nspectra == 1
    assert y.your_header.nchans == f.your_header.nchans
    os.remove('small_converted.fil')
Пример #5
0
        logging.info("Argument %s: %r", arg, value)
    y = Your(values.files)
    w = Writer(y)

    if values.type == 'fits':
        w.to_fits(c=values.chans,
                  nstart=values.nstart,
                  nsamp=values.nsamp,
                  outdir=values.outdir,
                  outname=values.out_name,
                  progress=values.no_progress,
                  flag_rfi=values.flag_rfi,
                  sk_sig=values.sk_sig,
                  sg_fw=values.sg_fw,
                  sg_sig=values.sg_sig,
                  zero_dm_subt=values.zero_dm_subt)
    elif values.type == 'fil':
        w.to_fil(c=values.chans,
                 nstart=values.nstart,
                 nsamp=values.nsamp,
                 outdir=values.outdir,
                 outname=values.out_name,
                 progress=values.no_progress,
                 flag_rfi=values.flag_rfi,
                 sk_sig=values.sk_sig,
                 sg_fw=values.sg_fw,
                 sg_sig=values.sg_sig,
                 zero_dm_subt=values.zero_dm_subt)
    else:
        raise ValueError("Type can either be 'fits' or 'fil'")
Пример #6
0
            )

    logging.info("Input Arguments:-")
    for arg, value in sorted(vars(values).items()):
        logging.info("Argument %s: %r", arg, value)
    y = Your(values.files)
    w = Writer(
        y,
        c_min=values.chans[0],
        c_max=values.chans[1],
        nstart=values.nstart,
        nsamp=values.nsamp,
        outdir=values.outdir,
        outname=values.out_name,
        progress=values.no_progress,
        flag_rfi=values.flag_rfi,
        spectral_kurtosis_sigma=values.spectral_kurtosis_sigma,
        savgol_frequency_window=values.savgol_frequency_window,
        savgol_sigma=values.savgol_sigma,
        zero_dm_subt=values.zero_dm_subt,
        time_decimation_factor=values.time_decimation_factor,
        frequency_decimation_factor=values.frequency_decimation_factor,
    )

    if values.type == "fits":
        w.to_fits()
    elif values.type == "fil":
        w.to_fil()
    else:
        raise ValueError("Type can either be 'fits' or 'fil'")