def test_phasedat_adev(self):
        # (s32_taus, s32_devs, s32_devs_lo, s32_devs_hi, s32_ns) = read_stable32( 'phase_dat_adev_octave.txt' , 1.0 )
        s32_rows = testutils.read_stable32("phase_dat_adev_octave.txt", 1.0)
        phase = testutils.read_datafile("PHASE.DAT")
        (taus, devs, errs, ns) = allan.adev(phase, taus=[s32["tau"] for s32 in s32_rows])

        # CI computation
        los = []
        his = []
        for (d, t, n) in zip(devs, taus, ns):
            # edf = greenhall_simple_edf( alpha=0, d=2, m=t, S=1, F=t, N=len(phase) )
            edf2 = allan.edf_greenhall(alpha=0, d=2, m=t, N=len(phase), overlapping=False, modified=False)
            (lo, hi) = allan.confidence_intervals(dev=d, ci=0.68268949213708585, edf=edf2)  # 0.68268949213708585
            # (lo2,hi2) = allan.confidence_intervals( dev=d, ci=0.68268949213708585, edf=edf2, use_scipy_chi2_ppf=False )
            # testutils.check_approx_equal(lo, lo2, tolerance=1e-4)
            # testutils.check_approx_equal(hi, hi2, tolerance=1e-4)

            # allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf')
            los.append(lo)
            his.append(hi)
        for (s32, t2, d2, lo2, hi2, n2) in zip(s32_rows, taus, devs, los, his, ns):
            print(
                "s32 %03d %03f %1.6f %1.6f %1.6f" % (s32["n"], s32["tau"], s32["dev_min"], s32["dev"], s32["dev_max"])
            )
            print("at  %03d %03f %1.6f %1.6f %1.6f" % (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            testutils.check_approx_equal(s32["dev_min"], lo2, tolerance=1e-3)
            testutils.check_approx_equal(s32["dev"], d2, tolerance=1e-4)
            testutils.check_approx_equal(s32["dev_max"], hi2, tolerance=1e-3)
            print("----")
 def test_adev_ci(self):
     s32rows = testutils.read_stable32(resultfile="adev_decade.txt", datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         (taus, devs, errs, ns) = allan.adev(data, rate=rate, taus=[row["tau"]])
         edf = allan.edf_greenhall(
             alpha=row["alpha"], d=2, m=row["m"], N=len(data), overlapping=False, modified=False, verbose=True
         )
         (lo, hi) = allan.confidence_intervals(devs[0], ci=0.68268949213708585, edf=edf)
         print("n check: ", testutils.check_equal(ns[0], row["n"]))
         print("dev check: ", testutils.check_approx_equal(devs[0], row["dev"]))
         print(
             "min dev check: ", lo, row["dev_min"], testutils.check_approx_equal(lo, row["dev_min"], tolerance=1e-3)
         )
         print(
             "max dev check: ", hi, row["dev_max"], testutils.check_approx_equal(hi, row["dev_max"], tolerance=1e-3)
         )
Example #3
0
def to_fractional(flist, f0):
    out = []
    for f in flist:
        out.append(f / float(f0) - 1.0)
    return out


fname = "gps_1pps_phase_data.txt.gz"
phase = read_datafile(fname, column=0)
print len(phase), " values read: ", len(phase) / 3600.0, " hours"

# f = to_fractional(f10MHz, 10e6 ) # convert to fractional frequency
my_taus = numpy.logspace(1, 6, 60)  # log-spaced tau values from 10s and upwards
rate = 1 / float(1.0)

(adev_taus, adev_devs, adev_errs, ns) = allan.adev(phase=phase, rate=rate, taus=my_taus)

(oadev_taus, oadev_devs, oadev_errs, ns) = allan.oadev(phase=phase, rate=rate, taus=my_taus)

(hdev_taus, hdev_devs, hdev_errs, ns) = allan.hdev(phase=phase, rate=rate, taus=my_taus)
(ohdev_taus, ohdev_devs, ohdev_errs, ns) = allan.ohdev(phase=phase, rate=rate, taus=my_taus)

(mdev_taus, mdev_devs, mdev_errs, ns) = allan.mdev(phase=phase, rate=rate, taus=my_taus)

(totdev_taus, totdev_devs, totdev_errs, ns) = allan.totdev(phase=phase, rate=rate, taus=my_taus)

(tie_taus, tie_devs, tie_errs, ns) = allan.tierms(phase=phase, rate=rate, taus=my_taus)
# (mtie_taus,mtie_devs,mtie_errs,ns)  = allan.mtie(phase=phase, rate=rate, taus=my_taus)

(tdev_taus, tdev_devs, tdev_errs, ns) = allan.tdev(phase=phase, rate=rate, taus=my_taus)
(tdev2_taus, tdev2_devs, tdev2_errs, ns2) = allan.tdev(
Example #4
0
data_file = "../tests/phasedat/PHASE.DAT"


def read_datafile(filename):
    p = []
    with open(filename) as f:
        for line in f:
            if not line.startswith("#"):  # skip comments
                p.append(float(line))
    return p


# read input data from file
phase = read_datafile(data_file)
# normal ADEV computation, giving naive 1/sqrt(N) errors
(taus, devs, errs, ns) = at.adev(phase, taus="octave")

# Confidence-intervals for each (tau,adev) pair separately.
cis = []
for (t, dev) in zip(taus, devs):
    # Greenhalls EDF (Equivalent Degrees of Freedom)
    # alpha     +2,...,-4   noise type, either estimated or known
    # d         1 first-difference variance, 2 allan variance, 3 hadamard variance
    #           we require: alpha+2*d >1     (is this ever false?)
    # m         tau/tau0 averaging factor
    # N         number of phase observations
    edf = at.edf_greenhall(alpha=0, d=2, m=t, N=len(phase), overlapping=False, modified=False)
    # with the known EDF we get CIs
    # for 1-sigma confidence we set
    # ci = scipy.special.erf(1/math.sqrt(2)) = 0.68268949213708585
    (lo, hi) = at.confidence_intervals(dev=dev, ci=0.68268949213708585, edf=edf)
def test_zero_rate():
    with pytest.raises(RuntimeError):
        at.adev(d, rate=0.0)
def test_tau_generator_numpy1234():
    wanted_taus = np.array([1, 2, 3, 4])
    (taus_used, adev, adeverror, adev_n) = at.adev(d, rate=r, taus=wanted_taus)
    np.testing.assert_array_equal(taus_used, wanted_taus)
def test_tau_generator_decade():
    (taus_used, adev, adeverror, adev_n) = at.adev(d, rate=r, taus="decade")
    np.testing.assert_array_equal(taus_used, expected_decade)
def test_tau_generator_empty_list():
    (taus_used, adev, adeverror, adev_n) = at.adev(d, taus=[])
    np.testing.assert_array_equal(taus_used, expected_octave)