Esempio n. 1
0
if __name__ == "__main__":
    numpy.set_printoptions(threshold=numpy.inf)
    parser = argparse.ArgumentParser()
    parser.add_argument("datafile", type=str, help="data file for histrogram")
    parser.add_argument("-o",
                        "--outdir",
                        type=str,
                        help="directory to save plots")
    args = parser.parse_args()

    if not os.path.isdir(args.outdir):
        print("making directory: " + args.outdir)
        os.mkdir(args.outdir)

    header, data = albatrostools.get_data(args.datafile, 300000)
    print(header)
    print("finished reading file")

    print(data["spectrum_number"])

    pyplot.plot(data["spectrum_number"])
    pyplot.savefig(args.outdir + "/spectrum_number.png")
    pyplot.clf()

    pols = albatrostools.correlate(data["pol0"], data["pol1"])
    print("just after correlate")
    pol00 = numpy.absolute(pols["pol00"])**2
    pol11 = numpy.absolute(pols["pol11"])**2
    pol01 = pols["pol01"]
    del pols
Esempio n. 2
0
    fnames = sft.time2fnames(ctime_start, ctime_stop, opts.data_dir)
    if len(fnames) == 0:
        print 'No files found in time range'
        exit(0)

    pol00 = None
    pol11 = None
    pol01_mag = None
    pol01_phase = None
    tstamps = []
    for fname in fnames:
        print 'Reading', fname
        fname_sub = fname.split('/')[-1]
        tstamp = fname_sub.split('.')[0]
        tstamps.append(tstamp)
        header, data = albatrostools.get_data(fname, items=opts.readlen)
        if header['bit_mode'] == 1:
            plot_auto = False
        else:
            plot_auto = True
        fmin = header['channels'][0] * 125.0 / 2048
        fmax = header['channels'][-1] * 125.0 / 2048
        # print 'Data dimensions are:', nm.shape(data['pol0']), 'and', nm.shape(data['pol1'])
        ntime = nm.shape(data['pol0'])[0]
        nchan = nm.shape(data['pol0'])[1]
        freqs = nm.linspace(fmin, fmax, nchan)

        # Calculate auto and cross correlations
        corr = data['pol0'] * nm.conj(data['pol1'])
        # Append averaged data
        if opts.dsfac is True:
Esempio n. 3
0
    data_dir = "/data/cynthia/albatros/mars2019/baseband"
    #fnames =  sft.time2fnames(ctime_start, ctime_stop, data_dir)

    fnames = ["data/15632/1563273072.raw"]

    if len(fnames) == 0:
        print('No files found in time range')
        exit(0)
    else:
        print("we have", len(fnames), 'files')
    audio = np.array([])

    for fname in fnames:
        print("working on", fname)
        header, data = albatrostools.get_data(fname,
                                              items=-1,
                                              unpack_fast=False,
                                              float=True)
        print("unpacked")
        # pool = Pool(processes=n_cores)

        n_channels = header['channels'][-1]
        s_channel = header['channels'][0]
        #freq = np.linspace(0,(n_channels / 2048) * 128e6, n_channels)
        fs = 2 * n_channels * 125e6 / 2048
        time_stream = {'pol0': [], 'pol1': []}

        with get_context("spawn").Pool(processes=n_cores) as pool:
            time_stream['pol0'] = np.array(
                pool.map(do_inverse, [
                    (data['pol0'][x:x + (5 * items_per_core), :], n_channels,
                     s_channel) for x in range(0,
t_start = np.fromfile(froot + 'time_gps_start.raw', dtype='double')
t_stop = np.fromfile(froot + 'time_gps_stop.raw', dtype='double')

dt = t_stop - t_start
#dt=np.diff(t_start) #this seems be more accurate than t_stop-t_start
t_per_spec = 2048 * 2 / 250e6
nspec_approx = np.median(dt) / t_per_spec

items = -1
bin_size = np.int(nspec_approx)

for file_name in fnames:
    #print(file_name)
    t1 = time.time()
    header, stuff = albatrostools.get_data(file_name,
                                           unpack_fast=True,
                                           float=True,
                                           byte_delta=-8)
    t2 = time.time()
    spec0 = albatrostools.bin_autos(stuff['pol0'], bin_size)
    spec1 = albatrostools.bin_autos(stuff['pol1'], bin_size)
    #pol1_rollx=np.empty(stuff['pol1'].shape,dtype=stuff['pol1'].dtype)
    #pol1_rolly=np.empty(stuff['pol1'].shape,dtype=stuff['pol1'].dtype)
    #pol1_rollx[:]=np.roll(stuff['pol1'],1,axis=1)
    #pol1_rolly[:]=np.roll(stuff['pol1'],1,axis=0)
    spec01 = albatrostools.bin_crosses(stuff['pol1'], stuff['pol0'], bin_size)
    #spec01x=albatrostools.bin_crosses(stuff['pol0'],pol1_rollx,bin_size)
    #spec01y=albatrostools.bin_crosses(stuff['pol0'],pol1_rolly,bin_size)
    t3 = time.time()
    try:
        big_spec0 = np.append(big_spec0, spec0, axis=0)
        big_spec1 = np.append(big_spec1, spec1, axis=0)
Esempio n. 5
0
    if len(fnames) == 0:
        print 'No files found in time range'
        exit(0)

    pol00 = None
    pol11 = None
    pol01_mag = None
    pol01_phase = None
    tstamps = []
    
    for fname in fnames:
        print 'Reading', fname
        fname_sub = fname.split('/')[-1]
        tstamp = fname_sub.split('.')[0]
        tstamps.append(tstamp)
        header, data = albatrostools.get_data(fname, items=opts.readlen, unpack_fast=True, float=True)
        ##unpack using c code do not forget to compile that stuff first!



        if header['bit_mode'] == 1:
            plot_auto = False
        else:
            plot_auto = True
        fmin = header['channels'][0]*125.0/2048
        fmax = header['channels'][-1]*125.0/2048
        # print 'Data dimensions are:', nm.shape(data['pol0']), 'and', nm.shape(data['pol1'])
        ntime = nm.shape(data['pol0'])[0]
        nchan = nm.shape(data['pol0'])[1]
        freqs = nm.linspace(fmin, fmax, nchan)