diff --git a/data_acq_and_processing/processing/data_processor/include/processing_live_config.hpp b/data_acq_and_processing/processing/data_processor/include/processing_live_config.hpp index 4d2abbb..4f12a95 100644 --- a/data_acq_and_processing/processing/data_processor/include/processing_live_config.hpp +++ b/data_acq_and_processing/processing/data_processor/include/processing_live_config.hpp @@ -13,10 +13,9 @@ enum class HistoryCommand { ClearAll, }; -enum class GprAlgorithm { - Backprojection, - LegacyPoint, - LegacyExtended, +enum class LegacyGprMode { + Point, + Extended, }; struct ProcessingLiveConfig { @@ -32,7 +31,7 @@ struct ProcessingLiveConfig { float bscan_gain = 1.0F; float bscan_start_freq_mhz = 100.0F; float bscan_stop_freq_mhz = 8800.0F; - GprAlgorithm gpr_algorithm = GprAlgorithm::Backprojection; + LegacyGprMode legacy_gpr_mode = LegacyGprMode::Point; std::vector gpr_input_positions{}; std::vector gpr_output_positions{}; float gpr_min_depth_m = 2.0F; diff --git a/data_acq_and_processing/processing/data_processor/src/data_processor.cpp b/data_acq_and_processing/processing/data_processor/src/data_processor.cpp index 8d261fc..80f2277 100644 --- a/data_acq_and_processing/processing/data_processor/src/data_processor.cpp +++ b/data_acq_and_processing/processing/data_processor/src/data_processor.cpp @@ -162,6 +162,10 @@ auto create_default_processors() -> ProcessorRegistry { auto processor = std::make_unique(); processors.emplace(processor->name(), std::move(processor)); } + { + auto processor = std::make_unique(); + processors.emplace(processor->name(), std::move(processor)); + } return processors; } diff --git a/data_acq_and_processing/processing/data_processor/src/processing_live_config.cpp b/data_acq_and_processing/processing/data_processor/src/processing_live_config.cpp index 438524e..3d0aaf3 100644 --- a/data_acq_and_processing/processing/data_processor/src/processing_live_config.cpp +++ b/data_acq_and_processing/processing/data_processor/src/processing_live_config.cpp @@ -31,19 +31,32 @@ using Json = nlohmann::json; throw std::runtime_error("processing.history_command must be one of: none, remove_last, clear_all"); } -[[nodiscard]] auto parse_gpr_algorithm(const std::string& value) -> GprAlgorithm { +[[nodiscard]] auto parse_legacy_gpr_mode(const std::string& value, const std::string& field_name) -> LegacyGprMode { + if (value == "point") { + return LegacyGprMode::Point; + } + if (value == "extended") { + return LegacyGprMode::Extended; + } + throw std::runtime_error(field_name + " must be one of: point, extended"); +} + +void apply_legacy_gpr_algorithm_alias(ProcessingLiveConfig& config, const std::string& value) { if (value == "backprojection") { - return GprAlgorithm::Backprojection; + return; } if (value == "legacy_point") { - return GprAlgorithm::LegacyPoint; + config.legacy_gpr_mode = LegacyGprMode::Point; + } else if (value == "legacy_extended") { + config.legacy_gpr_mode = LegacyGprMode::Extended; + } else { + throw std::runtime_error( + "processing.gpr_algorithm must be one of: backprojection, legacy_point, legacy_extended" + ); } - if (value == "legacy_extended") { - return GprAlgorithm::LegacyExtended; + if (config.processor_mode.empty() || config.processor_mode == "gpr") { + config.processor_mode = "legacy_gpr"; } - throw std::runtime_error( - "processing.gpr_algorithm must be one of: backprojection, legacy_point, legacy_extended" - ); } [[nodiscard]] auto parse_s_parameter_channel(const std::string& value, const std::string& field_name) -> std::string { @@ -179,11 +192,18 @@ using Json = nlohmann::json; } config.bscan_stop_freq_mhz = static_cast(found->get()); } + if (const auto found = root.find("legacy_gpr_mode"); found != root.end()) { + if (!found->is_string()) { + throw std::runtime_error("processing.legacy_gpr_mode must be string"); + } + config.legacy_gpr_mode = + parse_legacy_gpr_mode(found->get(), "processing.legacy_gpr_mode"); + } if (const auto found = root.find("gpr_algorithm"); found != root.end()) { if (!found->is_string()) { throw std::runtime_error("processing.gpr_algorithm must be string"); } - config.gpr_algorithm = parse_gpr_algorithm(found->get()); + apply_legacy_gpr_algorithm_alias(config, found->get()); } if (const auto found = root.find("gpr_input_positions"); found != root.end()) { config.gpr_input_positions = parse_u32_array(*found, "processing.gpr_input_positions"); diff --git a/data_acq_and_processing/processing/processors/include/gpr_processor.hpp b/data_acq_and_processing/processing/processors/include/gpr_processor.hpp index bc06471..dc8a9ed 100644 --- a/data_acq_and_processing/processing/processors/include/gpr_processor.hpp +++ b/data_acq_and_processing/processing/processors/include/gpr_processor.hpp @@ -15,4 +15,15 @@ class GprProcessor final : public ProcessorInterface { ) -> ipc::ResultCollection override; }; +class LegacyGprProcessor final : public ProcessorInterface { + public: + [[nodiscard]] auto name() const -> std::string override; + [[nodiscard]] auto process_collection( + const config::RunConfig& run_config, + const ipc::PreprocessedCollection& collection, + std::span previous_collections, + const ProcessingLiveConfig& live_config + ) -> ipc::ResultCollection override; +}; + } // namespace radar::processing diff --git a/data_acq_and_processing/processing/processors/src/gpr_legacy_processor.ipp b/data_acq_and_processing/processing/processors/src/gpr_legacy_processor.ipp index 57833b0..4970af3 100644 --- a/data_acq_and_processing/processing/processors/src/gpr_legacy_processor.ipp +++ b/data_acq_and_processing/processing/processors/src/gpr_legacy_processor.ipp @@ -750,7 +750,7 @@ void apply_legacy_motion_correction( return results; } - if (live_config.gpr_algorithm == GprAlgorithm::LegacyExtended) { + if (live_config.legacy_gpr_mode == LegacyGprMode::Extended) { const auto [regions, smoothed_accumulator] = extended_legacy_find_regions( grid, peaks_by_pair, diff --git a/data_acq_and_processing/processing/processors/src/gpr_processor.cpp b/data_acq_and_processing/processing/processors/src/gpr_processor.cpp index c8a87cb..5c3ea80 100644 --- a/data_acq_and_processing/processing/processors/src/gpr_processor.cpp +++ b/data_acq_and_processing/processing/processors/src/gpr_processor.cpp @@ -35,10 +35,20 @@ auto GprProcessor::process_collection( std::span previous_collections, const ProcessingLiveConfig& live_config ) -> ipc::ResultCollection { - if (live_config.gpr_algorithm != GprAlgorithm::Backprojection) { - return process_legacy_gpr(run_config, collection, previous_collections, live_config); - } return process_backprojection_gpr(run_config, collection, previous_collections, live_config); } +auto LegacyGprProcessor::name() const -> std::string { + return "legacy_gpr"; +} + +auto LegacyGprProcessor::process_collection( + const config::RunConfig& run_config, + const ipc::PreprocessedCollection& collection, + std::span previous_collections, + const ProcessingLiveConfig& live_config +) -> ipc::ResultCollection { + return process_legacy_gpr(run_config, collection, previous_collections, live_config); +} + } // namespace radar::processing diff --git a/python_app/gui/controllers/app_window_config/live_processing_mixin.py b/python_app/gui/controllers/app_window_config/live_processing_mixin.py index 9788a1e..3ecd16c 100644 --- a/python_app/gui/controllers/app_window_config/live_processing_mixin.py +++ b/python_app/gui/controllers/app_window_config/live_processing_mixin.py @@ -11,6 +11,11 @@ from python_app.orchestration.live_processing_config import ProcessingLiveConfig class AppWindowLiveProcessingMixin: """Handle live processing updates, redraws, and locator republishing.""" + @staticmethod + def _is_gpr_processing_mode(mode: str) -> bool: + """Return whether a mode uses GPR result payloads and plot surface.""" + return mode in {"gpr", "legacy_gpr"} + def _validate_processing_mode_selection(self, mode: str) -> None: """Validate requested processing mode against current stable/live GUI state.""" validate_processing_mode_constraints( @@ -23,10 +28,30 @@ class AppWindowLiveProcessingMixin: """Build live processing config from current processing widgets.""" self._sync_bscan_frequency_limits_with_radar() self._sync_gpr_frequency_limits_with_radar() + mode = self._processing_mode.currentText() + if mode == "legacy_gpr": + gpr_input_positions_text = self._legacy_gpr_input_positions_input.text() + gpr_output_positions_text = self._legacy_gpr_output_positions_input.text() + gpr_min_depth_m = float(self._legacy_gpr_min_depth_m.value()) + gpr_max_depth_m = float(self._legacy_gpr_max_depth_m.value()) + gpr_start_freq_mhz = float(self._legacy_gpr_start_freq_mhz.value()) + gpr_stop_freq_mhz = float(self._legacy_gpr_stop_freq_mhz.value()) + gpr_background_enabled = bool(self._legacy_gpr_background_subtract_enabled.isChecked()) + gpr_background_mean_count = int(self._legacy_gpr_background_mean_count.value()) + else: + gpr_input_positions_text = self._gpr_input_positions_input.text() + gpr_output_positions_text = 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_start_freq_mhz = float(self._gpr_start_freq_mhz.value()) + gpr_stop_freq_mhz = float(self._gpr_stop_freq_mhz.value()) + gpr_background_enabled = bool(self._gpr_background_subtract_enabled.isChecked()) + gpr_background_mean_count = int(self._gpr_background_mean_count.value()) + y_min_db = float(self._pass_through_y_min_db.value()) y_max_db = float(self._pass_through_y_max_db.value()) return ProcessingLiveConfig( - processor_mode=self._processing_mode.currentText(), + processor_mode=mode, pass_through_channel="s21", pass_through_fixed_y_enabled=bool(self._pass_through_fixed_y_enabled.isChecked()), pass_through_y_min_db=min(y_min_db, y_max_db), @@ -38,22 +63,22 @@ class AppWindowLiveProcessingMixin: bscan_gain=float(self._bscan_gain.value()), bscan_start_freq_mhz=float(self._bscan_start_freq_mhz.value()), bscan_stop_freq_mhz=float(self._bscan_stop_freq_mhz.value()), - gpr_algorithm=self._gpr_algorithm.currentText(), - gpr_input_positions=self._parse_csv_int_list(self._gpr_input_positions_input.text()), - 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()), + legacy_gpr_mode=self._legacy_gpr_config_mode.currentText(), + gpr_input_positions=self._parse_csv_int_list(gpr_input_positions_text), + gpr_output_positions=self._parse_csv_int_list(gpr_output_positions_text), + gpr_min_depth_m=gpr_min_depth_m, + gpr_max_depth_m=gpr_max_depth_m, gpr_range_comp_power=float(self._gpr_range_comp_power.value()), gpr_angle_comp_power=float(self._gpr_angle_comp_power.value()), - gpr_comp_power=float(self._gpr_comp_power.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_start_freq_mhz=float(self._gpr_start_freq_mhz.value()), - gpr_stop_freq_mhz=float(self._gpr_stop_freq_mhz.value()), - gpr_background_subtract_enabled=bool(self._gpr_background_subtract_enabled.isChecked()), - gpr_background_mean_count=int(self._gpr_background_mean_count.value()), + gpr_comp_power=float(self._legacy_gpr_comp_power.value()), + gpr_speed_m_s=float(self._legacy_gpr_speed_m_s.value()), + gpr_look_angle_deg=float(self._legacy_gpr_look_angle_deg.value()), + gpr_snr_thresh=float(self._legacy_gpr_snr_thresh.value()), + gpr_snr_comp_max=float(self._legacy_gpr_snr_comp_max.value()), + gpr_start_freq_mhz=gpr_start_freq_mhz, + gpr_stop_freq_mhz=gpr_stop_freq_mhz, + gpr_background_subtract_enabled=gpr_background_enabled, + gpr_background_mean_count=gpr_background_mean_count, 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), @@ -69,7 +94,7 @@ class AppWindowLiveProcessingMixin: """Handle live-processing setting changes and trigger redraw when needed.""" try: current_mode = self._processing_mode.currentText() - if current_mode == "gpr": + if self._is_gpr_processing_mode(current_mode): self._drain_results_until_quiet(timeout_s=0.05, poll_s=0.005) self._write_live_processing_config() @@ -77,7 +102,7 @@ class AppWindowLiveProcessingMixin: 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": + elif self._is_gpr_processing_mode(current_mode): latest = self._drain_results_until_quiet(timeout_s=0.8, poll_s=0.02) collection = latest if collection is None and self._result_history: @@ -96,7 +121,7 @@ class AppWindowLiveProcessingMixin: def _on_gpr_visual_settings_changed(self, *_args) -> None: """Redraw current GPR result using updated GUI-only render settings.""" - if self._processing_mode.currentText() != "gpr": + if not self._is_gpr_processing_mode(self._processing_mode.currentText()): return try: if self._result_history and self._draw_results(self._result_history[-1]): @@ -108,7 +133,7 @@ class AppWindowLiveProcessingMixin: def _on_gpr_locator_threshold_changed(self, *_args) -> None: """Redraw GPR view and republish locator snapshot after threshold changes.""" self._on_gpr_visual_settings_changed() - if self._processing_mode.currentText() != "gpr": + if not self._is_gpr_processing_mode(self._processing_mode.currentText()): return try: self._publish_locator_snapshot_from_latest_result() @@ -118,7 +143,7 @@ class AppWindowLiveProcessingMixin: def _on_gpr_locator_window_changed(self, *_args) -> None: """Redraw GPR view and republish locator snapshot after visible X/Z changes.""" self._on_gpr_visual_settings_changed() - if self._processing_mode.currentText() != "gpr": + if not self._is_gpr_processing_mode(self._processing_mode.currentText()): return try: self._publish_locator_snapshot_from_latest_result() @@ -131,8 +156,10 @@ class AppWindowLiveProcessingMixin: "pass_through": 0, "bscan": 1, "gpr": 2, + "legacy_gpr": 3, } self._processing_mode_pages.setCurrentIndex(mode_to_page.get(mode, 0)) + self._gpr_common_page.setVisible(self._is_gpr_processing_mode(mode)) current_page = self._processing_mode_pages.currentWidget() if current_page is not None: self._processing_mode_pages.setFixedHeight(current_page.sizeHint().height()) @@ -157,9 +184,9 @@ class AppWindowLiveProcessingMixin: self._set_plot_mode(mode) self._set_processing_mode_page(mode) self._on_processing_live_settings_changed() - if mode == "gpr": + if self._is_gpr_processing_mode(mode): self._publish_locator_snapshot_from_latest_result() - elif previous_mode == "gpr" and self._locator_service is not None: + elif self._is_gpr_processing_mode(previous_mode) and self._locator_service is not None: self._locator_service.publish_empty() if mode == "pass_through": self._log( @@ -182,21 +209,36 @@ class AppWindowLiveProcessingMixin: elif mode == "gpr": self._log( "Processing mode selected: gpr " - f"(algorithm={self._gpr_algorithm.currentText()}, " - f"inputs={self._gpr_input_positions_input.text().strip() or ''}, " + f"(inputs={self._gpr_input_positions_input.text().strip() or ''}, " f"outputs={self._gpr_output_positions_input.text().strip() or ''}, " 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"range_comp={self._gpr_range_comp_power.value():g}, " f"angle_comp={self._gpr_angle_comp_power.value():g}, " - f"comp={self._gpr_comp_power.value():g}, " - f"snr={self._gpr_snr_thresh.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_score={self._gpr_min_visible_score.value():g})" ) + elif mode == "legacy_gpr": + self._log( + "Processing mode selected: legacy_gpr " + f"(mode={self._legacy_gpr_config_mode.currentText()}, " + f"inputs={self._legacy_gpr_input_positions_input.text().strip() or ''}, " + f"outputs={self._legacy_gpr_output_positions_input.text().strip() or ''}, " + f"depth={self._legacy_gpr_min_depth_m.value():g}..{self._legacy_gpr_max_depth_m.value():g} m, " + f"freq={self._legacy_gpr_start_freq_mhz.value():g}..{self._legacy_gpr_stop_freq_mhz.value():g} MHz, " + f"comp={self._legacy_gpr_comp_power.value():g}, " + f"snr={self._legacy_gpr_snr_thresh.value():g}, " + f"snr_comp_max={self._legacy_gpr_snr_comp_max.value():g}, " + f"speed={self._legacy_gpr_speed_m_s.value():g} m/s, " + f"look_angle={self._legacy_gpr_look_angle_deg.value():g} deg, " + f"background_subtract={self._legacy_gpr_background_subtract_enabled.isChecked()}, " + f"mean_count={self._legacy_gpr_background_mean_count.value()}, " + f"render_mode={self._legacy_gpr_render_mode.currentText()}, " + f"min_pairs={self._legacy_gpr_min_visible_pair_count.value()})" + ) def _clear_history_mode_caches(self) -> None: """Drop cached render state for pass-through, B-scan, and GPR views.""" @@ -218,7 +260,7 @@ class AppWindowLiveProcessingMixin: self._bscan_plot.clear() self._configure_bscan_plot_axes() return - if self._processing_mode.currentText() == "gpr": + if self._is_gpr_processing_mode(self._processing_mode.currentText()): if self._result_history and self._draw_results(self._result_history[-1]): return self._clear_gpr_plot() diff --git a/python_app/gui/controllers/app_window_config/profile_io_mixin.py b/python_app/gui/controllers/app_window_config/profile_io_mixin.py index 3964101..f429285 100644 --- a/python_app/gui/controllers/app_window_config/profile_io_mixin.py +++ b/python_app/gui/controllers/app_window_config/profile_io_mixin.py @@ -70,25 +70,6 @@ class AppWindowConfigProfileIOMixin: self._pass_through_y_min_db.setEnabled(enabled) self._pass_through_y_max_db.setEnabled(enabled) - def _sync_gpr_algorithm_controls(self) -> None: - """Enable only controls that affect the selected GPR algorithm.""" - backprojection_enabled = self._gpr_algorithm.currentText() == "backprojection" - for widget in ( - self._gpr_range_comp_power, - self._gpr_angle_comp_power, - self._gpr_remove_sidelobe_objects_enabled, - ): - widget.setEnabled(backprojection_enabled) - - for widget in ( - self._gpr_comp_power, - self._gpr_speed_m_s, - self._gpr_look_angle_deg, - self._gpr_snr_thresh, - self._gpr_snr_comp_max, - ): - widget.setEnabled(not backprojection_enabled) - def _apply_history_limit_from_config(self, config) -> None: """Resize in-memory history buffers to match the loaded config.""" history_limit = self._history_limit_for_config(config) @@ -213,7 +194,6 @@ class AppWindowConfigProfileIOMixin: self._bscan_start_freq_mhz, self._bscan_stop_freq_mhz, self._bscan_subtract_mean_ascan, - self._gpr_algorithm, self._gpr_relative_permittivity, self._gpr_tx_geometry_input, self._gpr_rx_geometry_input, @@ -223,11 +203,6 @@ class AppWindowConfigProfileIOMixin: self._gpr_max_depth_m, self._gpr_range_comp_power, self._gpr_angle_comp_power, - self._gpr_comp_power, - self._gpr_speed_m_s, - self._gpr_look_angle_deg, - self._gpr_snr_thresh, - self._gpr_snr_comp_max, self._gpr_start_freq_mhz, self._gpr_stop_freq_mhz, self._gpr_background_subtract_enabled, @@ -239,6 +214,26 @@ class AppWindowConfigProfileIOMixin: self._gpr_visible_x_max_m, self._gpr_visible_z_min_m, self._gpr_visible_z_max_m, + self._legacy_gpr_config_mode, + self._legacy_gpr_input_positions_input, + self._legacy_gpr_output_positions_input, + self._legacy_gpr_min_depth_m, + self._legacy_gpr_max_depth_m, + self._legacy_gpr_comp_power, + self._legacy_gpr_snr_thresh, + self._legacy_gpr_snr_comp_max, + self._legacy_gpr_start_freq_mhz, + self._legacy_gpr_stop_freq_mhz, + self._legacy_gpr_speed_m_s, + self._legacy_gpr_look_angle_deg, + self._legacy_gpr_background_subtract_enabled, + self._legacy_gpr_background_mean_count, + self._legacy_gpr_render_mode, + self._legacy_gpr_min_visible_pair_count, + self._legacy_gpr_visible_x_min_m, + self._legacy_gpr_visible_x_max_m, + self._legacy_gpr_visible_z_min_m, + self._legacy_gpr_visible_z_max_m, self._save_count, self._save_path_input, self._save_name_input, @@ -290,16 +285,10 @@ class AppWindowConfigProfileIOMixin: ) self._gpr_input_positions_input.setText(str(gui_state.processing.gpr.input_positions)) self._gpr_output_positions_input.setText(str(gui_state.processing.gpr.output_positions)) - self._set_combo_current_text(self._gpr_algorithm, gui_state.processing.gpr.algorithm) 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_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_comp_power.setValue(float(gui_state.processing.gpr.comp_power)) - 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_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_background_subtract_enabled.setChecked( @@ -316,6 +305,29 @@ class AppWindowConfigProfileIOMixin: self._gpr_visible_z_min_m.setValue(float(gui_state.processing.gpr.visible_z_min_m)) self._gpr_visible_z_max_m.setValue(float(gui_state.processing.gpr.visible_z_max_m)) + self._set_combo_current_text(self._legacy_gpr_config_mode, gui_state.processing.legacy_gpr.mode) + self._legacy_gpr_input_positions_input.setText(str(gui_state.processing.legacy_gpr.input_positions)) + self._legacy_gpr_output_positions_input.setText(str(gui_state.processing.legacy_gpr.output_positions)) + self._legacy_gpr_min_depth_m.setValue(float(gui_state.processing.legacy_gpr.min_depth_m)) + self._legacy_gpr_max_depth_m.setValue(float(gui_state.processing.legacy_gpr.max_depth_m)) + self._legacy_gpr_comp_power.setValue(float(gui_state.processing.legacy_gpr.comp_power)) + self._legacy_gpr_snr_thresh.setValue(float(gui_state.processing.legacy_gpr.snr_thresh)) + self._legacy_gpr_snr_comp_max.setValue(float(gui_state.processing.legacy_gpr.snr_comp_max)) + self._legacy_gpr_start_freq_mhz.setValue(float(gui_state.processing.legacy_gpr.start_freq_mhz)) + self._legacy_gpr_stop_freq_mhz.setValue(float(gui_state.processing.legacy_gpr.stop_freq_mhz)) + self._legacy_gpr_speed_m_s.setValue(float(gui_state.processing.legacy_gpr.speed_m_s)) + self._legacy_gpr_look_angle_deg.setValue(float(gui_state.processing.legacy_gpr.look_angle_deg)) + self._legacy_gpr_background_subtract_enabled.setChecked( + bool(gui_state.processing.legacy_gpr.background_subtract_enabled) + ) + self._legacy_gpr_background_mean_count.setValue(int(gui_state.processing.legacy_gpr.background_mean_count)) + self._set_combo_current_text(self._legacy_gpr_render_mode, gui_state.processing.legacy_gpr.render_mode) + self._legacy_gpr_min_visible_pair_count.setValue(int(gui_state.processing.legacy_gpr.min_visible_pair_count)) + self._legacy_gpr_visible_x_min_m.setValue(float(gui_state.processing.legacy_gpr.visible_x_min_m)) + self._legacy_gpr_visible_x_max_m.setValue(float(gui_state.processing.legacy_gpr.visible_x_max_m)) + self._legacy_gpr_visible_z_min_m.setValue(float(gui_state.processing.legacy_gpr.visible_z_min_m)) + self._legacy_gpr_visible_z_max_m.setValue(float(gui_state.processing.legacy_gpr.visible_z_max_m)) + self._save_count.setValue(int(gui_state.data_actions.save_count)) self._save_path_input.setText(str(gui_state.data_actions.save_path)) self._save_name_input.setText(str(gui_state.data_actions.save_name)) @@ -330,7 +342,7 @@ class AppWindowConfigProfileIOMixin: self._gpr_geometry_signature = None self._gpr_selected_geometry = None self._sync_pass_through_y_controls() - self._sync_gpr_algorithm_controls() + self._set_processing_mode_page(gui_state.processing.selected_mode) self._refresh_preprocess_summary_labels() if self._preprocess_dialog is not None: diff --git a/python_app/gui/controllers/app_window_config/radar_limits_mixin.py b/python_app/gui/controllers/app_window_config/radar_limits_mixin.py index 7cb61b0..ea5076c 100644 --- a/python_app/gui/controllers/app_window_config/radar_limits_mixin.py +++ b/python_app/gui/controllers/app_window_config/radar_limits_mixin.py @@ -175,6 +175,8 @@ class AppWindowRadarLimitsMixin: "_bscan_stop_freq_mhz": "B-scan Stop MHz", "_gpr_start_freq_mhz": "GPR Start MHz", "_gpr_stop_freq_mhz": "GPR Stop MHz", + "_legacy_gpr_start_freq_mhz": "Legacy GPR Start MHz", + "_legacy_gpr_stop_freq_mhz": "Legacy GPR Stop MHz", } widgets = [getattr(self, widget_name) for widget_name in widget_names] previous_values = {widget_name: getattr(self, widget_name).value() for widget_name in widget_names} @@ -223,5 +225,7 @@ class AppWindowRadarLimitsMixin: ( "_gpr_start_freq_mhz", "_gpr_stop_freq_mhz", + "_legacy_gpr_start_freq_mhz", + "_legacy_gpr_stop_freq_mhz", ) ) diff --git a/python_app/gui/controllers/app_window_config/state_builders.py b/python_app/gui/controllers/app_window_config/state_builders.py index aaf49c8..521749c 100644 --- a/python_app/gui/controllers/app_window_config/state_builders.py +++ b/python_app/gui/controllers/app_window_config/state_builders.py @@ -6,6 +6,7 @@ from python_app.models.gui_profile_model import ( GuiBscanStateModel, GuiDataActionsStateModel, GuiGprStateModel, + GuiLegacyGprStateModel, GuiPassThroughStateModel, GuiPreprocessDialogStateModel, GuiProcessingStateModel, @@ -183,6 +184,27 @@ class AppWindowConfigStateBuildersMixin: visible_z_min_m=0.0, visible_z_max_m=14.0, ), + legacy_gpr=GuiLegacyGprStateModel( + input_positions=self._default_gpr_input_positions_from_config(config), + output_positions=self._default_gpr_output_positions_from_config(config), + min_depth_m=2.0, + max_depth_m=14.0, + comp_power=0.2, + 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, + render_mode="heatmap", + min_visible_pair_count=1, + visible_x_min_m=default_gpr_x_min_m, + visible_x_max_m=default_gpr_x_max_m, + visible_z_min_m=0.0, + visible_z_max_m=14.0, + ), ), data_actions=GuiDataActionsStateModel( save_count=10, @@ -252,18 +274,12 @@ class AppWindowConfigStateBuildersMixin: subtract_mean_ascan=bool(self._bscan_subtract_mean_ascan.isChecked()), ), gpr=GuiGprStateModel( - algorithm=self._gpr_algorithm.currentText(), input_positions=self._gpr_input_positions_input.text().strip(), 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()), range_comp_power=float(self._gpr_range_comp_power.value()), angle_comp_power=float(self._gpr_angle_comp_power.value()), - comp_power=float(self._gpr_comp_power.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()), start_freq_mhz=float(self._gpr_start_freq_mhz.value()), stop_freq_mhz=float(self._gpr_stop_freq_mhz.value()), background_subtract_enabled=bool(self._gpr_background_subtract_enabled.isChecked()), @@ -276,6 +292,28 @@ class AppWindowConfigStateBuildersMixin: visible_z_min_m=float(self._gpr_visible_z_min_m.value()), visible_z_max_m=float(self._gpr_visible_z_max_m.value()), ), + legacy_gpr=GuiLegacyGprStateModel( + mode=self._legacy_gpr_config_mode.currentText(), + input_positions=self._legacy_gpr_input_positions_input.text().strip(), + output_positions=self._legacy_gpr_output_positions_input.text().strip(), + min_depth_m=float(self._legacy_gpr_min_depth_m.value()), + max_depth_m=float(self._legacy_gpr_max_depth_m.value()), + comp_power=float(self._legacy_gpr_comp_power.value()), + start_freq_mhz=float(self._legacy_gpr_start_freq_mhz.value()), + stop_freq_mhz=float(self._legacy_gpr_stop_freq_mhz.value()), + speed_m_s=float(self._legacy_gpr_speed_m_s.value()), + look_angle_deg=float(self._legacy_gpr_look_angle_deg.value()), + snr_thresh=float(self._legacy_gpr_snr_thresh.value()), + snr_comp_max=float(self._legacy_gpr_snr_comp_max.value()), + background_subtract_enabled=bool(self._legacy_gpr_background_subtract_enabled.isChecked()), + background_mean_count=int(self._legacy_gpr_background_mean_count.value()), + render_mode=self._legacy_gpr_render_mode.currentText(), + min_visible_pair_count=int(self._legacy_gpr_min_visible_pair_count.value()), + visible_x_min_m=float(self._legacy_gpr_visible_x_min_m.value()), + visible_x_max_m=float(self._legacy_gpr_visible_x_max_m.value()), + visible_z_min_m=float(self._legacy_gpr_visible_z_min_m.value()), + visible_z_max_m=float(self._legacy_gpr_visible_z_max_m.value()), + ), ), data_actions=GuiDataActionsStateModel( save_count=int(self._save_count.value()), @@ -325,7 +363,7 @@ class AppWindowConfigStateBuildersMixin: combo_text = self._combos_text.text() config.combos = parse_combos_from_text(combo_text) config.ensure_combos() - if self._processing_mode.currentText() != "gpr" and self._switches_are_effectively_static(config): + if self._processing_mode.currentText() not in {"gpr", "legacy_gpr"} and self._switches_are_effectively_static(config): config.combos = [ComboModel(input=0, output=0)] for key in PREPROCESS_ASSET_KEYS: diff --git a/python_app/gui/controllers/app_window_pipeline_mixin.py b/python_app/gui/controllers/app_window_pipeline_mixin.py index f094fc4..a8c11cd 100644 --- a/python_app/gui/controllers/app_window_pipeline_mixin.py +++ b/python_app/gui/controllers/app_window_pipeline_mixin.py @@ -363,7 +363,7 @@ class AppWindowPipelineMixin: if record_result_history(self._result_history, collection): latest = collection if ( - self._processing_mode.currentText() == "gpr" + self._is_gpr_processing_mode(self._processing_mode.currentText()) and collection_has_gpr_payloads(collection) ): self._publish_locator_snapshot_from_collection(collection) @@ -478,11 +478,13 @@ class AppWindowPipelineMixin: speed_m_s = self._locator_service.drain_speed_updates() if speed_m_s is None: return + if self._processing_mode.currentText() != "legacy_gpr": + return - previous_speed_m_s = float(self._gpr_speed_m_s.value()) - with QSignalBlocker(self._gpr_speed_m_s): - self._gpr_speed_m_s.setValue(float(speed_m_s)) - current_speed_m_s = float(self._gpr_speed_m_s.value()) + previous_speed_m_s = float(self._legacy_gpr_speed_m_s.value()) + with QSignalBlocker(self._legacy_gpr_speed_m_s): + self._legacy_gpr_speed_m_s.setValue(float(speed_m_s)) + current_speed_m_s = float(self._legacy_gpr_speed_m_s.value()) if current_speed_m_s == previous_speed_m_s: return @@ -494,7 +496,7 @@ class AppWindowPipelineMixin: return self._locator_service.publish_collection( collection, - float(self._gpr_min_visible_score.value()), + self._gpr_locator_threshold(), visible_bounds=self._gpr_visible_object_bounds(), ) @@ -502,7 +504,7 @@ class AppWindowPipelineMixin: """Publish current locator-visible snapshot from latest cached GPR result.""" if self._locator_service is None: return - if self._processing_mode.currentText() != "gpr": + if not self._is_gpr_processing_mode(self._processing_mode.currentText()): self._locator_service.publish_empty() return diff --git a/python_app/gui/controllers/app_window_plot/gpr_plot_mixin.py b/python_app/gui/controllers/app_window_plot/gpr_plot_mixin.py index 198d151..75e1d81 100644 --- a/python_app/gui/controllers/app_window_plot/gpr_plot_mixin.py +++ b/python_app/gui/controllers/app_window_plot/gpr_plot_mixin.py @@ -17,6 +17,14 @@ from python_app.orchestration.gpr_locator import ( class AppWindowGprPlotMixin: """Renders GPR accumulator heatmaps and detected object overlays.""" + def _gpr_plot_title(self, *, objects_only: bool = False) -> str: + """Return title for the active GPR-like processing mode.""" + if self._processing_mode.currentText() == "legacy_gpr": + title = f"Legacy GPR {self._legacy_gpr_config_mode.currentText()}" + else: + title = "GPR coherent BP" + return f"{title} Objects Only" if objects_only else title + def _clear_gpr_plot(self) -> None: """Clear latest GPR plot surface.""" if not hasattr(self, "_gpr_plot"): @@ -39,7 +47,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("GPR coherent BP") + self._gpr_plot.setTitle(self._gpr_plot_title()) def _configure_gpr_plot_axes(self) -> None: """Apply persistent GPR plot axis labels and base view settings.""" @@ -162,8 +170,14 @@ class AppWindowGprPlotMixin: def _selected_gpr_geometry(self) -> tuple[np.ndarray, np.ndarray]: """Resolve selected Tx/Rx geometry arrays for current GPR selection.""" - requested_inputs = tuple(self._parse_csv_int_list(self._gpr_input_positions_input.text())) - requested_outputs = tuple(self._parse_csv_int_list(self._gpr_output_positions_input.text())) + if self._processing_mode.currentText() == "legacy_gpr": + input_positions_text = self._legacy_gpr_input_positions_input.text() + output_positions_text = self._legacy_gpr_output_positions_input.text() + else: + input_positions_text = self._gpr_input_positions_input.text() + output_positions_text = self._gpr_output_positions_input.text() + requested_inputs = tuple(self._parse_csv_int_list(input_positions_text)) + requested_outputs = tuple(self._parse_csv_int_list(output_positions_text)) signature = ( self._gpr_tx_geometry_input.toPlainText(), self._gpr_rx_geometry_input.toPlainText(), @@ -193,7 +207,7 @@ class AppWindowGprPlotMixin: def _draw_gpr_map(self, collection: ResultCollection) -> bool: """Draw latest collection-level GPR plot according to current render mode.""" - if self._gpr_render_mode.currentText() == "objects_only": + if self._gpr_render_mode_text() == "objects_only": return self._draw_gpr_objects_only(collection) return self._draw_gpr_heatmap(collection) @@ -251,7 +265,8 @@ class AppWindowGprPlotMixin: ) self._gpr_points_item.show() for x_value, y_value, score in points: - label = pg.TextItem(text=f"{float(score):.2f}", color="#ffffff", anchor=(0.0, 1.0)) + label_text = f"{float(score):.0f}" if self._processing_mode.currentText() == "legacy_gpr" else f"{float(score):.2f}" + label = pg.TextItem(text=label_text, color="#ffffff", anchor=(0.0, 1.0)) label.setZValue(40) label.setPos(float(x_value), float(y_value)) plot.addItem(label) @@ -297,7 +312,7 @@ class AppWindowGprPlotMixin: self._gpr_region_mask_items.append(mask_image) self._gpr_region_contours.append(contour) - plot.setTitle("GPR coherent BP") + plot.setTitle(self._gpr_plot_title()) finally: plot.setUpdatesEnabled(True) return True @@ -315,14 +330,24 @@ class AppWindowGprPlotMixin: def _gpr_visible_bounds(self) -> tuple[float, float, float, float]: """Return normalized GPR visible X/Z bounds from GUI controls.""" + if self._processing_mode.currentText() == "legacy_gpr": + x_min_widget = self._legacy_gpr_visible_x_min_m + x_max_widget = self._legacy_gpr_visible_x_max_m + z_min_widget = self._legacy_gpr_visible_z_min_m + z_max_widget = self._legacy_gpr_visible_z_max_m + else: + x_min_widget = self._gpr_visible_x_min_m + x_max_widget = self._gpr_visible_x_max_m + z_min_widget = self._gpr_visible_z_min_m + z_max_widget = self._gpr_visible_z_max_m x_min, x_max = self._normalized_display_range( - float(self._gpr_visible_x_min_m.value()), - float(self._gpr_visible_x_max_m.value()), + float(x_min_widget.value()), + float(x_max_widget.value()), minimum_span=0.1, ) z_min, z_max = self._normalized_display_range( - float(self._gpr_visible_z_min_m.value()), - float(self._gpr_visible_z_max_m.value()), + float(z_min_widget.value()), + float(z_max_widget.value()), minimum_span=0.1, ) return x_min, x_max, z_min, z_max @@ -331,6 +356,18 @@ class AppWindowGprPlotMixin: """Return normalized object/locator visible X/Z bounds from GUI controls.""" return self._gpr_visible_bounds() + def _gpr_render_mode_text(self) -> str: + """Return render mode for the active GPR-like processing mode.""" + if self._processing_mode.currentText() == "legacy_gpr": + return self._legacy_gpr_render_mode.currentText() + return self._gpr_render_mode.currentText() + + def _gpr_locator_threshold(self) -> float: + """Return object threshold using the active GPR mode's score semantics.""" + if self._processing_mode.currentText() == "legacy_gpr": + return float(self._legacy_gpr_min_visible_pair_count.value()) + return float(self._gpr_min_visible_score.value()) + @staticmethod def _gpr_display_y_min(z_min: float, z_max: float) -> float: """Return lower display bound, preserving surface markers only when surface is visible.""" @@ -372,9 +409,10 @@ class AppWindowGprPlotMixin: self._gpr_rx_item.setData(x=[], y=[]) self._gpr_rx_item.hide() - @staticmethod - def _format_gpr_object_label(x_m: float, z_m: float, score: float) -> str: + def _format_gpr_object_label(self, x_m: float, z_m: float, score: float) -> str: """Format object-only annotation text with normalized BP score and coordinates.""" + if self._processing_mode.currentText() == "legacy_gpr": + return f"{int(round(score))} | x={x_m:.1f} | z={z_m:.1f}" return f"{score:.2f} | x={x_m:.1f} | z={z_m:.1f}" @staticmethod @@ -451,7 +489,7 @@ class AppWindowGprPlotMixin: return rows x_min, x_max, z_min, z_max = self._gpr_visible_object_bounds() - min_score = float(self._gpr_min_visible_score.value()) + min_score = self._gpr_locator_threshold() finite_mask = np.all(np.isfinite(rows[:, :3]), axis=1) visible_mask = ( finite_mask @@ -527,7 +565,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("GPR coherent BP Objects Only") + plot.setTitle(self._gpr_plot_title(objects_only=True)) finally: plot.setUpdatesEnabled(True) return True diff --git a/python_app/gui/controllers/app_window_plot/trace_plot_mixin.py b/python_app/gui/controllers/app_window_plot/trace_plot_mixin.py index e359fde..80b1dd2 100644 --- a/python_app/gui/controllers/app_window_plot/trace_plot_mixin.py +++ b/python_app/gui/controllers/app_window_plot/trace_plot_mixin.py @@ -37,7 +37,7 @@ class AppWindowTracePlotMixin: def _on_trace_visibility_changed(self, *_args) -> None: """Redraw pass-through traces when magnitude/phase toggles changed.""" - if self._processing_mode.currentText() in {"bscan", "gpr"}: + if self._processing_mode.currentText() in {"bscan", "gpr", "legacy_gpr"}: return if self._result_history: self._draw_results(self._result_history[-1]) diff --git a/python_app/gui/controllers/app_window_plot_mixin.py b/python_app/gui/controllers/app_window_plot_mixin.py index 1f23ec1..5d89196 100644 --- a/python_app/gui/controllers/app_window_plot_mixin.py +++ b/python_app/gui/controllers/app_window_plot_mixin.py @@ -31,7 +31,7 @@ class AppWindowPlotMixin( """Draw collection based on currently selected processing mode.""" if self._processing_mode.currentText() == "bscan": return self._draw_bscan_heatmap(collection) - if self._processing_mode.currentText() == "gpr": + if self._processing_mode.currentText() in {"gpr", "legacy_gpr"}: return self._draw_gpr_map(collection) return self._draw_trace_lines(collection) diff --git a/python_app/gui/controllers/app_window_ui_mixin.py b/python_app/gui/controllers/app_window_ui_mixin.py index 80d0fa8..c5d81bd 100644 --- a/python_app/gui/controllers/app_window_ui_mixin.py +++ b/python_app/gui/controllers/app_window_ui_mixin.py @@ -265,13 +265,13 @@ class AppWindowUiMixin: """Switch visible plot page according to processing mode. `bscan` -> show `self._bscan_plot` - `gpr` -> show `self._gpr_plot` + `gpr` and `legacy_gpr` -> show `self._gpr_plot` otherwise -> show `self._trace_plots_container` """ if mode == "bscan": self._plot_stack.setCurrentWidget(self._bscan_plot) return - if mode == "gpr": + if mode in {"gpr", "legacy_gpr"}: self._plot_stack.setCurrentWidget(self._gpr_plot) return self._plot_stack.setCurrentWidget(self._trace_plots_container) diff --git a/python_app/gui/controllers/sections/processing_section.py b/python_app/gui/controllers/sections/processing_section.py index 86f41d9..7d44ad7 100644 --- a/python_app/gui/controllers/sections/processing_section.py +++ b/python_app/gui/controllers/sections/processing_section.py @@ -56,9 +56,10 @@ def build_processing_group(owner) -> QGroupBox: pass_defaults = processing_defaults.pass_through bscan_defaults = processing_defaults.bscan gpr_live_defaults = processing_defaults.gpr + legacy_gpr_defaults = processing_defaults.legacy_gpr owner._processing_mode = QComboBox() - owner._processing_mode.addItems(["pass_through", "bscan", "gpr"]) + owner._processing_mode.addItems(["pass_through", "bscan", "gpr", "legacy_gpr"]) owner._set_combo_current_text(owner._processing_mode, processing_defaults.selected_mode) owner._processing_mode_pages = QStackedWidget(group) @@ -154,10 +155,6 @@ def build_processing_group(owner) -> QGroupBox: gpr_defaults = owner._defaults_config.gpr - owner._gpr_algorithm = QComboBox() - owner._gpr_algorithm.addItems(["backprojection", "legacy_point", "legacy_extended"]) - owner._set_combo_current_text(owner._gpr_algorithm, gpr_live_defaults.algorithm) - owner._gpr_relative_permittivity = QDoubleSpinBox() owner._gpr_relative_permittivity.setDecimals(4) owner._gpr_relative_permittivity.setRange(0.0001, 1000.0) @@ -172,6 +169,16 @@ def build_processing_group(owner) -> QGroupBox: owner._gpr_rx_geometry_input.setPlaceholderText("input_pos x_m") owner._gpr_rx_geometry_input.setFixedHeight(78) + owner._gpr_common_page = _build_processing_mode_page( + group, + [ + ("Relative permittivity", owner._gpr_relative_permittivity), + ("Tx geometry", owner._gpr_tx_geometry_input), + ("Rx geometry", owner._gpr_rx_geometry_input), + ], + split_index=1, + ) + owner._gpr_input_positions_input = QLineEdit(str(gpr_live_defaults.input_positions)) owner._gpr_input_positions_input.setPlaceholderText("0,1,2") @@ -202,36 +209,6 @@ def build_processing_group(owner) -> QGroupBox: owner._gpr_angle_comp_power.setSingleStep(0.01) owner._gpr_angle_comp_power.setValue(float(gpr_live_defaults.angle_comp_power)) - 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_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_start_freq_mhz = QDoubleSpinBox() owner._gpr_start_freq_mhz.setDecimals(1) owner._gpr_start_freq_mhz.setRange(100.0, 8800.0) @@ -254,8 +231,6 @@ def build_processing_group(owner) -> QGroupBox: 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._sync_gpr_algorithm_controls() - 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) @@ -293,25 +268,16 @@ def build_processing_group(owner) -> QGroupBox: gpr_page = _build_processing_mode_page( owner._processing_mode_pages, [ - ("Algorithm", owner._gpr_algorithm), - ("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), ("Range comp power", owner._gpr_range_comp_power), ("Angle comp power", owner._gpr_angle_comp_power), - ("Comp power", owner._gpr_comp_power), - ("SNR thresh", owner._gpr_snr_thresh), - ("SNR comp max", owner._gpr_snr_comp_max), ("Render mode", owner._gpr_render_mode), ("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), - ("Speed m/s", owner._gpr_speed_m_s), - ("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), @@ -320,10 +286,141 @@ def build_processing_group(owner) -> QGroupBox: ("Mean count", owner._gpr_background_mean_count), owner._gpr_remove_sidelobe_objects_enabled, ], - split_index=12, + split_index=8, ) owner._processing_mode_pages.addWidget(gpr_page) + owner._legacy_gpr_config_mode = QComboBox() + owner._legacy_gpr_config_mode.addItems(["point", "extended"]) + owner._set_combo_current_text(owner._legacy_gpr_config_mode, legacy_gpr_defaults.mode) + + owner._legacy_gpr_input_positions_input = QLineEdit(str(legacy_gpr_defaults.input_positions)) + owner._legacy_gpr_input_positions_input.setPlaceholderText("0,1,2") + + owner._legacy_gpr_output_positions_input = QLineEdit(str(legacy_gpr_defaults.output_positions)) + owner._legacy_gpr_output_positions_input.setPlaceholderText("0,1") + + owner._legacy_gpr_min_depth_m = QDoubleSpinBox() + owner._legacy_gpr_min_depth_m.setDecimals(2) + owner._legacy_gpr_min_depth_m.setRange(0.0, 50.0) + owner._legacy_gpr_min_depth_m.setSingleStep(0.1) + owner._legacy_gpr_min_depth_m.setValue(float(legacy_gpr_defaults.min_depth_m)) + + owner._legacy_gpr_max_depth_m = QDoubleSpinBox() + owner._legacy_gpr_max_depth_m.setDecimals(2) + owner._legacy_gpr_max_depth_m.setRange(0.1, 50.0) + owner._legacy_gpr_max_depth_m.setSingleStep(0.1) + owner._legacy_gpr_max_depth_m.setValue(float(legacy_gpr_defaults.max_depth_m)) + + owner._legacy_gpr_comp_power = QDoubleSpinBox() + owner._legacy_gpr_comp_power.setDecimals(3) + owner._legacy_gpr_comp_power.setRange(0.0, 5.0) + owner._legacy_gpr_comp_power.setSingleStep(0.05) + owner._legacy_gpr_comp_power.setValue(float(legacy_gpr_defaults.comp_power)) + + owner._legacy_gpr_snr_thresh = QDoubleSpinBox() + owner._legacy_gpr_snr_thresh.setDecimals(2) + owner._legacy_gpr_snr_thresh.setRange(0.0, 1_000.0) + owner._legacy_gpr_snr_thresh.setSingleStep(0.1) + owner._legacy_gpr_snr_thresh.setValue(float(legacy_gpr_defaults.snr_thresh)) + + owner._legacy_gpr_snr_comp_max = QDoubleSpinBox() + owner._legacy_gpr_snr_comp_max.setDecimals(2) + owner._legacy_gpr_snr_comp_max.setRange(0.0, 1_000.0) + owner._legacy_gpr_snr_comp_max.setSingleStep(0.5) + owner._legacy_gpr_snr_comp_max.setValue(float(legacy_gpr_defaults.snr_comp_max)) + + owner._legacy_gpr_start_freq_mhz = QDoubleSpinBox() + owner._legacy_gpr_start_freq_mhz.setDecimals(1) + owner._legacy_gpr_start_freq_mhz.setRange(100.0, 8800.0) + owner._legacy_gpr_start_freq_mhz.setSingleStep(10.0) + owner._legacy_gpr_start_freq_mhz.setValue(float(legacy_gpr_defaults.start_freq_mhz)) + + owner._legacy_gpr_stop_freq_mhz = QDoubleSpinBox() + owner._legacy_gpr_stop_freq_mhz.setDecimals(1) + owner._legacy_gpr_stop_freq_mhz.setRange(100.0, 8800.0) + owner._legacy_gpr_stop_freq_mhz.setSingleStep(10.0) + owner._legacy_gpr_stop_freq_mhz.setValue(float(legacy_gpr_defaults.stop_freq_mhz)) + + owner._legacy_gpr_speed_m_s = QDoubleSpinBox() + owner._legacy_gpr_speed_m_s.setDecimals(3) + owner._legacy_gpr_speed_m_s.setRange(-100.0, 100.0) + owner._legacy_gpr_speed_m_s.setSingleStep(0.01) + owner._legacy_gpr_speed_m_s.setValue(float(legacy_gpr_defaults.speed_m_s)) + + owner._legacy_gpr_look_angle_deg = QDoubleSpinBox() + owner._legacy_gpr_look_angle_deg.setDecimals(2) + owner._legacy_gpr_look_angle_deg.setRange(-90.0, 90.0) + owner._legacy_gpr_look_angle_deg.setSingleStep(0.1) + owner._legacy_gpr_look_angle_deg.setValue(float(legacy_gpr_defaults.look_angle_deg)) + + owner._legacy_gpr_background_subtract_enabled = QCheckBox("Subtract mean of previous collections") + owner._legacy_gpr_background_subtract_enabled.setChecked(bool(legacy_gpr_defaults.background_subtract_enabled)) + + owner._legacy_gpr_background_mean_count = QSpinBox() + owner._legacy_gpr_background_mean_count.setRange(0, 10_000) + owner._legacy_gpr_background_mean_count.setValue(int(legacy_gpr_defaults.background_mean_count)) + + owner._legacy_gpr_render_mode = QComboBox() + owner._legacy_gpr_render_mode.addItems(["heatmap", "objects_only"]) + owner._set_combo_current_text(owner._legacy_gpr_render_mode, legacy_gpr_defaults.render_mode) + + owner._legacy_gpr_min_visible_pair_count = QSpinBox() + owner._legacy_gpr_min_visible_pair_count.setRange(1, 10_000) + owner._legacy_gpr_min_visible_pair_count.setValue(int(legacy_gpr_defaults.min_visible_pair_count)) + + owner._legacy_gpr_visible_x_min_m = QDoubleSpinBox() + owner._legacy_gpr_visible_x_min_m.setDecimals(2) + owner._legacy_gpr_visible_x_min_m.setRange(-100.0, 100.0) + owner._legacy_gpr_visible_x_min_m.setSingleStep(0.1) + owner._legacy_gpr_visible_x_min_m.setValue(float(legacy_gpr_defaults.visible_x_min_m)) + + owner._legacy_gpr_visible_x_max_m = QDoubleSpinBox() + owner._legacy_gpr_visible_x_max_m.setDecimals(2) + owner._legacy_gpr_visible_x_max_m.setRange(-100.0, 100.0) + owner._legacy_gpr_visible_x_max_m.setSingleStep(0.1) + owner._legacy_gpr_visible_x_max_m.setValue(float(legacy_gpr_defaults.visible_x_max_m)) + + owner._legacy_gpr_visible_z_min_m = QDoubleSpinBox() + owner._legacy_gpr_visible_z_min_m.setDecimals(2) + owner._legacy_gpr_visible_z_min_m.setRange(0.0, 100.0) + owner._legacy_gpr_visible_z_min_m.setSingleStep(0.1) + owner._legacy_gpr_visible_z_min_m.setValue(float(legacy_gpr_defaults.visible_z_min_m)) + + owner._legacy_gpr_visible_z_max_m = QDoubleSpinBox() + owner._legacy_gpr_visible_z_max_m.setDecimals(2) + owner._legacy_gpr_visible_z_max_m.setRange(0.0, 100.0) + owner._legacy_gpr_visible_z_max_m.setSingleStep(0.1) + owner._legacy_gpr_visible_z_max_m.setValue(float(legacy_gpr_defaults.visible_z_max_m)) + + legacy_gpr_page = _build_processing_mode_page( + owner._processing_mode_pages, + [ + ("Config mode", owner._legacy_gpr_config_mode), + ("Input positions", owner._legacy_gpr_input_positions_input), + ("Output positions", owner._legacy_gpr_output_positions_input), + ("Min depth m", owner._legacy_gpr_min_depth_m), + ("Max depth m", owner._legacy_gpr_max_depth_m), + ("Comp power", owner._legacy_gpr_comp_power), + ("SNR thresh", owner._legacy_gpr_snr_thresh), + ("SNR comp max", owner._legacy_gpr_snr_comp_max), + ("Speed m/s", owner._legacy_gpr_speed_m_s), + ("Render mode", owner._legacy_gpr_render_mode), + ("Min visible pairs", owner._legacy_gpr_min_visible_pair_count), + ("Start MHz", owner._legacy_gpr_start_freq_mhz), + ("Stop MHz", owner._legacy_gpr_stop_freq_mhz), + ("Look angle deg", owner._legacy_gpr_look_angle_deg), + ("Visible X min m", owner._legacy_gpr_visible_x_min_m), + ("Visible X max m", owner._legacy_gpr_visible_x_max_m), + ("Visible Z min m", owner._legacy_gpr_visible_z_min_m), + ("Visible Z max m", owner._legacy_gpr_visible_z_max_m), + owner._legacy_gpr_background_subtract_enabled, + ("Mean count", owner._legacy_gpr_background_mean_count), + ], + split_index=10, + ) + owner._processing_mode_pages.addWidget(legacy_gpr_page) + owner._processing_mode.currentTextChanged.connect(owner._on_processing_mode_changed) owner._show_magnitude_checkbox.toggled.connect(owner._on_trace_visibility_changed) owner._show_phase_checkbox.toggled.connect(owner._on_trace_visibility_changed) @@ -333,6 +430,7 @@ def build_processing_group(owner) -> QGroupBox: owner._pass_through_y_max_db.valueChanged.connect(owner._on_processing_live_settings_changed) form.addRow("Mode", owner._processing_mode) form.addRow(owner._processing_mode_pages) + form.addRow(owner._gpr_common_page) owner._bscan_axis.currentTextChanged.connect(owner._on_processing_live_settings_changed) owner._bscan_cut_m.valueChanged.connect(owner._on_processing_live_settings_changed) @@ -341,19 +439,12 @@ def build_processing_group(owner) -> QGroupBox: owner._bscan_start_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed) owner._bscan_stop_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed) owner._bscan_subtract_mean_ascan.toggled.connect(owner._on_processing_live_settings_changed) - owner._gpr_algorithm.currentTextChanged.connect(owner._sync_gpr_algorithm_controls) - owner._gpr_algorithm.currentTextChanged.connect(owner._on_processing_live_settings_changed) owner._gpr_input_positions_input.editingFinished.connect(owner._on_processing_live_settings_changed) 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_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_comp_power.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_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_background_subtract_enabled.toggled.connect(owner._on_processing_live_settings_changed) @@ -365,6 +456,26 @@ def build_processing_group(owner) -> QGroupBox: 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._legacy_gpr_config_mode.currentTextChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_input_positions_input.editingFinished.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_output_positions_input.editingFinished.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_min_depth_m.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_max_depth_m.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_comp_power.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_snr_thresh.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_snr_comp_max.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_start_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_stop_freq_mhz.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_speed_m_s.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_look_angle_deg.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_background_subtract_enabled.toggled.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_background_mean_count.valueChanged.connect(owner._on_processing_live_settings_changed) + owner._legacy_gpr_render_mode.currentTextChanged.connect(owner._on_gpr_visual_settings_changed) + owner._legacy_gpr_min_visible_pair_count.valueChanged.connect(owner._on_gpr_locator_threshold_changed) + owner._legacy_gpr_visible_x_min_m.valueChanged.connect(owner._on_gpr_locator_window_changed) + owner._legacy_gpr_visible_x_max_m.valueChanged.connect(owner._on_gpr_locator_window_changed) + owner._legacy_gpr_visible_z_min_m.valueChanged.connect(owner._on_gpr_locator_window_changed) + owner._legacy_gpr_visible_z_max_m.valueChanged.connect(owner._on_gpr_locator_window_changed) owner._set_processing_mode_page(owner._processing_mode.currentText()) return group diff --git a/python_app/gui/runtime/constraints.py b/python_app/gui/runtime/constraints.py index 9eb3a4e..6f8225e 100644 --- a/python_app/gui/runtime/constraints.py +++ b/python_app/gui/runtime/constraints.py @@ -24,7 +24,7 @@ def validate_processing_mode_constraints( ) return - if processing_mode != "gpr": + if processing_mode not in {"gpr", "legacy_gpr"}: return configured_combos = {(int(combo.input), int(combo.output)) for combo in config.combos} diff --git a/python_app/models/gui_profile_codec.py b/python_app/models/gui_profile_codec.py index ce24f5f..e462a2b 100644 --- a/python_app/models/gui_profile_codec.py +++ b/python_app/models/gui_profile_codec.py @@ -8,6 +8,7 @@ from python_app.models.gui_profile_schema import ( GuiBscanStateModel, GuiDataActionsStateModel, GuiGprStateModel, + GuiLegacyGprStateModel, GuiPassThroughStateModel, GuiPreprocessDialogStateModel, GuiProcessingStateModel, @@ -59,6 +60,15 @@ def _optional_float(object_payload: dict[str, Any], key: str, fallback: float, c return float(raw_value) +def _legacy_gpr_mode_from_algorithm(value: str) -> str | None: + """Translate the short-lived nested GPR algorithm field into legacy mode.""" + if value == "legacy_point": + return "point" + if value == "legacy_extended": + return "extended" + return None + + def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel: """Decode JSON-like payload into :class:`GuiProfileModel`.""" profile = GuiProfileModel(run_config=RunConfigModel.from_dict(payload), gui=None) @@ -91,20 +101,72 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel: pass_through_object = _as_dict(processing_object.get("pass_through"), "gui.processing.pass_through") bscan_object = _as_dict(processing_object.get("bscan"), "gui.processing.bscan") gpr_object = _as_dict(processing_object.get("gpr"), "gui.processing.gpr") + legacy_gpr_object = _as_dict(processing_object.get("legacy_gpr"), "gui.processing.legacy_gpr") root_gpr_object = payload.get("gpr") - gpr_algorithm_default = gui.processing.gpr.algorithm + + selected_mode = _optional_string( + processing_object, + "selected_mode", + gui.processing.selected_mode, + "gui.processing", + ) + legacy_mode_default = gui.processing.legacy_gpr.mode if isinstance(root_gpr_object, dict): if root_gpr_object.get("mode") == "point": - gpr_algorithm_default = "legacy_point" + legacy_mode_default = "point" elif root_gpr_object.get("mode") == "extended": - gpr_algorithm_default = "legacy_extended" + legacy_mode_default = "extended" + legacy_algorithm_mode = _legacy_gpr_mode_from_algorithm(str(gpr_object.get("algorithm", ""))) + if legacy_algorithm_mode is not None: + legacy_mode_default = legacy_algorithm_mode + has_legacy_root_gpr_mode = ( + isinstance(root_gpr_object, dict) + and root_gpr_object.get("mode") in {"point", "extended"} + ) + if selected_mode == "gpr" and (legacy_algorithm_mode is not None or has_legacy_root_gpr_mode): + selected_mode = "legacy_gpr" + + gpr_context = "gui.processing.gpr" + legacy_gpr_context = "gui.processing.legacy_gpr" + + def legacy_string(key: str, fallback: str) -> str: + """Read a legacy field, falling back to the old nested gpr object.""" + return _optional_string( + legacy_gpr_object, + key, + _optional_string(gpr_object, key, fallback, gpr_context), + legacy_gpr_context, + ) + + def legacy_bool(key: str, fallback: bool) -> bool: + """Read a legacy bool, falling back to the old nested gpr object.""" + return _optional_bool( + legacy_gpr_object, + key, + _optional_bool(gpr_object, key, fallback, gpr_context), + legacy_gpr_context, + ) + + def legacy_int(key: str, fallback: int) -> int: + """Read a legacy integer, falling back to the old nested gpr object.""" + return _optional_int( + legacy_gpr_object, + key, + _optional_int(gpr_object, key, fallback, gpr_context), + legacy_gpr_context, + ) + + def legacy_float(key: str, fallback: float) -> float: + """Read a legacy float, falling back to the old nested gpr object.""" + return _optional_float( + legacy_gpr_object, + key, + _optional_float(gpr_object, key, fallback, gpr_context), + legacy_gpr_context, + ) + gui.processing = GuiProcessingStateModel( - selected_mode=_optional_string( - processing_object, - "selected_mode", - gui.processing.selected_mode, - "gui.processing", - ), + selected_mode=selected_mode, pass_through=GuiPassThroughStateModel( show_magnitude=_optional_bool( pass_through_object, @@ -167,12 +229,6 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel: ), ), gpr=GuiGprStateModel( - algorithm=_optional_string( - gpr_object, - "algorithm", - gpr_algorithm_default, - "gui.processing.gpr", - ), input_positions=_optional_string( gpr_object, "input_positions", @@ -209,36 +265,6 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel: gui.processing.gpr.angle_comp_power, "gui.processing.gpr", ), - comp_power=_optional_float( - gpr_object, - "comp_power", - gui.processing.gpr.comp_power, - "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", - ), start_freq_mhz=_optional_float( gpr_object, "start_freq_mhz", @@ -306,27 +332,62 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel: "gui.processing.gpr", ), ), + legacy_gpr=GuiLegacyGprStateModel( + mode=legacy_string("mode", legacy_mode_default), + input_positions=legacy_string("input_positions", gui.processing.legacy_gpr.input_positions), + output_positions=legacy_string("output_positions", gui.processing.legacy_gpr.output_positions), + min_depth_m=legacy_float("min_depth_m", gui.processing.legacy_gpr.min_depth_m), + max_depth_m=legacy_float("max_depth_m", gui.processing.legacy_gpr.max_depth_m), + comp_power=legacy_float("comp_power", gui.processing.legacy_gpr.comp_power), + start_freq_mhz=legacy_float("start_freq_mhz", gui.processing.legacy_gpr.start_freq_mhz), + stop_freq_mhz=legacy_float("stop_freq_mhz", gui.processing.legacy_gpr.stop_freq_mhz), + speed_m_s=legacy_float("speed_m_s", gui.processing.legacy_gpr.speed_m_s), + look_angle_deg=legacy_float("look_angle_deg", gui.processing.legacy_gpr.look_angle_deg), + snr_thresh=legacy_float("snr_thresh", gui.processing.legacy_gpr.snr_thresh), + snr_comp_max=legacy_float("snr_comp_max", gui.processing.legacy_gpr.snr_comp_max), + background_subtract_enabled=legacy_bool( + "background_subtract_enabled", + gui.processing.legacy_gpr.background_subtract_enabled, + ), + background_mean_count=legacy_int( + "background_mean_count", + gui.processing.legacy_gpr.background_mean_count, + ), + render_mode=legacy_string("render_mode", gui.processing.legacy_gpr.render_mode), + min_visible_pair_count=legacy_int( + "min_visible_pair_count", + gui.processing.legacy_gpr.min_visible_pair_count, + ), + visible_x_min_m=legacy_float("visible_x_min_m", gui.processing.legacy_gpr.visible_x_min_m), + visible_x_max_m=legacy_float("visible_x_max_m", gui.processing.legacy_gpr.visible_x_max_m), + visible_z_min_m=legacy_float("visible_z_min_m", gui.processing.legacy_gpr.visible_z_min_m), + visible_z_max_m=legacy_float("visible_z_max_m", gui.processing.legacy_gpr.visible_z_max_m), + ), ) - if gui.processing.selected_mode not in {"pass_through", "bscan", "gpr"}: - raise ValueError("gui.processing.selected_mode must be one of: pass_through, bscan, gpr") + if gui.processing.selected_mode not in {"pass_through", "bscan", "gpr", "legacy_gpr"}: + raise ValueError("gui.processing.selected_mode must be one of: pass_through, bscan, gpr, legacy_gpr") if gui.processing.bscan.axis not in {"abs", "real", "phase"}: raise ValueError("gui.processing.bscan.axis must be one of: abs, real, phase") - if gui.processing.gpr.algorithm not in {"backprojection", "legacy_point", "legacy_extended"}: - raise ValueError("gui.processing.gpr.algorithm must be one of: backprojection, legacy_point, legacy_extended") 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.legacy_gpr.mode not in {"point", "extended"}: + raise ValueError("gui.processing.legacy_gpr.mode must be one of: point, extended") + if gui.processing.legacy_gpr.render_mode not in {"heatmap", "objects_only"}: + raise ValueError("gui.processing.legacy_gpr.render_mode must be one of: heatmap, objects_only") 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.comp_power < 0.0: - raise ValueError("gui.processing.gpr.comp_power must be >= 0") - 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_score < 0.0: raise ValueError("gui.processing.gpr.min_visible_score must be >= 0") + if gui.processing.legacy_gpr.comp_power < 0.0: + raise ValueError("gui.processing.legacy_gpr.comp_power must be >= 0") + if gui.processing.legacy_gpr.snr_thresh < 0.0: + raise ValueError("gui.processing.legacy_gpr.snr_thresh must be >= 0") + if gui.processing.legacy_gpr.snr_comp_max < 0.0: + raise ValueError("gui.processing.legacy_gpr.snr_comp_max must be >= 0") + if gui.processing.legacy_gpr.min_visible_pair_count < 1: + raise ValueError("gui.processing.legacy_gpr.min_visible_pair_count must be >= 1") data_actions_object = _as_dict(gui_object.get("data_actions"), "gui.data_actions") gui.data_actions = GuiDataActionsStateModel( @@ -407,18 +468,12 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]: "subtract_mean_ascan": gui.processing.bscan.subtract_mean_ascan, }, "gpr": { - "algorithm": gui.processing.gpr.algorithm, "input_positions": gui.processing.gpr.input_positions, "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, "range_comp_power": gui.processing.gpr.range_comp_power, "angle_comp_power": gui.processing.gpr.angle_comp_power, - "comp_power": gui.processing.gpr.comp_power, - "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, "start_freq_mhz": gui.processing.gpr.start_freq_mhz, "stop_freq_mhz": gui.processing.gpr.stop_freq_mhz, "background_subtract_enabled": gui.processing.gpr.background_subtract_enabled, @@ -431,6 +486,28 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]: "visible_z_min_m": gui.processing.gpr.visible_z_min_m, "visible_z_max_m": gui.processing.gpr.visible_z_max_m, }, + "legacy_gpr": { + "mode": gui.processing.legacy_gpr.mode, + "input_positions": gui.processing.legacy_gpr.input_positions, + "output_positions": gui.processing.legacy_gpr.output_positions, + "min_depth_m": gui.processing.legacy_gpr.min_depth_m, + "max_depth_m": gui.processing.legacy_gpr.max_depth_m, + "comp_power": gui.processing.legacy_gpr.comp_power, + "start_freq_mhz": gui.processing.legacy_gpr.start_freq_mhz, + "stop_freq_mhz": gui.processing.legacy_gpr.stop_freq_mhz, + "speed_m_s": gui.processing.legacy_gpr.speed_m_s, + "look_angle_deg": gui.processing.legacy_gpr.look_angle_deg, + "snr_thresh": gui.processing.legacy_gpr.snr_thresh, + "snr_comp_max": gui.processing.legacy_gpr.snr_comp_max, + "background_subtract_enabled": gui.processing.legacy_gpr.background_subtract_enabled, + "background_mean_count": gui.processing.legacy_gpr.background_mean_count, + "render_mode": gui.processing.legacy_gpr.render_mode, + "min_visible_pair_count": gui.processing.legacy_gpr.min_visible_pair_count, + "visible_x_min_m": gui.processing.legacy_gpr.visible_x_min_m, + "visible_x_max_m": gui.processing.legacy_gpr.visible_x_max_m, + "visible_z_min_m": gui.processing.legacy_gpr.visible_z_min_m, + "visible_z_max_m": gui.processing.legacy_gpr.visible_z_max_m, + }, }, "data_actions": { "save_count": gui.data_actions.save_count, diff --git a/python_app/models/gui_profile_model.py b/python_app/models/gui_profile_model.py index 5dbcb44..bbb4d3a 100644 --- a/python_app/models/gui_profile_model.py +++ b/python_app/models/gui_profile_model.py @@ -5,6 +5,7 @@ from python_app.models.gui_profile_schema import ( GuiBscanStateModel, GuiDataActionsStateModel, GuiGprStateModel, + GuiLegacyGprStateModel, GuiPassThroughStateModel, GuiPreprocessDialogStateModel, GuiProcessingStateModel, @@ -17,6 +18,7 @@ __all__ = [ "GuiBscanStateModel", "GuiDataActionsStateModel", "GuiGprStateModel", + "GuiLegacyGprStateModel", "GuiPassThroughStateModel", "GuiPreprocessDialogStateModel", "GuiProcessingStateModel", diff --git a/python_app/models/gui_profile_schema.py b/python_app/models/gui_profile_schema.py index c9e4db7..b7d1ae0 100644 --- a/python_app/models/gui_profile_schema.py +++ b/python_app/models/gui_profile_schema.py @@ -47,20 +47,14 @@ class GuiBscanStateModel: @dataclass(slots=True) class GuiGprStateModel: - """UI-only defaults for GPR live settings.""" + """UI-only defaults for coherent backprojection GPR live settings.""" - algorithm: str = "backprojection" input_positions: str = "" output_positions: str = "" min_depth_m: float = 2.0 max_depth_m: float = 14.0 range_comp_power: float = 0.28 angle_comp_power: float = 0.10 - comp_power: float = 0.2 - speed_m_s: float = 0.0 - look_angle_deg: float = 0.0 - snr_thresh: float = 4.5 - snr_comp_max: float = 25.0 start_freq_mhz: float = 3000.0 stop_freq_mhz: float = 6000.0 background_subtract_enabled: bool = True @@ -74,6 +68,32 @@ class GuiGprStateModel: visible_z_max_m: float = 14.0 +@dataclass(slots=True) +class GuiLegacyGprStateModel: + """UI-only defaults for legacy point/extended GPR live settings.""" + + mode: str = "point" + input_positions: str = "" + output_positions: str = "" + min_depth_m: float = 2.0 + max_depth_m: float = 14.0 + comp_power: float = 0.2 + 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 + render_mode: str = "heatmap" + min_visible_pair_count: int = 1 + visible_x_min_m: float = -2.0 + visible_x_max_m: float = 2.0 + visible_z_min_m: float = 0.0 + visible_z_max_m: float = 14.0 + + @dataclass(slots=True) class GuiProcessingStateModel: """UI-only processing-section defaults.""" @@ -82,6 +102,7 @@ class GuiProcessingStateModel: pass_through: GuiPassThroughStateModel = field(default_factory=GuiPassThroughStateModel) bscan: GuiBscanStateModel = field(default_factory=GuiBscanStateModel) gpr: GuiGprStateModel = field(default_factory=GuiGprStateModel) + legacy_gpr: GuiLegacyGprStateModel = field(default_factory=GuiLegacyGprStateModel) @dataclass(slots=True) diff --git a/python_app/orchestration/live_processing_config.py b/python_app/orchestration/live_processing_config.py index 18212f2..7d4aa0b 100644 --- a/python_app/orchestration/live_processing_config.py +++ b/python_app/orchestration/live_processing_config.py @@ -23,7 +23,7 @@ class ProcessingLiveConfig: bscan_gain: float = 1.0 bscan_start_freq_mhz: float = 100.0 bscan_stop_freq_mhz: float = 8800.0 - gpr_algorithm: str = "backprojection" + legacy_gpr_mode: str = "point" gpr_input_positions: list[int] | None = None gpr_output_positions: list[int] | None = None gpr_min_depth_m: float = 2.0 @@ -69,7 +69,7 @@ class ProcessingLiveConfig: "bscan_gain": float(self.bscan_gain), "bscan_start_freq_mhz": float(self.bscan_start_freq_mhz), "bscan_stop_freq_mhz": float(self.bscan_stop_freq_mhz), - "gpr_algorithm": str(self.gpr_algorithm), + "legacy_gpr_mode": str(self.legacy_gpr_mode), "gpr_input_positions": [int(value) for value in self.gpr_input_positions], "gpr_output_positions": [int(value) for value in self.gpr_output_positions], "gpr_min_depth_m": float(self.gpr_min_depth_m), diff --git a/run_config.json b/run_config.json index 50afb47..ace723b 100644 --- a/run_config.json +++ b/run_config.json @@ -215,18 +215,12 @@ "subtract_mean_ascan": false }, "gpr": { - "algorithm": "backprojection", "input_positions": "0,1,2,3", "output_positions": "0,1", "min_depth_m": 2.0, "max_depth_m": 14.0, "range_comp_power": 0.28, "angle_comp_power": 0.1, - "comp_power": 0.2, - "speed_m_s": 0.0, - "look_angle_deg": 0.0, - "snr_thresh": 4.5, - "snr_comp_max": 25.0, "start_freq_mhz": 3000.0, "stop_freq_mhz": 6000.0, "background_subtract_enabled": true, @@ -238,6 +232,28 @@ "visible_x_max_m": 2.0, "visible_z_min_m": 0.0, "visible_z_max_m": 14.0 + }, + "legacy_gpr": { + "mode": "point", + "input_positions": "0,1,2,3", + "output_positions": "0,1", + "min_depth_m": 2.0, + "max_depth_m": 14.0, + "comp_power": 0.2, + "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, + "render_mode": "heatmap", + "min_visible_pair_count": 1, + "visible_x_min_m": -2.0, + "visible_x_max_m": 2.0, + "visible_z_min_m": 0.0, + "visible_z_max_m": 14.0 } }, "data_actions": { diff --git a/run_config_simulator.example.json b/run_config_simulator.example.json index 50afb47..ace723b 100644 --- a/run_config_simulator.example.json +++ b/run_config_simulator.example.json @@ -215,18 +215,12 @@ "subtract_mean_ascan": false }, "gpr": { - "algorithm": "backprojection", "input_positions": "0,1,2,3", "output_positions": "0,1", "min_depth_m": 2.0, "max_depth_m": 14.0, "range_comp_power": 0.28, "angle_comp_power": 0.1, - "comp_power": 0.2, - "speed_m_s": 0.0, - "look_angle_deg": 0.0, - "snr_thresh": 4.5, - "snr_comp_max": 25.0, "start_freq_mhz": 3000.0, "stop_freq_mhz": 6000.0, "background_subtract_enabled": true, @@ -238,6 +232,28 @@ "visible_x_max_m": 2.0, "visible_z_min_m": 0.0, "visible_z_max_m": 14.0 + }, + "legacy_gpr": { + "mode": "point", + "input_positions": "0,1,2,3", + "output_positions": "0,1", + "min_depth_m": 2.0, + "max_depth_m": 14.0, + "comp_power": 0.2, + "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, + "render_mode": "heatmap", + "min_visible_pair_count": 1, + "visible_x_min_m": -2.0, + "visible_x_max_m": 2.0, + "visible_z_min_m": 0.0, + "visible_z_max_m": 14.0 } }, "data_actions": { diff --git a/tmp b/tmp index 8a3798a..6439c3f 100644 --- a/tmp +++ b/tmp @@ -1,3 +1,3 @@ смотри сейчас будем добавлять в проект поддержку еще одного девайса в качестве радара. Когда будешь читать код смотри если есть файлы длинее чем 1300 строк то надо бы будет их грамотно разбить. В целом пиши код как мастер профессионал лучший в мире и самый опытный разработчик, пиши красивейший код, максимально читаемый, грамотный и понятный. Очень внимательнно смотри чтобы не было фолбеков, если в коде уже сейчас видишь какие то фолбеки то скажи где они и что делают, скорее всего будем удалять их в дальнейшем. И когда писать сейчас будешь то не создавай лишнего кода типа фолбеков изза отсутвтивия зависимостей и так далее, лишний код это плохо. объем в идеале уменьшать надо проекта. -Давай постепенно будем добавлять поддержку нового типа радара в код, для начала - сбор данных свипов. По пути /home/europa/Documents/kamil_adc \ No newline at end of file +Давай постепенно будем добавлять поддержку нового типа радара в код, для начала - сбор данных свипов. По пути /home/europa/Documents/kamil_adc лежит проект, который собирает свипы с нового девайса (там формат получается вроде бы как 0x0a step data1 data2 где data 1 это действтиельная часть а 2 это мнимая). Вот надо будет драйвер написать для интеграции в проект. как в случае с мультидевайсом можно только питоновский драйвер оставить, то есть будет запускаться код например из проекта kamil_adc а мы поверх него уже пишем нашу прослойку для интеграции в проект radar_system. Вот желательно немного кода добавтиь. И еще у этого девайса своя конфигурация, увидеть как настраивается устройство и какие параметры можно в проекте \ No newline at end of file