fix sub matplotlib
This commit is contained in:
@ -461,17 +461,24 @@ def run_matplotlib(args):
|
|||||||
|
|
||||||
# Обновление линии последнего свипа
|
# Обновление линии последнего свипа
|
||||||
if current_sweep is not None:
|
if current_sweep is not None:
|
||||||
if x_shared is not None and current_sweep.size <= x_shared.size:
|
# Применяем вычитание медианы для отображения
|
||||||
xs = x_shared[: current_sweep.size]
|
display_sweep = current_sweep
|
||||||
|
if median_subtract_enabled and median_data is not None:
|
||||||
|
take_median = min(current_sweep.size, median_data.size)
|
||||||
|
display_sweep = current_sweep.copy()
|
||||||
|
display_sweep[:take_median] = current_sweep[:take_median] - median_data[:take_median]
|
||||||
|
|
||||||
|
if x_shared is not None and display_sweep.size <= x_shared.size:
|
||||||
|
xs = x_shared[: display_sweep.size]
|
||||||
else:
|
else:
|
||||||
xs = np.arange(current_sweep.size, dtype=np.int32)
|
xs = np.arange(display_sweep.size, dtype=np.int32)
|
||||||
line_obj.set_data(xs, current_sweep)
|
line_obj.set_data(xs, display_sweep)
|
||||||
# Лимиты по X постоянные под текущую ширину
|
# Лимиты по X постоянные под текущую ширину
|
||||||
ax_line.set_xlim(0, max(1, current_sweep.size - 1))
|
ax_line.set_xlim(0, max(1, display_sweep.size - 1))
|
||||||
# Адаптивные Y-лимиты (если не задан --ylim)
|
# Адаптивные Y-лимиты (если не задан --ylim)
|
||||||
if fixed_ylim is None:
|
if fixed_ylim is None:
|
||||||
y0 = float(np.nanmin(current_sweep))
|
y0 = float(np.nanmin(display_sweep))
|
||||||
y1 = float(np.nanmax(current_sweep))
|
y1 = float(np.nanmax(display_sweep))
|
||||||
if np.isfinite(y0) and np.isfinite(y1):
|
if np.isfinite(y0) and np.isfinite(y1):
|
||||||
if y0 == y1:
|
if y0 == y1:
|
||||||
pad = max(1.0, abs(y0) * 0.05)
|
pad = max(1.0, abs(y0) * 0.05)
|
||||||
@ -484,7 +491,7 @@ def run_matplotlib(args):
|
|||||||
ax_line.set_ylim(y0, y1)
|
ax_line.set_ylim(y0, y1)
|
||||||
|
|
||||||
# Обновление спектра и фазы текущего свипа
|
# Обновление спектра и фазы текущего свипа
|
||||||
take_fft = min(int(current_sweep.size), FFT_LEN)
|
take_fft = min(int(display_sweep.size), FFT_LEN)
|
||||||
if take_fft > 0 and freq_shared is not None:
|
if take_fft > 0 and freq_shared is not None:
|
||||||
# Создаем буфер для полного FFT (с отрицательными частотами)
|
# Создаем буфер для полного FFT (с отрицательными частотами)
|
||||||
fft_in = np.zeros((FFT_LEN,), dtype=np.float32)
|
fft_in = np.zeros((FFT_LEN,), dtype=np.float32)
|
||||||
@ -500,7 +507,7 @@ def run_matplotlib(args):
|
|||||||
data_points = min(data_points, take_fft, FFT_LEN - start_idx)
|
data_points = min(data_points, take_fft, FFT_LEN - start_idx)
|
||||||
|
|
||||||
# Подготовка данных с окном Хэннинга
|
# Подготовка данных с окном Хэннинга
|
||||||
seg = np.nan_to_num(current_sweep[:data_points], nan=0.0).astype(np.float32, copy=False)
|
seg = np.nan_to_num(display_sweep[:data_points], nan=0.0).astype(np.float32, copy=False)
|
||||||
win = np.hanning(data_points).astype(np.float32)
|
win = np.hanning(data_points).astype(np.float32)
|
||||||
|
|
||||||
# Размещаем данные в правильной позиции
|
# Размещаем данные в правильной позиции
|
||||||
|
|||||||
Reference in New Issue
Block a user