def test_ofamp(): """ Testing function for `qetpy.ofamp`. """ signal, template, psd = create_example_data() fs = 625e3 res1 = qp.ofamp(signal, template, psd, fs, lgcsigma=True, nconstrain=100, withdelay=True) OF = qp.OptimumFilter(signal, template, psd, fs) res2 = OF.ofamp_withdelay(nconstrain=100) res_compare1 = res2 + (OF.energy_resolution(), ) res3 = qp.ofamp(signal, template, psd, fs, withdelay=False) OF = qp.OptimumFilter(signal, template, psd, fs) res4 = OF.ofamp_nodelay() res_compare2 = (res4[0], 0.0, res4[1]) assert isclose(res1, res_compare1) assert isclose(res3, res_compare2)
def test_chi2_nopulse(): """ Testing function for `qetpy.chi2_nopulse`. """ signal, template, psd = create_example_data() fs = 625e3 res1 = qp.chi2_nopulse(signal, psd, fs) OF = qp.OptimumFilter(signal, template, psd, fs) res2 = OF.chi2_nopulse() assert isclose(res1, res2)
def test_ofamp_pileup_stationary(): """ Testing function for `qetpy.ofamp_pileup_stationary`. """ signal, template, psd = create_example_data() fs = 625e3 res1 = qp.ofamp_pileup_stationary(signal, template, psd, fs) OF = qp.OptimumFilter(signal, template, psd, fs) res2 = OF.ofamp_pileup_stationary() assert isclose(res1, res2)
def test_ofamp_pileup(): """ Testing function for `qetpy.ofamp_pileup`. """ signal, template, psd = create_example_data(lgcpileup=True) fs = 625e3 res1 = qp.ofamp_pileup(signal, template, psd, fs) OF = qp.OptimumFilter(signal, template, psd, fs) res2 = OF.ofamp_withdelay() res3 = OF.ofamp_pileup_iterative(res2[0], res2[1]) res_compare = res2[:-1] + res3 assert isclose(res1, res_compare)
def test_chi2lowfreq(): """ Testing function for `qetpy.chi2lowfreq`. """ signal, template, psd = create_example_data() fs = 625e3 res1 = qp.ofamp(signal, template, psd, fs) chi2low = qp.chi2lowfreq(signal, template, res1[0], res1[1], psd, fs, fcutoff=10000) OF = qp.OptimumFilter(signal, template, psd, fs) res2 = OF.ofamp_withdelay() chi2low_compare = OF.chi2_lowfreq(amp=res2[0], t0=res2[1], fcutoff=10000) assert isclose(chi2low, chi2low_compare)
def test_OptimumFilter(): """ Testing function for `qetpy.OptimumFilter` class. """ signal, template, psd = create_example_data() fs = 625e3 OF = qp.OptimumFilter(signal, template, psd, fs) res = OF.ofamp_nodelay() assert isclose(res, (-1.589803642041125e-07, 2871569.457990007), rtol=1e-6) res = OF.energy_resolution() assert isclose(res, 2.3725914280425287e-09, rtol=1e-6) res = OF.ofamp_withdelay() assert isclose(res, (4.000884927004103e-06, 0.00016, 32474.45440205792), rtol=1e-6) res2 = OF.ofamp_nodelay(windowcenter=int(res[1] * fs)) assert isclose(res2, res[::2], rtol=1e-6) res = OF.time_resolution(res[0]) assert isclose(res, 5.746611055379949e-09, rtol=1e-6) res = OF.ofamp_withdelay(nconstrain=100) assert isclose(res, (6.382904231454342e-07, 7.84e-05, 2803684.0424425197), rtol=1e-6) res = OF.ofamp_withdelay(nconstrain=100, lgcoutsidewindow=True) assert isclose(res, (4.000884927004103e-06, 0.00016, 32474.45440205792), rtol=1e-6) res = OF.ofamp_withdelay(nconstrain=3, windowcenter=-5) assert isclose(res, (-1.748136068514983e-07, -9.6e-06, 2870630.5945196496), rtol=1e-6) res = OF.chi2_lowfreq(amp=4.000884927004103e-06, t0=0.00016, fcutoff=10000) assert isclose(res, 1052.9089578293142, rtol=1e-6) res = OF.chi2_nopulse() assert isclose(res, 2876059.4034037213, rtol=1e-6) OF.update_signal(signal) res = OF.ofamp_pileup_stationary() assert isclose(res, (2.884298804131357e-09, 4.001001614298674e-06, 0.00016, 32472.978956471197), rtol=1e-6) signal, template, psd = create_example_data(lgcpileup=True) OF.update_signal(signal) res1 = OF.ofamp_withdelay() res = OF.ofamp_pileup_iterative(res1[0], res1[1]) assert isclose(res, (4.000882414471985e-06, 0.00016, 32477.55571848713), rtol=1e-6) res = OF.ofamp_pileup_iterative(res1[0], res1[1], nconstrain=100, lgcoutsidewindow=False) assert isclose(res, (6.382879106117655e-07, 7.84e-05, 2803684.142039136), rtol=1e-6) res = OF.ofamp_pileup_iterative(res1[0], res1[1], nconstrain=100, lgcoutsidewindow=True) assert isclose(res, (4.000882414471985e-06, 0.00016, 32477.55571848713), rtol=1e-6) signal, template, psd = create_example_data(lgcbaseline=True) OF.update_signal(signal) res = OF.ofamp_baseline() assert isclose(res, (4.000884927004102e-06, 0.00016, 32474.454402058076), rtol=1e-6) res = OF.ofamp_baseline(nconstrain=100) assert isclose(res, (6.434754982839688e-07, 7.84e-05, 2806781.3450564747), rtol=1e-6) res = OF.ofamp_baseline(nconstrain=100, lgcoutsidewindow=True) assert isclose(res, (4.000884927004102e-06, 0.00016, 32474.454402058076), rtol=1e-6)