예제 #1
0
 def test_phasedat_tdev(self):
     s32_rows = testutils.read_stable32( 'phase_dat_tdev_octave.txt' , 1.0 )
     phase = testutils.read_datafile('PHASE.DAT')
     (taus,devs,errs,ns) = allan.tdev(phase, taus=[s32['tau'] for s32 in s32_rows])
     
     # CI computation
     # alhpa= +2,...,-4   noise power
     # d= 1 first-difference variance, 2 allan variance, 3 hadamard variance
     # alpha+2*d >1
     # m = tau/tau0 averaging factor
     # N number of phase obs
     los=[]
     his=[]
     for (d,t, n) in zip(devs, taus, ns):
         edf2 = allan.edf_greenhall( alpha=0, d=2, m=int(t), N=len(phase), overlapping = True, modified=True  )
         # covert to mdev
         # tdev = taus * mdev / np.sqrt(3.0)
         mdev = d/t*np.sqrt(3.0)
         (lo,hi) = allan.confidence_interval( dev=mdev, edf=edf2 )
         # convert back to tdev
         lo = t*lo/np.sqrt(3.0)
         hi = t*hi/np.sqrt(3.0)
         los.append(lo)
         his.append(hi)
     print("tdev()")
     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_max'], hi2, tolerance=1e-3)
     print("----")
예제 #2
0
    def test_phasedat_totdev(self):
        s32_rows = testutils.read_stable32('phase_dat_totdev_octave.txt', 1.0)
        phase = testutils.read_datafile('PHASE.DAT')
        (taus, devs, errs,
         ns) = allan.totdev(phase, taus=[s32['tau'] for s32 in s32_rows])

        los = []
        his = []
        for (d, t, n) in zip(devs, taus, ns):
            #edf = greenhall_simple_edf( alpha=0, d=3, m=t, S=1, F=t, N=len(phase) )
            #edf2 = greenhall_edf( alpha=0, d=3, m=int(t), N=len(phase), overlapping = True, modified=False  )
            #print(edf,edf2,edf2/edf)
            edf = allan.edf_totdev(len(phase), t, alpha=0)
            (lo, hi) = allan.confidence_interval(dev=d, edf=edf)
            #allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf')
            los.append(lo)
            his.append(hi)
        print("totdev()")
        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_max'], hi2, tolerance=1e-3)
        print("----")
예제 #3
0
 def slow_failing_phasedat_mtotdev(self):
     s32_rows = testutils.read_stable32( 'phase_dat_mtotdev_octave_alpha0.txt' , 1.0 )
     phase = testutils.read_datafile('PHASE.DAT')
     (taus,devs,errs,ns) = allan.mtotdev(phase, taus=[s32['tau'] for s32 in s32_rows])
     
     los=[]
     his=[]
     for (d,t, n) in zip(devs, taus, ns):
         #edf = greenhall_simple_edf( alpha=0, d=3, m=t, S=1, F=t, N=len(phase) )
         if int(t)<10:
             edf = allan.edf_greenhall( alpha=0, d=2, m=int(t), N=len(phase), overlapping = True, modified=True  )
         else:
             edf = allan.edf_mtotdev(len(phase), t, alpha=0)
         #print edf, edf2
         #print(edf,edf2,edf2/edf)
         
         print(edf)
         (lo,hi) = allan.confidence_interval( dev=d, edf=edf )
         #allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf')
         los.append(lo)
         his.append(hi)
     print("mtotdev()")
     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_max'], hi2,tolerance=1e-3)
     print("----")
예제 #4
0
 def test_oadev_ci(self):
     s32rows = testutils.read_stable32(resultfile='oadev_decade.txt',
                                       datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         (taus, devs, errs, ns) = allan.oadev(data,
                                              rate=rate,
                                              taus=[row['tau']])
         edf = allan.edf_greenhall(alpha=row['alpha'],
                                   d=2,
                                   m=row['m'],
                                   N=len(data),
                                   overlapping=True,
                                   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))
