Exemple #1
0
    allrms2 = []

    for P in range(20):
        file1 = file_fmt.format(S=0, P=P)
        file2 = file_fmt.format(S=1, P=P)
        print('Reading from {}\n         and {}'.format(file1, file2))

        with open(file1, 'rb', recsize*itemsize) as fh1, \
             open(file2, 'rb', recsize*itemsize) as fh2:
            rms1 = []
            rms2 = []
            while True:
                try:
                    # data stored as series of floats in two files,
                    # one for real and one for imaginary
                    raw1 = fromfile(fh1, dtype, recsize).reshape(-1,nchan)
                    raw2 = fromfile(fh2, dtype, recsize).reshape(-1,nchan)
                except(EOFError, ValueError):
                    break
                rms1.append(raw1.std(0))
                rms2.append(raw2.std(0))
                print("rms1,2 = {}, {}".format(rms1[-1],rms2[-1]))

            allrms1 += rms1
            allrms2 += rms2

            out1 = file1.split("/")[-1].replace(".raw","_rms.npy")
            np.save(out1, np.array(rms1))
            out2 = file2.split("/")[-1].replace(".raw","_rms.npy")
            np.save(out2, np.array(rms2))
Exemple #2
0
            from pulsar.predictor import Polyco

            polyco_file = get_pkg_data_filename(phasepol)
            polyco = Polyco(polyco_file)
            phasepol = polyco.phasepol(time0,
                                       rphase='fraction',
                                       t0=time0,
                                       time_unit=u.second,
                                       convert=True)
            nskip = int(
                round(
                    ((Time('2013-07-25T22:15:00', scale='utc') - time0) /
                     (recsize * 2 / samplerate)).to(u.dimensionless_unscaled)))
            if verbose:
                print("Using start time {0} and phase polynomial {1}".format(
                    time0, phasepol))
                print("Skipping {0} records and folding {1} records to cover "
                      "time span {2} to {3}".format(
                          nskip, nt, time0 + nskip * recsize * 2 / samplerate,
                          time0 + (nskip + nt) * recsize * 2 / samplerate))

            fh1.seek(nskip * recsize)
            rms = []
            for j in range(nt):
                raw = fromfile(fh1, '4bit', recsize)
                rms.append(raw.reshape(-1, 1024).std(1))
                print("Set {}, rms_min,max={}, {}".format(
                    j, rms[-1].min(), rms[-1].max()))
        rms = np.hstack(rms)
        np.save('aro_rms.npy', rms)
Exemple #3
0
        if not isinstance(phasepol, Polynomial):
            from astropy.utils.data import get_pkg_data_filename
            from pulsar.predictor import Polyco

            polyco_file = get_pkg_data_filename(phasepol)
            polyco = Polyco(polyco_file)
            phasepol = polyco.phasepol(time0, rphase='fraction', t0=time0,
                                       time_unit=u.second, convert=True)
            nskip = int(round(
                ((Time('2013-07-25T22:15:00', scale='utc') - time0) /
                 (recsize * 2 / samplerate)).to(u.dimensionless_unscaled)))
            if verbose:
                print("Using start time {0} and phase polynomial {1}"
                      .format(time0, phasepol))
                print("Skipping {0} records and folding {1} records to cover "
                      "time span {2} to {3}"
                      .format(nskip, nt,
                              time0 + nskip * recsize * 2 / samplerate,
                              time0 + (nskip+nt) * recsize * 2 / samplerate))

            fh1.seek(nskip * recsize)
            rms = []
            for j in range(nt):
                raw = fromfile(fh1, '4bit', recsize)
                rms.append(raw.reshape(-1, 1024).std(1))
                print("Set {}, rms_min,max={}, {}".format(j, rms[-1].min(),
                                                      rms[-1].max()))
        rms = np.hstack(rms)
        np.save('aro_rms.npy', rms)
Exemple #4
0
    allrms2 = []

    for P in range(20):
        file1 = file_fmt.format(S=0, P=P)
        file2 = file_fmt.format(S=1, P=P)
        print('Reading from {}\n         and {}'.format(file1, file2))

        with open(file1, 'rb', recsize*itemsize) as fh1, \
             open(file2, 'rb', recsize*itemsize) as fh2:
            rms1 = []
            rms2 = []
            while True:
                try:
                    # data stored as series of floats in two files,
                    # one for real and one for imaginary
                    raw1 = fromfile(fh1, dtype, recsize).reshape(-1, nchan)
                    raw2 = fromfile(fh2, dtype, recsize).reshape(-1, nchan)
                except (EOFError, ValueError):
                    break
                rms1.append(raw1.std(0))
                rms2.append(raw2.std(0))
                print("rms1,2 = {}, {}".format(rms1[-1], rms2[-1]))

            allrms1 += rms1
            allrms2 += rms2

            out1 = file1.split("/")[-1].replace(".raw", "_rms.npy")
            np.save(out1, np.array(rms1))
            out2 = file2.split("/")[-1].replace(".raw", "_rms.npy")
            np.save(out2, np.array(rms2))