This commit is contained in:
Ayzen
2026-05-05 15:45:52 +03:00
parent 5a70235ef3
commit e86f30023e
29 changed files with 1743 additions and 1797 deletions
+1
View File
@@ -214,6 +214,7 @@ class AppWindow(
self._refresh_preprocess_summary_labels()
self._apply_initial_radar_limits()
self._start_locator_service()
self._on_processing_mode_changed(self._processing_mode.currentText())
self._write_live_processing_config()
self._timer.start()
@@ -42,15 +42,13 @@ class AppWindowLiveProcessingMixin:
gpr_output_positions=self._parse_csv_int_list(self._gpr_output_positions_input.text()),
gpr_min_depth_m=float(self._gpr_min_depth_m.value()),
gpr_max_depth_m=float(self._gpr_max_depth_m.value()),
gpr_comp_power=float(self._gpr_comp_power.value()),
gpr_range_comp_power=float(self._gpr_range_comp_power.value()),
gpr_angle_comp_power=float(self._gpr_angle_comp_power.value()),
gpr_start_freq_mhz=float(self._gpr_start_freq_mhz.value()),
gpr_stop_freq_mhz=float(self._gpr_stop_freq_mhz.value()),
gpr_speed_m_s=float(self._gpr_speed_m_s.value()),
gpr_look_angle_deg=float(self._gpr_look_angle_deg.value()),
gpr_snr_thresh=float(self._gpr_snr_thresh.value()),
gpr_snr_comp_max=float(self._gpr_snr_comp_max.value()),
gpr_background_subtract_enabled=bool(self._gpr_background_subtract_enabled.isChecked()),
gpr_background_mean_count=int(self._gpr_background_mean_count.value()),
gpr_remove_sidelobe_objects_enabled=bool(self._gpr_remove_sidelobe_objects_enabled.isChecked()),
history_command_seq=int(self._history_command_seq),
history_command=str(history_command),
)
@@ -61,25 +59,25 @@ class AppWindowLiveProcessingMixin:
self._history_command_seq += 1
self._live_config_writer.write(self._live_processing_config(history_command=history_command))
def _apply_external_gpr_speed_update(self, speed_m_s: float) -> None:
"""Apply GPR speed received from locator clients without recursive signals."""
with QSignalBlocker(self._gpr_speed_m_s):
self._gpr_speed_m_s.setValue(float(speed_m_s))
self._write_live_processing_config()
def _on_processing_live_settings_changed(self, *_args) -> None:
"""Handle live-processing setting changes and trigger redraw when needed."""
try:
self._write_live_processing_config()
current_mode = self._processing_mode.currentText()
if current_mode == "gpr":
self._drain_results_until_quiet(timeout_s=0.05, poll_s=0.005)
self._write_live_processing_config()
if current_mode == "bscan":
self._drain_results_until_quiet(timeout_s=0.25, poll_s=0.01)
self._sync_bscan_history_from_results()
self._draw_bscan_heatmap_from_history()
elif current_mode == "gpr":
self._drain_results_until_quiet(timeout_s=0.35, poll_s=0.01)
if self._result_history:
if not self._draw_results(self._result_history[-1]):
latest = self._drain_results_until_quiet(timeout_s=0.8, poll_s=0.02)
collection = latest
if collection is None and self._result_history:
collection = self._result_history[-1]
if collection is not None:
if not self._draw_results(collection):
self._clear_gpr_plot()
else:
self._clear_gpr_plot()
@@ -121,6 +119,19 @@ class AppWindowLiveProcessingMixin:
except Exception as exc: # noqa: BLE001
self._show_exception("Failed to update locator GPR window", exc)
def _set_processing_mode_page(self, mode: str) -> None:
"""Show the parameter page for `mode` without changing runtime state."""
mode_to_page = {
"pass_through": 0,
"bscan": 1,
"gpr": 2,
}
self._processing_mode_pages.setCurrentIndex(mode_to_page.get(mode, 0))
current_page = self._processing_mode_pages.currentWidget()
if current_page is not None:
self._processing_mode_pages.setFixedHeight(current_page.sizeHint().height())
self._processing_mode_pages.updateGeometry()
def _on_processing_mode_changed(self, mode: str) -> None:
"""Switch processing parameter page and refresh corresponding visualization."""
previous_mode = getattr(self, "_active_processing_mode", "pass_through")
@@ -137,21 +148,12 @@ class AppWindowLiveProcessingMixin:
return
self._active_processing_mode = mode
mode_to_page = {
"pass_through": 0,
"bscan": 1,
"gpr": 2,
}
self._set_plot_mode(mode)
self._processing_mode_pages.setCurrentIndex(mode_to_page.get(mode, 0))
current_page = self._processing_mode_pages.currentWidget()
if current_page is not None:
self._processing_mode_pages.setFixedHeight(current_page.sizeHint().height())
self._processing_mode_pages.updateGeometry()
self._set_processing_mode_page(mode)
self._on_processing_live_settings_changed()
if mode == "gpr":
self._publish_locator_snapshot_from_latest_result()
elif previous_mode == "gpr":
elif previous_mode == "gpr" and self._locator_service is not None:
self._locator_service.publish_empty()
if mode == "pass_through":
self._log(
@@ -178,14 +180,13 @@ class AppWindowLiveProcessingMixin:
f"outputs={self._gpr_output_positions_input.text().strip() or '<all>'}, "
f"depth={self._gpr_min_depth_m.value():g}..{self._gpr_max_depth_m.value():g} m, "
f"freq={self._gpr_start_freq_mhz.value():g}..{self._gpr_stop_freq_mhz.value():g} MHz, "
f"speed={self._gpr_speed_m_s.value():g} m/s, "
f"look_angle={self._gpr_look_angle_deg.value():g} deg, "
f"snr_thresh={self._gpr_snr_thresh.value():g}, "
f"snr_comp_max={self._gpr_snr_comp_max.value():g}, "
f"range_comp={self._gpr_range_comp_power.value():g}, "
f"angle_comp={self._gpr_angle_comp_power.value():g}, "
f"background_subtract={self._gpr_background_subtract_enabled.isChecked()}, "
f"mean_count={self._gpr_background_mean_count.value()}, "
f"remove_sidelobes={self._gpr_remove_sidelobe_objects_enabled.isChecked()}, "
f"render_mode={self._gpr_render_mode.currentText()}, "
f"min_pairs={self._gpr_min_visible_pair_count.value()})"
f"min_score={self._gpr_min_visible_score.value():g})"
)
def _clear_history_mode_caches(self) -> None:
@@ -194,7 +194,6 @@ class AppWindowConfigProfileIOMixin:
self._bscan_start_freq_mhz,
self._bscan_stop_freq_mhz,
self._bscan_subtract_mean_ascan,
self._gpr_config_mode,
self._gpr_relative_permittivity,
self._gpr_tx_geometry_input,
self._gpr_rx_geometry_input,
@@ -202,17 +201,15 @@ class AppWindowConfigProfileIOMixin:
self._gpr_output_positions_input,
self._gpr_min_depth_m,
self._gpr_max_depth_m,
self._gpr_comp_power,
self._gpr_range_comp_power,
self._gpr_angle_comp_power,
self._gpr_start_freq_mhz,
self._gpr_stop_freq_mhz,
self._gpr_speed_m_s,
self._gpr_look_angle_deg,
self._gpr_snr_thresh,
self._gpr_snr_comp_max,
self._gpr_background_subtract_enabled,
self._gpr_background_mean_count,
self._gpr_remove_sidelobe_objects_enabled,
self._gpr_render_mode,
self._gpr_min_visible_pair_count,
self._gpr_min_visible_score,
self._gpr_visible_x_min_m,
self._gpr_visible_x_max_m,
self._gpr_visible_z_min_m,
@@ -253,7 +250,6 @@ class AppWindowConfigProfileIOMixin:
self._bscan_stop_freq_mhz.setValue(float(gui_state.processing.bscan.stop_freq_mhz))
self._bscan_subtract_mean_ascan.setChecked(bool(gui_state.processing.bscan.subtract_mean_ascan))
self._set_combo_current_text(self._gpr_config_mode, str(config.gpr.mode))
self._gpr_relative_permittivity.setValue(float(config.gpr.relative_permittivity))
self._gpr_tx_geometry_input.setPlainText(
"\n".join(
@@ -271,19 +267,19 @@ class AppWindowConfigProfileIOMixin:
self._gpr_output_positions_input.setText(str(gui_state.processing.gpr.output_positions))
self._gpr_min_depth_m.setValue(float(gui_state.processing.gpr.min_depth_m))
self._gpr_max_depth_m.setValue(float(gui_state.processing.gpr.max_depth_m))
self._gpr_comp_power.setValue(float(gui_state.processing.gpr.comp_power))
self._gpr_range_comp_power.setValue(float(gui_state.processing.gpr.range_comp_power))
self._gpr_angle_comp_power.setValue(float(gui_state.processing.gpr.angle_comp_power))
self._gpr_start_freq_mhz.setValue(float(gui_state.processing.gpr.start_freq_mhz))
self._gpr_stop_freq_mhz.setValue(float(gui_state.processing.gpr.stop_freq_mhz))
self._gpr_speed_m_s.setValue(float(gui_state.processing.gpr.speed_m_s))
self._gpr_look_angle_deg.setValue(float(gui_state.processing.gpr.look_angle_deg))
self._gpr_snr_thresh.setValue(float(gui_state.processing.gpr.snr_thresh))
self._gpr_snr_comp_max.setValue(float(gui_state.processing.gpr.snr_comp_max))
self._gpr_background_subtract_enabled.setChecked(
bool(gui_state.processing.gpr.background_subtract_enabled)
)
self._gpr_background_mean_count.setValue(int(gui_state.processing.gpr.background_mean_count))
self._gpr_remove_sidelobe_objects_enabled.setChecked(
bool(gui_state.processing.gpr.remove_sidelobe_objects_enabled)
)
self._set_combo_current_text(self._gpr_render_mode, gui_state.processing.gpr.render_mode)
self._gpr_min_visible_pair_count.setValue(int(gui_state.processing.gpr.min_visible_pair_count))
self._gpr_min_visible_score.setValue(float(gui_state.processing.gpr.min_visible_score))
self._gpr_visible_x_min_m.setValue(float(gui_state.processing.gpr.visible_x_min_m))
self._gpr_visible_x_max_m.setValue(float(gui_state.processing.gpr.visible_x_max_m))
self._gpr_visible_z_min_m.setValue(float(gui_state.processing.gpr.visible_z_min_m))
@@ -169,17 +169,15 @@ class AppWindowConfigStateBuildersMixin:
output_positions=self._default_gpr_output_positions_from_config(config),
min_depth_m=2.0,
max_depth_m=14.0,
comp_power=0.2,
range_comp_power=0.28,
angle_comp_power=0.10,
start_freq_mhz=3000.0,
stop_freq_mhz=6000.0,
speed_m_s=0.0,
look_angle_deg=0.0,
snr_thresh=4.5,
snr_comp_max=25.0,
background_subtract_enabled=True,
background_mean_count=10,
remove_sidelobe_objects_enabled=True,
render_mode="heatmap",
min_visible_pair_count=1,
min_visible_score=0.0,
visible_x_min_m=default_gpr_x_min_m,
visible_x_max_m=default_gpr_x_max_m,
visible_z_min_m=0.0,
@@ -258,17 +256,15 @@ class AppWindowConfigStateBuildersMixin:
output_positions=self._gpr_output_positions_input.text().strip(),
min_depth_m=float(self._gpr_min_depth_m.value()),
max_depth_m=float(self._gpr_max_depth_m.value()),
comp_power=float(self._gpr_comp_power.value()),
range_comp_power=float(self._gpr_range_comp_power.value()),
angle_comp_power=float(self._gpr_angle_comp_power.value()),
start_freq_mhz=float(self._gpr_start_freq_mhz.value()),
stop_freq_mhz=float(self._gpr_stop_freq_mhz.value()),
speed_m_s=float(self._gpr_speed_m_s.value()),
look_angle_deg=float(self._gpr_look_angle_deg.value()),
snr_thresh=float(self._gpr_snr_thresh.value()),
snr_comp_max=float(self._gpr_snr_comp_max.value()),
background_subtract_enabled=bool(self._gpr_background_subtract_enabled.isChecked()),
background_mean_count=int(self._gpr_background_mean_count.value()),
remove_sidelobe_objects_enabled=bool(self._gpr_remove_sidelobe_objects_enabled.isChecked()),
render_mode=self._gpr_render_mode.currentText(),
min_visible_pair_count=int(self._gpr_min_visible_pair_count.value()),
min_visible_score=float(self._gpr_min_visible_score.value()),
visible_x_min_m=float(self._gpr_visible_x_min_m.value()),
visible_x_max_m=float(self._gpr_visible_x_max_m.value()),
visible_z_min_m=float(self._gpr_visible_z_min_m.value()),
@@ -323,14 +319,13 @@ class AppWindowConfigStateBuildersMixin:
combo_text = self._combos_text.text()
config.combos = parse_combos_from_text(combo_text)
config.ensure_combos()
if self._switches_are_effectively_static(config):
if self._processing_mode.currentText() != "gpr" and self._switches_are_effectively_static(config):
config.combos = [ComboModel(input=0, output=0)]
for key in PREPROCESS_ASSET_KEYS:
preprocess_asset_model(config, key).bundle_path = ""
for key in VISIBLE_PREPROCESS_ASSET_KEYS:
preprocess_asset_model(config, key).set_name = self._selected_preprocess_sets.get(key, "")
config.gpr.mode = self._gpr_config_mode.currentText()
config.gpr.relative_permittivity = float(self._gpr_relative_permittivity.value())
config.gpr.tx_geometry = self._parse_gpr_tx_geometry_text(self._gpr_tx_geometry_input.toPlainText())
config.gpr.rx_geometry = self._parse_gpr_rx_geometry_text(self._gpr_rx_geometry_input.toPlainText())
@@ -378,7 +373,7 @@ class AppWindowConfigStateBuildersMixin:
@staticmethod
def _switches_are_effectively_static(config: RunConfigModel) -> bool:
"""Return `True` when switch setup effectively yields one fixed combo."""
"""Return `True` when non-GPR switch setup effectively yields one fixed combo."""
if config.is_multi_device:
return False
has_single_position = config.input_switch.positions <= 1 and config.output_switch.positions <= 1
@@ -399,21 +399,25 @@ class AppWindowPipelineMixin:
previous = current
time.sleep(poll_s)
def _drain_results_until_quiet(self, *, timeout_s: float, poll_s: float) -> None:
"""Drain only results ring until size stabilizes or timeout expires."""
def _drain_results_until_quiet(self, *, timeout_s: float, poll_s: float) -> ResultCollection | None:
"""Drain results until at least one result arrives and the ring becomes quiet."""
if self._result_reader is None:
return
return None
deadline = time.monotonic() + timeout_s
stable_rounds = 0
latest_seen: ResultCollection | None = None
while time.monotonic() < deadline and stable_rounds < 2:
while time.monotonic() < deadline and (latest_seen is None or stable_rounds < 2):
latest = self._read_all_results()
if latest is None:
stable_rounds += 1
if latest_seen is not None:
stable_rounds += 1
else:
latest_seen = latest
stable_rounds = 0
time.sleep(poll_s)
return latest_seen
def _update_history_indicator(self) -> None:
"""Update UI label with current history buffer sizes."""
@@ -466,22 +470,25 @@ class AppWindowPipelineMixin:
)
def _drain_locator_speed_updates(self) -> None:
"""Apply queued speed updates received by the embedded locator server."""
latest_speed = self._locator_service.drain_speed_updates()
if latest_speed is None:
"""Drain queued locator speed packets; coherent BP does not use motion speed."""
if self._locator_service is None:
return
self._apply_external_gpr_speed_update(0.0) # TODO: remove temporary stub and apply real locator client speed.
self._locator_service.drain_speed_updates()
def _publish_locator_snapshot_from_collection(self, collection: ResultCollection) -> None:
"""Publish one locator snapshot from a GPR result collection."""
if self._locator_service is None:
return
self._locator_service.publish_collection(
collection,
float(self._gpr_min_visible_pair_count.value()),
float(self._gpr_min_visible_score.value()),
visible_bounds=self._gpr_visible_object_bounds(),
)
def _publish_locator_snapshot_from_latest_result(self) -> None:
"""Publish current locator-visible snapshot from latest cached GPR result."""
if self._locator_service is None:
return
if self._processing_mode.currentText() != "gpr":
self._locator_service.publish_empty()
return
@@ -39,7 +39,7 @@ class AppWindowGprPlotMixin:
if self._gpr_region_centers_item is not None:
self._gpr_region_centers_item.setData(x=[], y=[])
self._gpr_region_centers_item.hide()
self._gpr_plot.setTitle(f"GPR {self._gpr_config_mode.currentText()}")
self._gpr_plot.setTitle("GPR coherent BP")
def _configure_gpr_plot_axes(self) -> None:
"""Apply persistent GPR plot axis labels and base view settings."""
@@ -53,6 +53,29 @@ class AppWindowGprPlotMixin:
view_box = plot.getViewBox()
view_box.invertY(False)
view_box.enableAutoRange(x=False, y=False)
self._disable_gpr_plot_interaction(plot, view_box)
@staticmethod
def _disable_gpr_plot_interaction(plot: pg.PlotWidget, view_box: pg.ViewBox) -> None:
"""Disable mouse-driven GPR pan/zoom; ranges are controlled by widgets."""
AppWindowGprPlotMixin._call_if_present(plot, "setMouseEnabled", x=False, y=False)
AppWindowGprPlotMixin._call_if_present(plot, "setMenuEnabled", False)
AppWindowGprPlotMixin._call_if_present(plot.getPlotItem(), "hideButtons")
AppWindowGprPlotMixin._call_if_present(view_box, "setMouseEnabled", x=False, y=False)
AppWindowGprPlotMixin._call_if_present(view_box, "setMenuEnabled", False)
for axis_name in ("bottom", "left"):
AppWindowGprPlotMixin._call_if_present(
plot.getPlotItem().getAxis(axis_name),
"setMouseEnabled",
False,
)
@staticmethod
def _call_if_present(obj: object, method_name: str, *args, **kwargs) -> None:
"""Call optional pyqtgraph API when available in the installed version."""
method = getattr(obj, method_name, None)
if method is not None:
method(*args, **kwargs)
def _ensure_gpr_plot_items(self) -> None:
"""Create persistent GPR plot items once and reuse them on redraw."""
@@ -209,8 +232,9 @@ class AppWindowGprPlotMixin:
self._gpr_image_item.setLevels((float(np.min(image)), float(np.max(image) + 1e-6)))
self._gpr_image_item.show()
plot.setXRange(x_min, x_max, padding=0.02)
plot.setYRange(self._gpr_display_y_min(y_min, y_max), y_max, padding=0.02)
visible_x_min, visible_x_max, visible_z_min, visible_z_max = self._gpr_visible_bounds()
plot.setXRange(visible_x_min, visible_x_max, padding=0.0)
plot.setYRange(self._gpr_display_y_min(visible_z_min, visible_z_max), visible_z_max, padding=0.0)
self._draw_gpr_geometry_markers()
@@ -227,7 +251,7 @@ class AppWindowGprPlotMixin:
)
self._gpr_points_item.show()
for x_value, y_value, score in points:
label = pg.TextItem(text=f"{float(score):.0f}", color="#ffffff", anchor=(0.0, 1.0))
label = pg.TextItem(text=f"{float(score):.2f}", color="#ffffff", anchor=(0.0, 1.0))
label.setZValue(40)
label.setPos(float(x_value), float(y_value))
plot.addItem(label)
@@ -273,7 +297,7 @@ class AppWindowGprPlotMixin:
self._gpr_region_mask_items.append(mask_image)
self._gpr_region_contours.append(contour)
plot.setTitle(f"GPR {self._gpr_config_mode.currentText()}")
plot.setTitle("GPR coherent BP")
finally:
plot.setUpdatesEnabled(True)
return True
@@ -289,8 +313,8 @@ class AppWindowGprPlotMixin:
half_span = 0.5 * minimum_span
return center - half_span, center + half_span
def _gpr_visible_object_bounds(self) -> tuple[float, float, float, float]:
"""Return normalized object-only visible X/Z bounds from GUI controls."""
def _gpr_visible_bounds(self) -> tuple[float, float, float, float]:
"""Return normalized GPR visible X/Z bounds from GUI controls."""
x_min, x_max = self._normalized_display_range(
float(self._gpr_visible_x_min_m.value()),
float(self._gpr_visible_x_max_m.value()),
@@ -303,11 +327,17 @@ class AppWindowGprPlotMixin:
)
return x_min, x_max, z_min, z_max
def _gpr_visible_object_bounds(self) -> tuple[float, float, float, float]:
"""Return normalized object/locator visible X/Z bounds from GUI controls."""
return self._gpr_visible_bounds()
@staticmethod
def _gpr_display_y_min(z_min: float, z_max: float) -> float:
"""Return lower GPR display bound with a small negative margin for antenna markers."""
lower = min(0.0, float(z_min))
span = max(float(z_max) - float(z_min), 1e-6)
"""Return lower display bound, preserving surface markers only when surface is visible."""
lower = float(z_min)
if lower > 0.0:
return lower
span = max(float(z_max) - lower, 1e-6)
marker_margin = max(span * 0.03, 0.06)
return lower - marker_margin
@@ -343,9 +373,9 @@ class AppWindowGprPlotMixin:
self._gpr_rx_item.hide()
@staticmethod
def _format_gpr_object_label(x_m: float, z_m: float, pair_count: float) -> str:
"""Format object-only annotation text with pair count and coordinates."""
return f"{int(round(pair_count))} | x={x_m:.1f} | z={z_m:.1f}"
def _format_gpr_object_label(x_m: float, z_m: float, score: float) -> str:
"""Format object-only annotation text with normalized BP score and coordinates."""
return f"{score:.2f} | x={x_m:.1f} | z={z_m:.1f}"
@staticmethod
def _expanded_scene_rect(rect: QRectF, *, padding_px: float = 4.0) -> QRectF:
@@ -411,7 +441,7 @@ class AppWindowGprPlotMixin:
occupied_scene_rects.append(last_rect)
def _gpr_object_rows(self, collection: ResultCollection) -> np.ndarray:
"""Return object rows as `[x_m, z_m, pair_count]` from current GPR result payload."""
"""Return object rows as `[x_m, z_m, score]` from current GPR result payload."""
return extract_gpr_object_rows(collection)
def _filtered_gpr_object_rows(self, collection: ResultCollection) -> np.ndarray:
@@ -421,11 +451,11 @@ class AppWindowGprPlotMixin:
return rows
x_min, x_max, z_min, z_max = self._gpr_visible_object_bounds()
min_pair_count = float(self._gpr_min_visible_pair_count.value())
min_score = float(self._gpr_min_visible_score.value())
finite_mask = np.all(np.isfinite(rows[:, :3]), axis=1)
visible_mask = (
finite_mask
& (rows[:, 2] >= min_pair_count)
& (rows[:, 2] >= min_score)
& (rows[:, 0] >= x_min)
& (rows[:, 0] <= x_max)
& (rows[:, 1] >= z_min)
@@ -470,12 +500,12 @@ class AppWindowGprPlotMixin:
occupied_scene_rects: list[QRectF] = []
x_span = x_max - x_min
z_span = z_max - z_min
for x_value, z_value, pair_count in object_rows:
for x_value, z_value, score in object_rows:
label = pg.TextItem(
text=self._format_gpr_object_label(
float(x_value),
float(z_value),
float(pair_count),
float(score),
),
color="#ffd6d9",
anchor=(0.0, 1.0),
@@ -497,7 +527,7 @@ class AppWindowGprPlotMixin:
plot.setXRange(x_min, x_max, padding=0.0)
plot.setYRange(self._gpr_display_y_min(z_min, z_max), z_max, padding=0.0)
plot.setTitle(f"GPR {self._gpr_config_mode.currentText()} Objects Only")
plot.setTitle("GPR coherent BP Objects Only")
finally:
plot.setUpdatesEnabled(True)
return True
@@ -154,10 +154,6 @@ def build_processing_group(owner) -> QGroupBox:
gpr_defaults = owner._defaults_config.gpr
owner._gpr_config_mode = QComboBox()
owner._gpr_config_mode.addItems(["point", "extended"])
owner._set_combo_current_text(owner._gpr_config_mode, gpr_defaults.mode)
owner._gpr_relative_permittivity = QDoubleSpinBox()
owner._gpr_relative_permittivity.setDecimals(4)
owner._gpr_relative_permittivity.setRange(0.0001, 1000.0)
@@ -190,11 +186,17 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_max_depth_m.setSingleStep(0.1)
owner._gpr_max_depth_m.setValue(float(gpr_live_defaults.max_depth_m))
owner._gpr_comp_power = QDoubleSpinBox()
owner._gpr_comp_power.setDecimals(3)
owner._gpr_comp_power.setRange(0.0, 5.0)
owner._gpr_comp_power.setSingleStep(0.05)
owner._gpr_comp_power.setValue(float(gpr_live_defaults.comp_power))
owner._gpr_range_comp_power = QDoubleSpinBox()
owner._gpr_range_comp_power.setDecimals(3)
owner._gpr_range_comp_power.setRange(0.0, 5.0)
owner._gpr_range_comp_power.setSingleStep(0.01)
owner._gpr_range_comp_power.setValue(float(gpr_live_defaults.range_comp_power))
owner._gpr_angle_comp_power = QDoubleSpinBox()
owner._gpr_angle_comp_power.setDecimals(3)
owner._gpr_angle_comp_power.setRange(0.0, 5.0)
owner._gpr_angle_comp_power.setSingleStep(0.01)
owner._gpr_angle_comp_power.setValue(float(gpr_live_defaults.angle_comp_power))
owner._gpr_start_freq_mhz = QDoubleSpinBox()
owner._gpr_start_freq_mhz.setDecimals(1)
@@ -208,30 +210,6 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_stop_freq_mhz.setSingleStep(10.0)
owner._gpr_stop_freq_mhz.setValue(float(gpr_live_defaults.stop_freq_mhz))
owner._gpr_speed_m_s = QDoubleSpinBox()
owner._gpr_speed_m_s.setDecimals(3)
owner._gpr_speed_m_s.setRange(-100.0, 100.0)
owner._gpr_speed_m_s.setSingleStep(0.01)
owner._gpr_speed_m_s.setValue(float(gpr_live_defaults.speed_m_s))
owner._gpr_look_angle_deg = QDoubleSpinBox()
owner._gpr_look_angle_deg.setDecimals(2)
owner._gpr_look_angle_deg.setRange(-90.0, 90.0)
owner._gpr_look_angle_deg.setSingleStep(0.1)
owner._gpr_look_angle_deg.setValue(float(gpr_live_defaults.look_angle_deg))
owner._gpr_snr_thresh = QDoubleSpinBox()
owner._gpr_snr_thresh.setDecimals(2)
owner._gpr_snr_thresh.setRange(0.0, 1_000.0)
owner._gpr_snr_thresh.setSingleStep(0.1)
owner._gpr_snr_thresh.setValue(float(gpr_live_defaults.snr_thresh))
owner._gpr_snr_comp_max = QDoubleSpinBox()
owner._gpr_snr_comp_max.setDecimals(2)
owner._gpr_snr_comp_max.setRange(0.0, 1_000.0)
owner._gpr_snr_comp_max.setSingleStep(0.5)
owner._gpr_snr_comp_max.setValue(float(gpr_live_defaults.snr_comp_max))
owner._gpr_background_subtract_enabled = QCheckBox("Subtract mean of previous collections")
owner._gpr_background_subtract_enabled.setChecked(bool(gpr_live_defaults.background_subtract_enabled))
@@ -239,13 +217,18 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_background_mean_count.setRange(0, 10_000)
owner._gpr_background_mean_count.setValue(int(gpr_live_defaults.background_mean_count))
owner._gpr_remove_sidelobe_objects_enabled = QCheckBox("Remove sidelobe objects")
owner._gpr_remove_sidelobe_objects_enabled.setChecked(bool(gpr_live_defaults.remove_sidelobe_objects_enabled))
owner._gpr_render_mode = QComboBox()
owner._gpr_render_mode.addItems(["heatmap", "objects_only"])
owner._set_combo_current_text(owner._gpr_render_mode, gpr_live_defaults.render_mode)
owner._gpr_min_visible_pair_count = QSpinBox()
owner._gpr_min_visible_pair_count.setRange(1, 10_000)
owner._gpr_min_visible_pair_count.setValue(int(gpr_live_defaults.min_visible_pair_count))
owner._gpr_min_visible_score = QDoubleSpinBox()
owner._gpr_min_visible_score.setDecimals(2)
owner._gpr_min_visible_score.setRange(0.0, 1.0)
owner._gpr_min_visible_score.setSingleStep(0.05)
owner._gpr_min_visible_score.setValue(float(gpr_live_defaults.min_visible_score))
owner._gpr_visible_x_min_m = QDoubleSpinBox()
owner._gpr_visible_x_min_m.setDecimals(2)
@@ -274,31 +257,28 @@ def build_processing_group(owner) -> QGroupBox:
gpr_page = _build_processing_mode_page(
owner._processing_mode_pages,
[
("Config mode", owner._gpr_config_mode),
("Relative permittivity", owner._gpr_relative_permittivity),
("Input positions", owner._gpr_input_positions_input),
("Output positions", owner._gpr_output_positions_input),
("Min depth m", owner._gpr_min_depth_m),
("Max depth m", owner._gpr_max_depth_m),
("Comp power", owner._gpr_comp_power),
("SNR thresh", owner._gpr_snr_thresh),
("SNR comp max", owner._gpr_snr_comp_max),
("Speed m/s", owner._gpr_speed_m_s),
("Range comp power", owner._gpr_range_comp_power),
("Angle comp power", owner._gpr_angle_comp_power),
("Render mode", owner._gpr_render_mode),
("Min visible pairs", owner._gpr_min_visible_pair_count),
("Min visible score", owner._gpr_min_visible_score),
("Tx geometry", owner._gpr_tx_geometry_input),
("Rx geometry", owner._gpr_rx_geometry_input),
("Start MHz", owner._gpr_start_freq_mhz),
("Stop MHz", owner._gpr_stop_freq_mhz),
("Look angle deg", owner._gpr_look_angle_deg),
("Visible X min m", owner._gpr_visible_x_min_m),
("Visible X max m", owner._gpr_visible_x_max_m),
("Visible Z min m", owner._gpr_visible_z_min_m),
("Visible Z max m", owner._gpr_visible_z_max_m),
owner._gpr_background_subtract_enabled,
("Mean count", owner._gpr_background_mean_count),
owner._gpr_remove_sidelobe_objects_enabled,
],
split_index=11,
split_index=10,
)
owner._processing_mode_pages.addWidget(gpr_page)
@@ -323,21 +303,19 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_output_positions_input.editingFinished.connect(owner._on_processing_live_settings_changed)
owner._gpr_min_depth_m.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_max_depth_m.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_comp_power.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_range_comp_power.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_angle_comp_power.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_start_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_stop_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_speed_m_s.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_look_angle_deg.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_snr_thresh.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_snr_comp_max.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_background_subtract_enabled.toggled.connect(owner._on_processing_live_settings_changed)
owner._gpr_background_mean_count.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_remove_sidelobe_objects_enabled.toggled.connect(owner._on_processing_live_settings_changed)
owner._gpr_render_mode.currentTextChanged.connect(owner._on_gpr_visual_settings_changed)
owner._gpr_min_visible_pair_count.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
owner._gpr_min_visible_score.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
owner._gpr_visible_x_min_m.valueChanged.connect(owner._on_gpr_locator_window_changed)
owner._gpr_visible_x_max_m.valueChanged.connect(owner._on_gpr_locator_window_changed)
owner._gpr_visible_z_min_m.valueChanged.connect(owner._on_gpr_locator_window_changed)
owner._gpr_visible_z_max_m.valueChanged.connect(owner._on_gpr_locator_window_changed)
owner._on_processing_mode_changed(owner._processing_mode.currentText())
owner._set_processing_mode_page(owner._processing_mode.currentText())
return group
+28 -42
View File
@@ -184,10 +184,16 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
gui.processing.gpr.max_depth_m,
"gui.processing.gpr",
),
comp_power=_optional_float(
range_comp_power=_optional_float(
gpr_object,
"comp_power",
gui.processing.gpr.comp_power,
"range_comp_power",
gui.processing.gpr.range_comp_power,
"gui.processing.gpr",
),
angle_comp_power=_optional_float(
gpr_object,
"angle_comp_power",
gui.processing.gpr.angle_comp_power,
"gui.processing.gpr",
),
start_freq_mhz=_optional_float(
@@ -202,30 +208,6 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
gui.processing.gpr.stop_freq_mhz,
"gui.processing.gpr",
),
speed_m_s=_optional_float(
gpr_object,
"speed_m_s",
gui.processing.gpr.speed_m_s,
"gui.processing.gpr",
),
look_angle_deg=_optional_float(
gpr_object,
"look_angle_deg",
gui.processing.gpr.look_angle_deg,
"gui.processing.gpr",
),
snr_thresh=_optional_float(
gpr_object,
"snr_thresh",
gui.processing.gpr.snr_thresh,
"gui.processing.gpr",
),
snr_comp_max=_optional_float(
gpr_object,
"snr_comp_max",
gui.processing.gpr.snr_comp_max,
"gui.processing.gpr",
),
background_subtract_enabled=_optional_bool(
gpr_object,
"background_subtract_enabled",
@@ -238,16 +220,22 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
gui.processing.gpr.background_mean_count,
"gui.processing.gpr",
),
remove_sidelobe_objects_enabled=_optional_bool(
gpr_object,
"remove_sidelobe_objects_enabled",
gui.processing.gpr.remove_sidelobe_objects_enabled,
"gui.processing.gpr",
),
render_mode=_optional_string(
gpr_object,
"render_mode",
gui.processing.gpr.render_mode,
"gui.processing.gpr",
),
min_visible_pair_count=_optional_int(
min_visible_score=_optional_float(
gpr_object,
"min_visible_pair_count",
gui.processing.gpr.min_visible_pair_count,
"min_visible_score",
gui.processing.gpr.min_visible_score,
"gui.processing.gpr",
),
visible_x_min_m=_optional_float(
@@ -282,12 +270,12 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
raise ValueError("gui.processing.bscan.axis must be one of: abs, real, phase")
if gui.processing.gpr.render_mode not in {"heatmap", "objects_only"}:
raise ValueError("gui.processing.gpr.render_mode must be one of: heatmap, objects_only")
if gui.processing.gpr.snr_thresh < 0.0:
raise ValueError("gui.processing.gpr.snr_thresh must be >= 0")
if gui.processing.gpr.snr_comp_max < 0.0:
raise ValueError("gui.processing.gpr.snr_comp_max must be >= 0")
if gui.processing.gpr.min_visible_pair_count < 1:
raise ValueError("gui.processing.gpr.min_visible_pair_count must be >= 1")
if gui.processing.gpr.range_comp_power < 0.0:
raise ValueError("gui.processing.gpr.range_comp_power must be >= 0")
if gui.processing.gpr.angle_comp_power < 0.0:
raise ValueError("gui.processing.gpr.angle_comp_power must be >= 0")
if gui.processing.gpr.min_visible_score < 0.0:
raise ValueError("gui.processing.gpr.min_visible_score must be >= 0")
data_actions_object = _as_dict(gui_object.get("data_actions"), "gui.data_actions")
gui.data_actions = GuiDataActionsStateModel(
@@ -372,17 +360,15 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]:
"output_positions": gui.processing.gpr.output_positions,
"min_depth_m": gui.processing.gpr.min_depth_m,
"max_depth_m": gui.processing.gpr.max_depth_m,
"comp_power": gui.processing.gpr.comp_power,
"range_comp_power": gui.processing.gpr.range_comp_power,
"angle_comp_power": gui.processing.gpr.angle_comp_power,
"start_freq_mhz": gui.processing.gpr.start_freq_mhz,
"stop_freq_mhz": gui.processing.gpr.stop_freq_mhz,
"speed_m_s": gui.processing.gpr.speed_m_s,
"look_angle_deg": gui.processing.gpr.look_angle_deg,
"snr_thresh": gui.processing.gpr.snr_thresh,
"snr_comp_max": gui.processing.gpr.snr_comp_max,
"background_subtract_enabled": gui.processing.gpr.background_subtract_enabled,
"background_mean_count": gui.processing.gpr.background_mean_count,
"remove_sidelobe_objects_enabled": gui.processing.gpr.remove_sidelobe_objects_enabled,
"render_mode": gui.processing.gpr.render_mode,
"min_visible_pair_count": gui.processing.gpr.min_visible_pair_count,
"min_visible_score": gui.processing.gpr.min_visible_score,
"visible_x_min_m": gui.processing.gpr.visible_x_min_m,
"visible_x_max_m": gui.processing.gpr.visible_x_max_m,
"visible_z_min_m": gui.processing.gpr.visible_z_min_m,
+4 -6
View File
@@ -53,17 +53,15 @@ class GuiGprStateModel:
output_positions: str = ""
min_depth_m: float = 2.0
max_depth_m: float = 14.0
comp_power: float = 0.2
range_comp_power: float = 0.28
angle_comp_power: float = 0.10
start_freq_mhz: float = 3000.0
stop_freq_mhz: float = 6000.0
speed_m_s: float = 0.0
look_angle_deg: float = 0.0
snr_thresh: float = 4.5
snr_comp_max: float = 25.0
background_subtract_enabled: bool = True
background_mean_count: int = 10
remove_sidelobe_objects_enabled: bool = True
render_mode: str = "heatmap"
min_visible_pair_count: int = 1
min_visible_score: float = 0.0
visible_x_min_m: float = -2.0
visible_x_max_m: float = 2.0
visible_z_min_m: float = 0.0
-2
View File
@@ -179,7 +179,6 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
if isinstance(band, (list, tuple)) and len(band) == 2:
model.preprocess.notch.bands_hz.append((float(band[0]), float(band[1])))
model.gpr.mode = str(gpr_payload.get("mode", model.gpr.mode))
model.gpr.relative_permittivity = float(
gpr_payload.get("relative_permittivity", model.gpr.relative_permittivity)
)
@@ -339,7 +338,6 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
},
},
"gpr": {
"mode": model.gpr.mode,
"relative_permittivity": model.gpr.relative_permittivity,
"tx_geometry": [
{
-1
View File
@@ -183,7 +183,6 @@ class GprRxGeometryModel:
class GprModel:
"""Stable GPR configuration saved in run_config.json."""
mode: str = "point"
relative_permittivity: float = 1.0
tx_geometry: list[GprTxGeometryModel] = field(default_factory=list)
rx_geometry: list[GprRxGeometryModel] = field(default_factory=list)
@@ -37,8 +37,6 @@ def validate_gpr_model(
output_switch_positions: int,
) -> None:
"""Validate stable GPR config against current switch dimensions."""
if gpr.mode not in {"point", "extended"}:
raise ValueError("gpr.mode must be either 'point' or 'extended'")
if float(gpr.relative_permittivity) <= 0.0:
raise ValueError("gpr.relative_permittivity must be > 0")
+5 -5
View File
@@ -50,7 +50,7 @@ def collection_has_gpr_payloads(collection: ResultCollection) -> bool:
def gpr_object_rows(collection: ResultCollection) -> np.ndarray:
"""Return object rows as `[x_m, z_m, pair_count]` from a GPR collection."""
"""Return object rows as `[x_m, z_m, score]` from a GPR collection."""
points_payload = collection_payload_by_name(collection, "gpr_points", kind=4)
if points_payload is not None:
points = np.asarray(points_payload.table, dtype=np.float32)
@@ -68,17 +68,17 @@ def gpr_object_rows(collection: ResultCollection) -> np.ndarray:
def locator_observations_from_collection(
collection: ResultCollection,
min_pair_count: float,
min_score: float,
*,
visible_bounds: tuple[float, float, float, float] | None = None,
) -> list[dict[str, float]]:
"""Build locator observations from GPR rows using pair threshold and optional X/Z bounds."""
"""Build locator observations from GPR rows using score threshold and optional X/Z bounds."""
rows = gpr_object_rows(collection)
if rows.size == 0:
return []
finite_mask = np.all(np.isfinite(rows[:, :3]), axis=1)
visible_mask = finite_mask & (rows[:, 2] >= float(min_pair_count))
visible_mask = finite_mask & (rows[:, 2] >= float(min_score))
if visible_bounds is not None:
x_min, x_max, z_min, z_max = (float(value) for value in visible_bounds)
visible_mask &= (
@@ -90,7 +90,7 @@ def locator_observations_from_collection(
filtered = rows[visible_mask]
observations: list[dict[str, float]] = []
for x_m, z_m, _pair_count in filtered:
for x_m, z_m, _score in filtered:
observations.append(
{
"dst": round(float(z_m), 2),
@@ -27,15 +27,13 @@ class ProcessingLiveConfig:
gpr_output_positions: list[int] | None = None
gpr_min_depth_m: float = 2.0
gpr_max_depth_m: float = 14.0
gpr_comp_power: float = 0.2
gpr_range_comp_power: float = 0.28
gpr_angle_comp_power: float = 0.10
gpr_start_freq_mhz: float = 3000.0
gpr_stop_freq_mhz: float = 6000.0
gpr_speed_m_s: float = 0.0
gpr_look_angle_deg: float = 0.0
gpr_snr_thresh: float = 4.5
gpr_snr_comp_max: float = 25.0
gpr_background_subtract_enabled: bool = True
gpr_background_mean_count: int = 10
gpr_remove_sidelobe_objects_enabled: bool = True
history_command_seq: int = 0
history_command: str = "none"
@@ -69,15 +67,13 @@ class ProcessingLiveConfig:
"gpr_output_positions": [int(value) for value in self.gpr_output_positions],
"gpr_min_depth_m": float(self.gpr_min_depth_m),
"gpr_max_depth_m": float(self.gpr_max_depth_m),
"gpr_comp_power": float(self.gpr_comp_power),
"gpr_range_comp_power": float(self.gpr_range_comp_power),
"gpr_angle_comp_power": float(self.gpr_angle_comp_power),
"gpr_start_freq_mhz": float(self.gpr_start_freq_mhz),
"gpr_stop_freq_mhz": float(self.gpr_stop_freq_mhz),
"gpr_speed_m_s": float(self.gpr_speed_m_s),
"gpr_look_angle_deg": float(self.gpr_look_angle_deg),
"gpr_snr_thresh": float(self.gpr_snr_thresh),
"gpr_snr_comp_max": float(self.gpr_snr_comp_max),
"gpr_background_subtract_enabled": bool(self.gpr_background_subtract_enabled),
"gpr_background_mean_count": int(self.gpr_background_mean_count),
"gpr_remove_sidelobe_objects_enabled": bool(self.gpr_remove_sidelobe_objects_enabled),
"history_command_seq": int(self.history_command_seq),
"history_command": str(self.history_command),
}
+2 -2
View File
@@ -183,14 +183,14 @@ class LocatorTcpService:
def publish_collection(
self,
collection: ResultCollection,
min_pair_count: float,
min_score: float,
*,
visible_bounds: tuple[float, float, float, float] | None = None,
) -> None:
"""Publish one locator payload derived from a GPR result collection."""
observations = locator_observations_from_collection(
collection,
min_pair_count,
min_score,
visible_bounds=visible_bounds,
)
payload = build_locator_payload(