Python 如何从给定的量化信号中去除量化噪声?

Python 如何从给定的量化信号中去除量化噪声?,python,numpy,scipy,Python,Numpy,Scipy,比如说,我有一个模拟信号,它是离散表示: import numpy as np import pylab as py def sin(frequency = 1, time = 1, sampling = 128, phi = 0): ''' Sinus function for a given frequency in Hz, length in time, sampling frequency, and phase. ''' dt = 1.0 / s

比如说,我有一个模拟信号,它是离散表示:

import numpy as np
import pylab as py

def sin(frequency = 1, time = 1, sampling = 128, phi = 0):
    '''
    Sinus function for a given frequency in Hz, length in time,
    sampling frequency, and phase.
    '''
    dt = 1.0 / sampling
    t = np.arange(0, time, dt)
    s = np.sin((2 * np.pi * frequency * t) + phi)
    return s, t

s_analog_1, t_analog_1 = sin(frequency = 1, sampling = 1000)
py.plot(t_analog_1, s_analog_1, linewidth = '1.5', color = 'red', 
label = 'analog signal')

s_analog_2, t_analog_2 = sin(frequency = 1, sampling = 10)
py.plot(t_analog_2, s_analog_2, 'o', color = 'red')

# Calculate the quantization noise, ie "R/2^N"
s_discrete, t_discrete = sin(frequency = 1, sampling = 10)
N = 3
R = 2
dy = R/2**N
s_quantized = np.floor(s_discrete / dy) * dy + 0.5 *dy

py.plot(t_discrete, s_quantized, color = 'gray', label = 'discrete signal')
py.plot(t_discrete, s_quantized, 'o', color = 'gray')

py.legend(loc='upper right', fontsize='10')

py.show()

模数转换器为3位电平,测量范围为2。如何从离散信号表示中去除量化噪声,使其适合模拟信号表示?这个问题是在我已经收集到离散信号的情况下提出的。在删除过程中,我可以使用量化噪声系数,即dy=R/2^N。提前感谢。

如果您希望将正弦波拟合到数据中,为什么不将正弦波拟合到数据中?你需要决定频率和相位是固定参数还是自由参数来拟合。一般来说,低通滤波通常是最可行的方法。如果您已经收集了数据,使用查看功率谱密度将有助于找到适当的参数。scipy.filter具有设计过滤器的方法。或者,您可以使用rfft/irfft将适当的频率区域设置为零。@frank128791首先,我想将灰点的位置调整为红点的位置。@bluevoxel您如何知道红点的位置?您是否已经知道正弦波的相位、频率和/或振幅?显然,如果您已经知道灰点应该去哪里,那么您只需要根据获取数据的时间分配正确的值。