right ifft implementation
This commit is contained in:
@ -243,15 +243,14 @@ def run_matplotlib(args):
|
||||
ax_line.set_ylim(-1.05, 1.05)
|
||||
ax_line.set_ylabel("/ max")
|
||||
|
||||
# Спектр — используем уже вычисленный в ring FFT
|
||||
if ring.last_fft_vals is not None and ring.freq_shared is not None:
|
||||
# Спектр — используем уже вычисленный в ring IFFT (временной профиль)
|
||||
if ring.last_fft_vals is not None and ring.fft_time_axis is not None:
|
||||
fft_vals = ring.last_fft_vals
|
||||
xs_fft = ring.freq_shared
|
||||
if fft_vals.size > xs_fft.size:
|
||||
fft_vals = fft_vals[: xs_fft.size]
|
||||
fft_line_obj.set_data(xs_fft[: fft_vals.size], fft_vals)
|
||||
xs_fft = ring.fft_time_axis
|
||||
n = min(fft_vals.size, xs_fft.size)
|
||||
fft_line_obj.set_data(xs_fft[:n], fft_vals[:n])
|
||||
if np.isfinite(np.nanmin(fft_vals)) and np.isfinite(np.nanmax(fft_vals)):
|
||||
ax_fft.set_xlim(0, max(1, xs_fft.size - 1))
|
||||
ax_fft.set_xlim(0, float(xs_fft[n - 1]))
|
||||
ax_fft.set_ylim(float(np.nanmin(fft_vals)), float(np.nanmax(fft_vals)))
|
||||
|
||||
# Водопад сырых данных
|
||||
|
||||
@ -7,12 +7,16 @@ from typing import Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
from rfg_adc_plotter.constants import FREQ_SPAN_GHZ, IFFT_LEN
|
||||
from rfg_adc_plotter.io.sweep_reader import SweepReader
|
||||
from rfg_adc_plotter.processing.normalizer import build_calib_envelopes
|
||||
from rfg_adc_plotter.state.app_state import AppState, format_status
|
||||
from rfg_adc_plotter.state.ring_buffer import RingBuffer
|
||||
from rfg_adc_plotter.types import SweepPacket
|
||||
|
||||
# Максимальное значение временной оси IFFT в нс
|
||||
_IFFT_T_MAX_NS = float((IFFT_LEN - 1) / (FREQ_SPAN_GHZ * 1e9) * 1e9)
|
||||
|
||||
|
||||
def _parse_ylim(ylim_str: Optional[str]) -> Optional[Tuple[float, float]]:
|
||||
if not ylim_str:
|
||||
@ -164,8 +168,8 @@ def run_pyqtgraph(args):
|
||||
p_fft = win.addPlot(row=1, col=0, title="FFT")
|
||||
p_fft.showGrid(x=True, y=True, alpha=0.3)
|
||||
curve_fft = p_fft.plot(pen=pg.mkPen((255, 120, 80), width=1))
|
||||
p_fft.setLabel("bottom", "Бин")
|
||||
p_fft.setLabel("left", "Амплитуда, дБ")
|
||||
p_fft.setLabel("bottom", "Время, нс")
|
||||
p_fft.setLabel("left", "Мощность, дБ")
|
||||
|
||||
# Водопад спектров (справа-снизу)
|
||||
p_spec = win.addPlot(row=1, col=1, title="B-scan (дБ)")
|
||||
@ -176,7 +180,7 @@ def run_pyqtgraph(args):
|
||||
p_spec.getAxis("bottom").setStyle(showValues=False)
|
||||
except Exception:
|
||||
pass
|
||||
p_spec.setLabel("left", "Бин (0 снизу)")
|
||||
p_spec.setLabel("left", "Время, нс")
|
||||
img_fft = pg.ImageItem()
|
||||
p_spec.addItem(img_fft)
|
||||
|
||||
@ -197,7 +201,6 @@ def run_pyqtgraph(args):
|
||||
FREQ_MAX = 14.323
|
||||
|
||||
def _init_imshow_extents():
|
||||
w = ring.width
|
||||
ms = ring.max_sweeps
|
||||
fb = ring.fft_bins
|
||||
img.setImage(ring.ring.T, autoLevels=False)
|
||||
@ -205,8 +208,9 @@ def run_pyqtgraph(args):
|
||||
p_img.setRange(xRange=(0, ms - 1), yRange=(FREQ_MIN, FREQ_MAX), padding=0)
|
||||
p_line.setXRange(FREQ_MIN, FREQ_MAX, padding=0)
|
||||
img_fft.setImage(ring.ring_fft.T, autoLevels=False)
|
||||
p_spec.setRange(xRange=(0, ms - 1), yRange=(0, max(1, fb - 1)), padding=0)
|
||||
p_fft.setXRange(0, max(1, fb - 1), padding=0)
|
||||
img_fft.setRect(pg.QtCore.QRectF(0.0, 0.0, float(ms), _IFFT_T_MAX_NS))
|
||||
p_spec.setRange(xRange=(0, ms - 1), yRange=(0.0, _IFFT_T_MAX_NS), padding=0)
|
||||
p_fft.setXRange(0.0, _IFFT_T_MAX_NS, padding=0)
|
||||
|
||||
def _img_rect(ms: int) -> "pg.QtCore.QRectF":
|
||||
return pg.QtCore.QRectF(0.0, FREQ_MIN, float(ms), FREQ_MAX - FREQ_MIN)
|
||||
@ -245,13 +249,12 @@ def run_pyqtgraph(args):
|
||||
p_line.setYRange(-1.05, 1.05, padding=0)
|
||||
p_line.setLabel("left", "/ max")
|
||||
|
||||
# Спектр — используем уже вычисленный в ring FFT
|
||||
if ring.last_fft_vals is not None and ring.freq_shared is not None:
|
||||
# Спектр — используем уже вычисленный в ring IFFT (временной профиль)
|
||||
if ring.last_fft_vals is not None and ring.fft_time_axis is not None:
|
||||
fft_vals = ring.last_fft_vals
|
||||
xs_fft = ring.freq_shared
|
||||
if fft_vals.size > xs_fft.size:
|
||||
fft_vals = fft_vals[: xs_fft.size]
|
||||
curve_fft.setData(xs_fft[: fft_vals.size], fft_vals)
|
||||
xs_fft = ring.fft_time_axis
|
||||
n = min(fft_vals.size, xs_fft.size)
|
||||
curve_fft.setData(xs_fft[:n], fft_vals[:n])
|
||||
p_fft.setYRange(float(np.nanmin(fft_vals)), float(np.nanmax(fft_vals)), padding=0)
|
||||
|
||||
# Позиция подписи канала
|
||||
@ -290,6 +293,7 @@ def run_pyqtgraph(args):
|
||||
img_fft.setImage(disp_fft, autoLevels=False, levels=levels)
|
||||
else:
|
||||
img_fft.setImage(disp_fft, autoLevels=False)
|
||||
img_fft.setRect(pg.QtCore.QRectF(0.0, 0.0, float(ring.max_sweeps), _IFFT_T_MAX_NS))
|
||||
|
||||
timer = pg.QtCore.QTimer()
|
||||
timer.timeout.connect(update)
|
||||
|
||||
Reference in New Issue
Block a user