예제 #5
0
 def test_phasedat_ohdev(self):
     s32_rows = testutils.read_stable32( 'phase_dat_ohdev_octave.txt' , 1.0 )
     phase = testutils.read_datafile('PHASE.DAT')
     (taus,devs,errs,ns) = allan.ohdev(phase, taus=[s32['tau'] for s32 in s32_rows])
     
     # CI computation
     # alhpa= +2,...,-4   noise power
     # d= 1 first-difference variance, 2 allan variance, 3 hadamard variance
     # alpha+2*d >1
     # m = tau/tau0 averaging factor
     # F filter factor, 1 modified variance, m unmodified variance
     # S stride factor, 1 nonoverlapped estimator, m overlapped estimator (estimator stride = tau/S )
     # N number of phase obs
     los=[]
     his=[]
     for (d,t, n) in zip(devs, taus, ns):
         #edf = greenhall_simple_edf( alpha=0, d=3, m=t, S=1, F=t, N=len(phase) )
         edf2 = allan.edf_greenhall( alpha=0, d=3, m=int(t), N=len(phase), overlapping = True, modified=False  )
         #print(edf,edf2,edf2/edf)
         (lo,hi) = allan.confidence_interval( dev=d, edf=edf2 )
         #allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf')
         los.append(lo)
         his.append(hi)
     print("ohdev()")
     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_max'], hi2, tolerance=1e-3)
     print("----")
예제 #6
0
    def test_totdev_ci(self):
        print("totdev()")
        s32rows = testutils.read_stable32(resultfile='totdev_octave.txt',
                                          datarate=1.0)
        for row in s32rows:
            data = testutils.read_datafile(data_file)
            data = allan.frequency2fractional(data, mean_frequency=1.0e7)
            (taus, devs, errs, ns) = allan.totdev(data,
                                                  rate=rate,
                                                  data_type="freq",
                                                  taus=[row['tau']])
            edf = allan.edf_totdev(N=len(data), m=row['m'], alpha=row['alpha'])

            (lo, hi) = allan.confidence_interval(devs[0], edf=edf)
            print("n check: ", testutils.check_equal(ns[0], row['n']))
            print(
                "dev check: ",
                testutils.check_approx_equal(devs[0],
                                             row['dev'],
                                             tolerance=2e-3))
            print("min dev check: %.4g %.4g %d" %
                  (lo, row['dev_min'],
                   testutils.check_approx_equal(
                       lo, row['dev_min'], tolerance=2e-3)))
            print("max dev check: %.4g %.4g %d" %
                  (hi, row['dev_max'],
                   testutils.check_approx_equal(
                       hi, row['dev_max'], tolerance=2e-3)))
