コード例 #1
0
def test_shocklikeGaussian():
    m0 = 1 + np.random.rand() * 0.2
    sigma = 50 * Ts
    # zero noise
    x = shocklikeGaussian(time, t0, m0, sigma, noise=0.0)
    assert x.max() == approx(m0)
    assert np.std(x[:N // 10]) < 1e-10
    # noisy signal
    nstd = 1e-2
    x = shocklikeGaussian(time, t0, m0, sigma, noise=nstd)
    assert np.round(np.std(x[:N // 10]) * 100) / 100 == approx(nstd)
コード例 #2
0
ファイル: test_signals.py プロジェクト: mniehus/PyDynamic
def test_shocklikeGaussian():
    m0 = 1 + np.random.rand() * 0.2
    sigma = 50 * Ts
    # zero noise
    x = shocklikeGaussian(time, t0, m0, sigma, noise=0.0)
    assert_almost_equal(np.max(x), m0)
    assert np.std(x[: N // 10]) < 1e-10
    # noisy signal
    nstd = 1e-2
    x = shocklikeGaussian(time, t0, m0, sigma, noise=nstd)
    assert_almost_equal(np.round(np.std(x[: N // 10]) * 100) / 100, nstd)
コード例 #3
0
# sensor/measurement system
f0 = 36e3
uf0 = 0.01 * f0  # resonance frequency
S0 = 0.124
uS0 = 0.001 * S0  # static gain
delta = 0.0055
udelta = 0.1 * delta  # damping

# transform continuous system to digital filter
bc, ac = sos_phys2filter(S0, delta,
                         f0)  # calculate analogue filter coefficients
b, a = dsp.bilinear(bc, ac, Fs)  # transform to digital filter coefficients

# simulate input and output signals
time = np.arange(0, 4e-3 - Ts, Ts)  # time values
x = shocklikeGaussian(time, t0=2e-3, sigma=1e-5, m0=0.8)  # input signal
y = dsp.lfilter(b, a, x)  # output signal
noise = 1e-3  # noise std
yn = y + rst.randn(np.size(y)) * noise  # add white noise

# Monte Carlo for calculation of unc. assoc. with [real(H),imag(H)]
runs = 10000
MCf0 = f0 + rst.randn(runs) * uf0  # MC draws of resonance frequency
MCS0 = S0 + rst.randn(runs) * uS0  # MC draws of static gain
MCd = delta + rst.randn(runs) * udelta  # MC draws of damping
f = np.linspace(0, 120e3,
                200)  # frequencies at which to calculate frequency response
HMC = np.zeros((runs, len(f)),
               dtype=complex)  # initialise frequency response with zeros
for k in range(runs):  # actual Monte Carlo
    bc_, ac_ = sos_phys2filter(
コード例 #4
0
ファイル: deconv_FIR.py プロジェクト: eichstaedtPTB/PyDynamic
# parameters of simulated measurement
Fs = 500e3      # sampling frequency (in Hz)
Ts = 1 / Fs     # sampling intervall length (in s)

# sensor/measurement system
f0 = 36e3; uf0 = 0.01*f0            # resonance frequency
S0 = 0.124; uS0= 0.001*S0           # static gain
delta = 0.0055; udelta = 0.1*delta  # damping

# transform continuous system to digital filter
bc, ac = sos_phys2filter(S0,delta,f0)   # calculate analogue filter coefficients
b, a = dsp.bilinear(bc, ac, Fs)         # transform to digital filter coefficients

# simulate input and output signals
time = np.arange(0, 4e-3 - Ts, Ts)                              # time values
x = shocklikeGaussian(time, t0 = 2e-3, sigma = 1e-5, m0=0.8)    # input signal
y = dsp.lfilter(b, a, x)                                        # output signal
noise = 1e-3                                                    # noise std
yn = y + rst.randn(np.size(y)) * noise                          # add white noise

# Monte Carlo for calculation of unc. assoc. with [real(H),imag(H)]
runs = 10000
MCf0 = f0 + rst.randn(runs)*uf0                 # MC draws of resonance frequency
MCS0 = S0 + rst.randn(runs)*uS0                 # MC draws of static gain
MCd  = delta+ rst.randn(runs)*udelta            # MC draws of damping
f = np.linspace(0, 120e3, 200)                  # frequencies at which to calculate frequency response
HMC = np.zeros((runs, len(f)),dtype=complex)    # initialise frequency response with zeros
for k in range(runs):       # actual Monte Carlo
    bc_,ac_ = sos_phys2filter(MCS0[k], MCd[k], MCf0[k])     # calculate analogue filter coefficients
    b_,a_ = dsp.bilinear(bc_,ac_,Fs)                        # transform to digital filter coefficients
    HMC[k,:] = dsp.freqz(b_,a_,2*np.pi*f/Fs)[1]             # calculate DFT frequency response