Esempio n. 1
0
    def test_bounce_kernel(self):
        amp = 0.1
        tau = 10e-9
        length = 100e-9
        sampling_rate = 1e9

        ker_real = kf.bounce_kernel(amp=amp,
                                    time=tau,
                                    length=length,
                                    sampling_rate=sampling_rate)

        ker_sampled = kf.bounce_kernel(amp=amp,
                                       time=tau * sampling_rate,
                                       length=length * sampling_rate,
                                       sampling_rate=1)

        np.testing.assert_almost_equal(ker_real, ker_sampled)
        nr_samples = int(length * sampling_rate)
        t_kernel = np.arange(nr_samples) / sampling_rate
        bounce = kf.bounce(t_kernel,
                           amp=amp,
                           time=tau,
                           sampling_rate=sampling_rate)
        y_corr0 = np.convolve(ker_real, bounce)
        np.testing.assert_almost_equal(y_corr0[10:80], np.ones(70), decimal=2)
Esempio n. 2
0
def bounce_correction(ysig,
                      tau: float,
                      amp: float,
                      sampling_rate: float = 1,
                      inverse: bool = False):
    """
    Corrects for a bounce

    Args:
        ysig: the signal to be predistorted
        tau: the time at which the bounce occurs
        amp: the amplitude of the bounce correction
        sampling_rate: the sampling rate of the signal
    returns:
        filtered_signal : the signal corrected for the bounce
    """

    # kernel is cut of after 8*tau, this menas that it will only correct
    # bounces up to 8th order, this is good for coefficients << 1
    kern = bounce_kernel(amp,
                         time=tau,
                         length=8 * tau,
                         sampling_rate=sampling_rate)
    if inverse:
        raise NotImplemented
    else:
        filter_signal = np.convolve(ysig, kern, mode='full')
    return filter_signal[:len(ysig)]
Esempio n. 3
0
 def test_bounce_kernel(self):
     bl = 40e-9
     ba = .2
     bt = 12e-9
     self.k0.bounce_amp_1(ba)
     self.k0.bounce_tau_1(bt)
     self.k0.bounce_length_1(bl)
     kObj_bounce = self.k0.get_bounce_kernel_1()
     kf_bounce = kf.bounce_kernel(amp=ba, time=bt * 1e9, length=bl * 1e9)
     np.testing.assert_almost_equal(kObj_bounce, kf_bounce)
Esempio n. 4
0
 def get_bounce_kernel_2(self):
     return kf.bounce_kernel(amp=self.bounce_amp_2(),
                             time=self.bounce_tau_2()*self.sampling_rate(),
                             length=self.bounce_length_2()*self.sampling_rate())