예제 #7
0
 def test_oadev_ci(self):
     s32rows = testutils.read_stable32(resultfile='oadev_octave.txt',
                                       datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         data = allan.frequency2fractional(data, mean_frequency=1.0e7)
         (taus, devs, errs, ns) = allan.oadev(data,
                                              rate=rate,
                                              data_type="freq",
                                              taus=[row['tau']])
         # NOTE! Here we use alhpa from Stable32-results for the allantools edf computation!
         edf = allan.edf_greenhall(alpha=row['alpha'],
                                   d=2,
                                   m=row['m'],
                                   N=len(data),
                                   overlapping=True,
                                   modified=False,
                                   verbose=True)
         (lo, hi) = allan.confidence_interval(devs[0], edf=edf)
         print("n check: ", testutils.check_equal(ns[0], row['n']))
         print(
             "dev check: ", devs[0], row['dev'],
             testutils.check_approx_equal(devs[0],
                                          row['dev'],
                                          tolerance=2e-3))
         print(
             "min dev check: ", lo, row['dev_min'],
             testutils.check_approx_equal(lo,
                                          row['dev_min'],
                                          tolerance=2e-3))
         print(
             "max dev check: ", hi, row['dev_max'],
             testutils.check_approx_equal(hi,
                                          row['dev_max'],
                                          tolerance=2e-3))
예제 #8
0
 def test_mdev_ci(self):
     s32rows = testutils.read_stable32(resultfile='mdev_decade.txt', datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         (taus, devs, errs, ns) = allan.mdev(data, rate=rate,
                                               taus=[ row['tau'] ])
         edf = allan.edf_greenhall(alpha=row['alpha'],d=2,m=row['m'],N=len(data),overlapping=True, modified = True, 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 ) )
예제 #9
0
 def test_phasedat_adev(self):
     s32_rows = testutils.read_stable32( 'phase_dat_adev_octave.txt' , 1.0 )
     phase = np.array( testutils.read_datafile('PHASE.DAT') )
     (taus,devs,errs,ns) = allan.adev(phase, taus=[s32['tau'] for s32 in s32_rows])
     
     # separate CI computation
     los=[]
     his=[]
     for (d,t, n, s32) in zip(devs, taus, ns,s32_rows):
         # Note FIXED alpha here 
         edf2 = allan.edf_greenhall( alpha=0, d=2, m=t, N=len(phase), overlapping = False, modified=False )
         (lo,hi) = allan.confidence_interval( dev=d, edf=edf2 )           
         los.append(lo)
         his.append(hi)
         try:
             (lo2,hi2) = allan.confidence_interval_noiseID(phase, d, af=int(t), dev_type="adev", data_type="phase")
             assert np.isclose( lo2, s32['dev_min'] , rtol=1e-2)
             assert np.isclose( hi2, s32['dev_max'] , rtol=1e-2)
             print(" CI OK! tau= ",t)
         except NotImplementedError:
             print("can't do CI for tau= ",t)
             pass
     
     # compare to Stable32
     print("adev()")
     print("    n   tau dev_min  dev      dev_max ")
     for (s32, t2, d2, lo2, hi2, n2) in zip(s32_rows, taus, devs, los, his, ns):
         print("S32 %03d %03.1f %1.6f %1.6f %1.6f" % (s32['n'], s32['tau'], s32['dev_min'], s32['dev'], s32['dev_max']))
         print("AT  %03d %03.1f %1.6f %1.6f %1.6f" % (n2, t2, round(lo2,5), round(d2,5), round(hi2,5) ))
         testutils.check_approx_equal(s32['n'], n2, tolerance=1e-9)
         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("----")
예제 #10
0
    def test_phasedat_adev(self):
        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])

        # separate CI computation
        los = []
        his = []
        for (d, t, n) in zip(devs, taus, ns):
            edf2 = allan.edf_greenhall(alpha=0,
                                       d=2,
                                       m=t,
                                       N=len(phase),
                                       overlapping=False,
                                       modified=False)
            (lo, hi) = allan.confidence_interval(dev=d, edf=edf2)
            los.append(lo)
            his.append(hi)

        # compare to Stable32
        print("adev()")
        for (s32, t2, d2, lo2, hi2, n2) in zip(s32_rows, taus, devs, los, his,
                                               ns):
            print("S32 %03d %03.1f %1.6f %1.6f %1.6f" %
                  (s32['n'], s32['tau'], s32['dev_min'], s32['dev'],
                   s32['dev_max']))
            print("AT  %03d %03.1f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            testutils.check_approx_equal(s32['n'], n2, tolerance=1e-3)
            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("----")
예제 #11
0
    def test_phasedat_tdev(self):
        s32_rows = testutils.read_stable32('phase_dat_tdev_octave.txt', 1.0)
        phase = testutils.read_datafile('PHASE.DAT')
        (taus, devs, errs,
         ns) = allan.tdev(phase, taus=[s32['tau'] for s32 in s32_rows])

        # CI computation
        # alhpa= +2,...,-4   noise power
        # d= 1 first-difference variance, 2 allan variance, 3 hadamard variance
        # alpha+2*d >1
        # m = tau/tau0 averaging factor
        # N number of phase obs
        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=int(t),
                                       N=len(phase),
                                       overlapping=True,
                                       modified=True)

            # covert to mdev
            # taus * md / np.sqrt(3.0)
            mdev = d / t * np.sqrt(3.0)

            (lo,
             hi) = allan.confidence_intervals(dev=mdev,
                                              ci=0.68268949213708585,
                                              edf=edf2)  # 0.68268949213708585

            # convert back to tdev
            lo = t * lo / np.sqrt(3.0)
            hi = t * hi / np.sqrt(3.0)

            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_max'], hi2, tolerance=1e-3)
            print("----")
