new graph style
This commit is contained in:
@ -1019,31 +1019,24 @@ def main():
|
||||
xs = x_shared[: current_sweep_raw.size]
|
||||
else:
|
||||
xs = np.arange(current_sweep_raw.size, dtype=np.int32)
|
||||
line_obj.set_data(xs, current_sweep_raw)
|
||||
def _norm_to_max(data):
|
||||
m = float(np.nanmax(np.abs(data)))
|
||||
return data / m if m > 0.0 else data
|
||||
line_obj.set_data(xs, _norm_to_max(current_sweep_raw))
|
||||
if last_calib_sweep is not None:
|
||||
line_calib_obj.set_data(xs[: last_calib_sweep.size], last_calib_sweep)
|
||||
line_calib_obj.set_data(xs[: last_calib_sweep.size], _norm_to_max(last_calib_sweep))
|
||||
else:
|
||||
line_calib_obj.set_data([], [])
|
||||
if current_sweep_norm is not None:
|
||||
line_norm_obj.set_data(xs[: current_sweep_norm.size], current_sweep_norm)
|
||||
line_norm_obj.set_data(xs[: current_sweep_norm.size], _norm_to_max(current_sweep_norm))
|
||||
else:
|
||||
line_norm_obj.set_data([], [])
|
||||
# Лимиты по X постоянные под текущую ширину
|
||||
ax_line.set_xlim(0, max(1, current_sweep_raw.size - 1))
|
||||
# Адаптивные Y-лимиты (если не задан --ylim)
|
||||
# Фиксированные Y-лимиты после нормировки на максимум
|
||||
if fixed_ylim is None:
|
||||
y0 = float(np.nanmin(current_sweep_raw))
|
||||
y1 = float(np.nanmax(current_sweep_raw))
|
||||
if np.isfinite(y0) and np.isfinite(y1):
|
||||
if y0 == y1:
|
||||
pad = max(1.0, abs(y0) * 0.05)
|
||||
y0 -= pad
|
||||
y1 += pad
|
||||
else:
|
||||
pad = 0.05 * (y1 - y0)
|
||||
y0 -= pad
|
||||
y1 += pad
|
||||
ax_line.set_ylim(y0, y1)
|
||||
ax_line.set_ylim(-1.05, 1.05)
|
||||
ax_line.set_ylabel("/ max")
|
||||
|
||||
# Обновление спектра текущего свипа
|
||||
sweep_for_fft = current_sweep_norm if current_sweep_norm is not None else current_sweep_raw
|
||||
@ -1422,21 +1415,21 @@ def run_pyqtgraph(args):
|
||||
xs = x_shared[: current_sweep_raw.size]
|
||||
else:
|
||||
xs = np.arange(current_sweep_raw.size)
|
||||
curve.setData(xs, current_sweep_raw, autoDownsample=True)
|
||||
def _norm_to_max(data):
|
||||
m = float(np.nanmax(np.abs(data)))
|
||||
return data / m if m > 0.0 else data
|
||||
curve.setData(xs, _norm_to_max(current_sweep_raw), autoDownsample=True)
|
||||
if last_calib_sweep is not None:
|
||||
curve_calib.setData(xs[: last_calib_sweep.size], last_calib_sweep, autoDownsample=True)
|
||||
curve_calib.setData(xs[: last_calib_sweep.size], _norm_to_max(last_calib_sweep), autoDownsample=True)
|
||||
else:
|
||||
curve_calib.setData([], [])
|
||||
if current_sweep_norm is not None:
|
||||
curve_norm.setData(xs[: current_sweep_norm.size], current_sweep_norm, autoDownsample=True)
|
||||
curve_norm.setData(xs[: current_sweep_norm.size], _norm_to_max(current_sweep_norm), autoDownsample=True)
|
||||
else:
|
||||
curve_norm.setData([], [])
|
||||
if fixed_ylim is None:
|
||||
y0 = float(np.nanmin(current_sweep_raw))
|
||||
y1 = float(np.nanmax(current_sweep_raw))
|
||||
if np.isfinite(y0) and np.isfinite(y1):
|
||||
margin = 0.05 * max(1.0, (y1 - y0))
|
||||
p_line.setYRange(y0 - margin, y1 + margin, padding=0)
|
||||
p_line.setYRange(-1.05, 1.05, padding=0)
|
||||
p_line.setLabel("left", "/ max")
|
||||
|
||||
# Обновим спектр
|
||||
sweep_for_fft = current_sweep_norm if current_sweep_norm is not None else current_sweep_raw
|
||||
|
||||
Reference in New Issue
Block a user