Пример #1
0
def test_evaluate():
    amplitude = 1.2
    frequency = 42.
    t = 3.
    sinusodial = Sinusodial(amplitude, frequency)
    assert sinusodial.evaluate(t) == (amplitude *
                                      math.sin(2 * math.pi * frequency * t))
Пример #2
0
def test_evaluate_with_offset_and_phase():
    amplitude = 1.2
    frequency = 42.
    phase = 7.5 * math.pi
    offset = 4.5321
    t = 3.
    sinusodial = Sinusodial(amplitude, frequency, phase, offset)
    assert sinusodial.evaluate(t) == (
        amplitude * math.sin(2 * math.pi * frequency * t + phase) + offset)
    u_hat_parallel[index] = next(digital_estimator_parallel)

###############################################################################
# Visualizing Results
# -------------------
#
# Finally, we summarize the comparision by visualizing the resulting estimate
# in both time and frequency domain.

t = np.arange(size)
# compensate the built in L1 delay of FIR filter.
t_fir = np.arange(-L1 + 1, size - L1 + 1)
t_iir = np.arange(-L1 + 1, size - L1 + 1)
u = np.zeros_like(u_hat_batch)
for index, tt in enumerate(t):
    u[index] = analog_signal.evaluate(tt * T)
plt.plot(t, u_hat_batch, label="$\hat{u}(t)$ Batch")
plt.plot(t_fir, u_hat_fir, label="$\hat{u}(t)$ FIR")
plt.plot(t_iir, u_hat_iir, label="$\hat{u}(t)$ IIR")
plt.plot(t, u_hat_parallel, label="$\hat{u}(t)$ Parallel")
plt.plot(t, stf_at_omega * u, label="$\mathrm{STF}(2 \pi f_u) * u(t)$")
plt.xlabel('$t / T$')
plt.legend()
plt.title("Estimated input signal")
plt.grid(which='both')
plt.xlim((-100, 500))
plt.tight_layout()

plt.figure()
plt.plot(t, u_hat_batch, label="$\hat{u}(t)$ Batch")
plt.plot(t_fir, u_hat_fir, label="$\hat{u}(t)$ FIR")
Пример #4
0
###############################################################################
# Visualizing Results
# -------------------
#
# Finally, we summarize the comparision by visualizing the resulting estimate
# in both time and frequency domain.
from cbadc.utilities import compute_power_spectral_density

t = np.arange(size)
# compensate the built in K1 delay of FIR filter.
t_fir = np.arange(-K1 + 1, size - K1 + 1)
u = np.zeros_like(u_hat_mid_point)
u_mid_point = np.zeros_like(u)
for index, tt in enumerate(t):
    u[index] = analog_signal.evaluate(tt * T)
    u_mid_point[index] = analog_signal.evaluate(tt * T - T / 2.0)
plt.plot(t, stf_at_omega * u, label="$\mathrm{STF}(2 \pi f_u) * u(t)$")
plt.plot(t_fir, u_hat_default, label="$\hat{u}(t)$ Default")
plt.plot(t_fir - 0.5, u_hat_mid_point, label="$\hat{u}(t - T/2)$ Mid point")
plt.xlabel('$t / T$')
plt.legend()
plt.title("Estimated input signal")
plt.grid(which='both')
plt.xlim((-100, 500))
plt.tight_layout()

plt.figure()
plt.plot(t, stf_at_omega * u, label="$\mathrm{STF}(2 \pi f_u) * u(t)$")
plt.plot(t_fir, u_hat_default, label="$\hat{u}(t)$ Default")
plt.plot(t_fir - 0.5, u_hat_mid_point, label="$\hat{u}(t - T/2)$ Mid point")