클래스 FFT_Plot() :pyQTGraph 설정 축 값 (FFT)
def __init__(self,
win,
nSamples,
aData,
sRate,
wFunction,
zStart = 0):
self.nSamples = nSamples # Number of Sample must be a 2^n power
self.aData = aData # Amplitude data array
self.sRate = sRate # Sample Rate
self.wFunction = wFunction # Windowing Function
self.zStart = zStart # Start of Zoom Window if Used
self.zStop = nSamples/2 # End of Zoom Window if Used
# Instantiate a plot window within an existing pyQtGraph window.
self.plot = win.addPlot(title="FFT")
self.update(aData)
self.grid_state()
self.plot.setLabel('left', 'Amplitude', 'Volts')
self.plot.setLabel('bottom', 'Frequency', 'Hz')
def update(self, aData):
x = np.fft.fft(aData,)
amplitude = np.absolute(x)
fScale = np.linspace(0 , 50000, self.nSamples)
self.plot.plot(amplitude)
# Calculate and set-up X axis
self.plot.setXRange(SampleSize/2, 0)
def grid_state(self, x = True, y = True):
self.plot.showGrid(x, y)
내 문제는 매우 간단하다. x 축과 y 축을 따라 표시된 값을 어떻게 변경합니까?
샘플을 2048 개 사용하고 샘플의 절반을 표시하면 (0 ~ 샘플/2) 나는 0에서 1을 표시합니다. 빈도 나 진폭을 표시 할 수 없다면 계산할 수 없습니다.
범위를 변경하면 스펙트럼이 효과적으로 축소됩니다 ... 일부 예제를 보았지만 무슨 일이 벌어지는 지에 대한 설명이 없어져서 빨리 잃었습니다.
어떤 도움을 주시면 감사하겠습니다 ... 누가 공유로
... 나는 내가 'X'배열을 사용할 수 있다는 사실을 놓쳤다. 클래스는 다음과 같습니다 수정 된 초보자 :) :
클래스 FFT_Plot() :
def __init__(self,
win,
nSamples,
aData,
sRate,
wFunction,
zStart = 0):
self.nSamples = nSamples # Number of Sample must be a 2^n power
self.aData = aData # Amplitude data array
self.sRate = sRate # Sample Rate as Frequency
self.wFunction = wFunction # Windowing Function
self.zStart = zStart # Start of Zoom Window if Used
self.zStop = nSamples/2 # End of Zoom Window if Used
# Instantiate a plot window within an existing pyQtGraph window.
self.plot = win.addPlot(title="FFT")
self.update(aData)
self.grid_state()
self.plot.setLabel('left', 'Amplitude', 'Volts')
self.plot.setLabel('bottom', 'Frequency', 'Hz')
def update(self, aData):
x = np.fft.fft(aData,)
amplitude = np.absolute(x)
# Create a linear scale based on the Sample Rate and Number of Samples.
fScale = np.linspace(0 , self.sRate, self.nSamples)
self.plot.plot(x = fScale, y = amplitude, pen={'color': (0, 0, 0), 'width': 2})
# Because the X-axis is now tied to the fScale, which os based on sRate,
# to set any range limits you must use the sRate.
self.plot.setXRange(self.sRate/2, 0)
def grid_state(self, x = True, y = True):
self.plot.showGrid(x, y)
모든 DSP 유형이 아닌 수학의 의견을 추가 할 주시기 바랍니다.
또한 Y 축을 올바르게 읽으려면 진폭 배열을 그에 따라 사전 크기 조정해야하는 것으로 보입니다.
수정 - 취소됨 – user3279899