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_interval(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))
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("----")
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("----")
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)))
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("----")
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("----")
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("----")
def test_phasedat_hdev(self): s32_rows = testutils.read_stable32( 'phase_dat_hdev_octave.txt' , 1.0 ) phase = testutils.read_datafile('PHASE.DAT') (taus,devs,errs,ns) = allan.hdev(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=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_interval( dev=d, edf=edf2 ) #allan.uncertainty_estimate(len(phase), t, d,ci=0.683,noisetype='wf') los.append(lo) his.append(hi) print("hdev()") 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("----")
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("----")
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))
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("----")
def get_better_ade(tau, adev, tau0, N, alpha=0, d=2, overlapping=True, modified=False): """Calculate non-naive Allan deviation errors. Equivalent to Stable32. Ref: https://github.com/aewallin/allantools/blob/master/examples/ci_demo.py https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20050061319.pdf Args: tau (list of floats): list of tau_values for which deviations were computed adev (list of floats): list of ADEV (or another statistic) deviations tau0 (float): averaging factor; average interval between measurements N (int): number of frequency observations alpha (int, optional): +2,...,-4 noise type, either estimated or known d (int, optional): statistic code: 1 first-difference variance, 2 allan variance, 3 hadamard variance overlapping (bool, optional): True if overlapping statistic used. False if standard statistic used modified (bool, optional): True if modified statistic used. False if standard statistic used. Returns: err_lo (list of floats): non-naive lower 1-sigma confidence interval for each point over which deviations were computed err_high (list of floats): non-naive higher 1-sigma confidence interval for each point over which deviations were computed """ # Confidence-intervals for each (tau, adev) pair separately. cis = [] for (t, dev) in zip(tau, adev): # Greenhalls EDF (Equivalent Degrees of Freedom) edf = allantools.edf_greenhall(alpha=alpha, d=d, m=t / tau0, N=N, overlapping=overlapping, modified=modified) # with the known EDF we get CIs (lo, hi) = allantools.confidence_interval(dev=dev, edf=edf) cis.append((lo, hi)) err_lo = np.array([d - ci[0] for (d, ci) in zip(adev, cis)]) err_hi = np.array([ci[1] - d for (d, ci) in zip(adev, cis)]) return err_lo, err_hi
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 ) )
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 ) ) )
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))
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("----")
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("----")
# 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) edfs.append(edf) # with the known EDF we get CIs (lo, hi) = at.confidence_interval(dev=dev, 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
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 (lo,hi) = at.confidence_interval( dev=dev, 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