コード例 #1
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))
コード例 #2
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("----")
コード例 #3
0
    def test_phasedat_totdev(self):
        (s32_taus, s32_devs, s32_devs_lo, s32_devs_hi,
         s32_ns) = read_stable32('phase_dat_totdev_octave.txt', 1.0)
        phase = read_datafile('PHASE.DAT')
        (taus, devs, errs, ns) = allan.totdev(phase, taus=s32_taus)

        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_intervals(dev=d,
                                              ci=0.68268949213708585,
                                              edf=edf)  # 0.68268949213708585
            #allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf')
            los.append(lo)
            his.append(hi)

        for (t1, d1, lo1, hi1, n1, t2, d2, lo2, hi2,
             n2) in zip(s32_taus, s32_devs, s32_devs_lo, s32_devs_hi, s32_ns,
                        taus, devs, los, his, ns):
            print("s32 %03d %03f %1.6f %1.6f %1.6f" % (n1, t1, lo1, d1, hi1))
            print("at  %03d %03f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 7), round(d2, 7), round(hi2, 7)))
            approx_equal(lo1, lo2, tolerance=1e-3)
            approx_equal(hi1, hi2, tolerance=1e-3)
            print("----")
コード例 #4
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):
            #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  )
            #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("----")
コード例 #5
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_intervals(dev=d,
                                              ci=0.68268949213708585,
                                              edf=edf)  # 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("----")
コード例 #6
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_intervals( dev=d, ci=0.68268949213708585, edf=edf )  # 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("----")
コード例 #7
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 ) )
コード例 #8
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("----")
コード例 #9
0
    def test_phasedat_mdev(self):
        (s32_taus, s32_devs, s32_devs_lo, s32_devs_hi,
         s32_ns) = read_stable32('phase_dat_mdev_octave.txt', 1.0)
        phase = read_datafile('PHASE.DAT')
        (taus, devs, errs, ns) = allan.mdev(phase, taus=s32_taus)

        # 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=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)
            #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)

        #print greenhall_simple_edf( alpha=0, d=2, m=1, S=1, F=1, N=len(phase) )
        #print confidence_intervals( dev
        #   tau N       edf         chi2    chi2    dev_lo      dev         dev_hi
        #   1   999     782.030     821.358 742.689 2.8515e-01  2.9223e-01  2.9987e-01
        #   2   997     540.681     573.374 507.975 1.9520e-01  2.0102e-01  2.0738e-01

        for (t1, d1, lo1, hi1, n1, t2, d2, lo2, hi2,
             n2) in zip(s32_taus, s32_devs, s32_devs_lo, s32_devs_hi, s32_ns,
                        taus, devs, los, his, ns):
            print("s32 %03d %03f %1.6f %1.6f %1.6f" % (n1, t1, lo1, d1, hi1))
            print("at  %03d %03f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            approx_equal(lo1, lo2, tolerance=1e-3)
            approx_equal(hi1, hi2, tolerance=1e-3)
            print("----")
コード例 #10
0
ファイル: test_ocxo.py プロジェクト: fmeynadier/allantools
 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)
         )
コード例 #11
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("----")
コード例 #12
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)
        phase = read_datafile('PHASE.DAT')
        (taus, devs, errs, ns) = allan.adev(phase, taus=s32_taus)

        # 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)
            #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)

        #print greenhall_simple_edf( alpha=0, d=2, m=1, S=1, F=1, N=len(phase) )
        #print confidence_intervals( dev
        #   tau N       edf         chi2_l
        #   1   999     782.030     821.358 , 742.689
        #  2.851498,  2.922319  2.998720

        for (t1, d1, lo1, hi1, n1, t2, d2, lo2, hi2,
             n2) in zip(s32_taus, s32_devs, s32_devs_lo, s32_devs_hi, s32_ns,
                        taus, devs, los, his, ns):
            print("s32 %03d %03f %1.6f %1.6f %1.6f" % (n1, t1, lo1, d1, hi1))
            print("at  %03d %03f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            approx_equal(lo1, lo2, tolerance=1e-3)
            approx_equal(hi1, hi2, tolerance=1e-3)
            print("----")
コード例 #13
0
    def test_phasedat_hdev(self):
        (s32_taus, s32_devs, s32_devs_lo, s32_devs_hi,
         s32_ns) = read_stable32('phase_dat_hdev_octave.txt', 1.0)
        phase = read_datafile('PHASE.DAT')
        (taus, devs, errs, ns) = allan.hdev(phase, taus=s32_taus)

        # 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=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=False,
                                       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 (t1, d1, lo1, hi1, n1, t2, d2, lo2, hi2,
             n2) in zip(s32_taus, s32_devs, s32_devs_lo, s32_devs_hi, s32_ns,
                        taus, devs, los, his, ns):
            print("s32 %03d %03f %1.6f %1.6f %1.6f" % (n1, t1, lo1, d1, hi1))
            print("at  %03d %03f %1.6f %1.6f %1.6f" %
                  (n2, t2, round(lo2, 5), round(d2, 5), round(hi2, 5)))
            approx_equal(lo1, lo2, tolerance=1e-3)
            approx_equal(hi1, hi2, tolerance=1e-3)
            print("----")
コード例 #14
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("----")
コード例 #15
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("----")
コード例 #16
0
ファイル: ci_demo.py プロジェクト: chaloz/allantools
(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 )
    cis.append( (lo,hi) )

# now we are ready to print and plot the results
print "Tau\tmin Dev\t\tDev\t\tMax Dev"
for (tau,dev,ci) in zip(taus,devs,cis):
    print "%d\t%f\t%f\t%f" % (tau, ci[0], dev, ci[1] )
""" output is
Tau	min Dev		Dev		Max Dev
1	0.285114	0.292232	0.299910
2	0.197831	0.205102	0.213237
4	0.141970	0.149427	0.158198
8	0.102541	0.110135	0.119711
16	0.056510	0.062381	0.070569
32	0.049153	0.056233	0.067632
64	0.027109	0.032550	0.043536