예제 #12
0
    def test_totdev_ci(self):
        print("totdev()")
        s32rows = testutils.read_stable32(resultfile='totdev_octave.txt', datarate=1.0)
        for row in s32rows:
            data = testutils.read_datafile(data_file)
            data = allan.frequency2fractional(data, mean_frequency=1.0e7)
            (taus, devs, errs, ns) = allan.totdev(data, rate=rate, data_type="freq",
                                                  taus=[ row['tau'] ])
            edf = allan.edf_totdev(N=len(data),m=row['m'], alpha=row['alpha'])

            (lo,hi) = allan.confidence_interval(devs[0], edf=edf)
            print("n check: ", testutils.check_equal( ns[0], row['n'] ) )
            print("dev check: ", testutils.check_approx_equal( devs[0], row['dev'], tolerance=2e-3 ) )
            print("min dev check: %.4g %.4g %d" %( lo, row['dev_min'], testutils.check_approx_equal( lo, row['dev_min'], tolerance=2e-3 ) ) )
            print("max dev check: %.4g %.4g %d" %( hi, row['dev_max'], testutils.check_approx_equal( hi, row['dev_max'], tolerance=2e-3 ) ) )
예제 #13
0
 def test_mdev_ci(self):
     """ Overlapping ADEV with confidence intervals """
     s32rows = testutils.read_stable32(resultfile='mdev_octave.txt', datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         data = allan.frequency2fractional(data, mean_frequency=1.0e7)
         (taus, devs, errs, ns) = allan.mdev(data, rate=rate, data_type="freq",
                                               taus=[ row['tau'] ])
         # NOTE! Here we use alhpa from Stable32-results for the allantools edf computation!
         edf = allan.edf_greenhall(alpha=row['alpha'],d=2,m=row['m'],N=len(data),overlapping=True, modified = True, verbose=True)
         (lo,hi) =allan.confidence_interval(devs[0], edf=edf)
         print("n check: ", testutils.check_equal( ns[0], row['n'] ) )
         print("dev check: ", devs[0], row['dev'], testutils.check_approx_equal( devs[0], row['dev'], tolerance=2e-3 ) )
         print("min dev check: ",  lo, row['dev_min'], testutils.check_approx_equal( lo, row['dev_min'], tolerance=2e-3 ) )
         print("max dev check: ", hi, row['dev_max'], testutils.check_approx_equal( hi, row['dev_max'], tolerance=2e-3 ) )
예제 #14
0
 def test_mdev_ci(self):
     s32rows = testutils.read_stable32(resultfile="mdev_octave.txt", datarate=1.0)
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         data = allan.frequency2fractional(data, mean_frequency=1.0e7)
         (taus, devs, errs, ns) = allan.mdev(data, rate=rate, data_type="freq", taus=[row["tau"]])
         edf = allan.edf_greenhall(
             alpha=row["alpha"], d=2, m=row["m"], N=len(data), overlapping=True, modified=True, 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: ", devs[0], row["dev"], testutils.check_approx_equal(devs[0], row["dev"], tolerance=2e-3))
         print(
             "min dev check: ", lo, row["dev_min"], testutils.check_approx_equal(lo, row["dev_min"], tolerance=2e-3)
         )
         print(
             "max dev check: ", hi, row["dev_max"], testutils.check_approx_equal(hi, row["dev_max"], tolerance=2e-3)
         )
예제 #15
0
    def test_phasedat_adev(self):
        s32_rows = testutils.read_stable32('phase_dat_adev_octave.txt', 1.0)
        phase = np.array(testutils.read_datafile('PHASE.DAT'))
        (taus, devs, errs,
         ns) = allan.adev(phase, taus=[s32['tau'] for s32 in s32_rows])

        # separate CI computation
        los = []
        his = []
        for (d, t, n, s32) in zip(devs, taus, ns, s32_rows):
            # Note FIXED alpha here
            edf2 = allan.edf_greenhall(alpha=0,
                                       d=2,
                                       m=t,
                                       N=len(phase),
                                       overlapping=False,
                                       modified=False)
            (lo, hi) = allan.confidence_interval(dev=d, edf=edf2)
            assert np.isclose(lo, s32['dev_min'], rtol=1e-2)
            assert np.isclose(hi, s32['dev_max'], rtol=1e-2)
            print(" alpha=0 FIXED, CI OK! tau = %f" % t)

            los.append(lo)
            his.append(hi)
            try:
                (lo2,
                 hi2) = allan.confidence_interval_noiseID(phase,
                                                          d,
                                                          af=int(t),
                                                          dev_type="adev",
                                                          data_type="phase")
                assert np.isclose(lo2, s32['dev_min'], rtol=1e-2)
                assert np.isclose(hi2, s32['dev_max'], rtol=1e-2)
                print(" ACF_NID CI OK! tau = %f" % t)
            except NotImplementedError:
                print("can't do CI for tau = %f" % t)
                pass

        # compare to Stable32
        print("adev()")
        print("    n   tau dev_min  dev      dev_max ")
        for (s32, t2, d2, lo2, hi2, n2) in zip(s32_rows, taus, devs, los, his,
                                               ns):
            print("S32 %03d %03.1f %1.6f %1.6f %1.6f" %
                  (s32['n'], s32['tau'], s32['dev_min'], s32['dev'],
                   s32['dev_max']))
            print("AT  %03d %03.1f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            testutils.check_approx_equal(s32['n'], n2, tolerance=1e-9)
            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("----")
예제 #16
0
    def test_phasedat_oadev(self):
        s32_rows = testutils.read_stable32('phase_dat_oadev_octave.txt', 1.0)
        phase = testutils.read_datafile('PHASE.DAT')
        (taus, devs, errs,
         ns) = allan.oadev(phase, taus=[s32['tau'] for s32 in s32_rows])

        # CI computation
        # alhpa     +2,...,-4   noise power
        # d         1 first-difference variance, 2 allan variance, 3 hadamard variance
        #           alpha+2*d >1
        # m         tau/tau0 averaging factor
        # F         filter factor, 1 modified variance, m unmodified variance
        # S         stride factor, 1 nonoverlapped estimator, m overlapped estimator (estimator stride = tau/S )
        # N         number of phase observations
        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=int(t),
                                       N=len(phase),
                                       overlapping=True,
                                       modified=False)
            #print(edf,edf2,edf2/edf)
            (lo,
             hi) = allan.confidence_intervals(dev=d,
                                              ci=0.68268949213708585,
                                              edf=edf2)  # 0.68268949213708585
            #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_max'], hi2, tolerance=1e-3)
            print("----")
예제 #17
0
 def test_adev_ci(self):
     s32rows = testutils.read_stable32(resultfile='adev_decade.txt',
                                       datarate=1.0)
     edfs = []
     err_lo = []
     err_hi = []
     err_dev = []
     for row in s32rows:
         data = testutils.read_datafile(data_file)
         (taus, devs, errs, ns) = allan.adev(data,
                                             rate=rate,
                                             taus=[row['tau']])
         # here allantools does not identify the noise type
         # instead the noise type alpha from Stable 32 is used
         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_interval(devs[0], 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))
         # store relative errors for later printout
         edfs.append(edf)
         err_dev.append(row['dev'] / devs[0] - 1.0)
         err_hi.append(row['dev_max'] / hi - 1.0)
         err_lo.append(row['dev_min'] / lo - 1.0)
     # print table with relative errors
     for (e, lo, err, hi) in zip(edfs, err_lo, err_dev, err_hi):
         print('%d %.6f %.6f %.6f' % (e, lo, err, hi))
예제 #18
0
 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("----")
예제 #19
0
    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("----")
예제 #20
0
    def test_phasedat_mdev(self):
        s32_rows = testutils.read_stable32('phase_dat_mdev_octave.txt', 1.0)
        phase = testutils.read_datafile('PHASE.DAT')
        (taus, devs, errs,
         ns) = allan.mdev(phase, taus=[s32['tau'] for s32 in s32_rows])

        # CI computation
        # alhpa= +2,...,-4   noise power
        # d= 1 first-difference variance, 2 allan variance, 3 hadamard variance
        # alpha+2*d >1
        # m = tau/tau0 averaging factor
        # F filter factor, 1 modified variance, m unmodified variance
        # S stride factor, 1 nonoverlapped estimator, m overlapped estimator (estimator stride = tau/S )
        # N number of phase obs
        los = []
        his = []
        for (d, t, n) in zip(devs, taus, ns):
            edf2 = allan.edf_greenhall(alpha=0,
                                       d=2,
                                       m=int(t),
                                       N=len(phase),
                                       overlapping=True,
                                       modified=True)
            (lo, hi) = allan.confidence_interval(dev=d, edf=edf2)
            los.append(lo)
            his.append(hi)
        # compare to Stable32
        print("mdev()")
        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("----")