working version
This commit is contained in:
+1086
File diff suppressed because it is too large
Load Diff
@@ -116,15 +116,20 @@ struct PreprocessConfig {
|
||||
};
|
||||
|
||||
struct GprTxGeometry {
|
||||
// Transmitter geometry keyed by output switch position.
|
||||
// Transmitter geometry keyed by output switch position. y_m/z_m default to 0 so
|
||||
// legacy 1D configs continue to render in the y=0, z=0 plane.
|
||||
std::uint32_t output_pos = 0;
|
||||
float x_m = 0.0F;
|
||||
float y_m = 0.0F;
|
||||
float z_m = 0.0F;
|
||||
};
|
||||
|
||||
struct GprRxGeometry {
|
||||
// Receiver geometry keyed by input switch position.
|
||||
// Receiver geometry keyed by input switch position. y_m/z_m default to 0.
|
||||
std::uint32_t input_pos = 0;
|
||||
float x_m = 0.0F;
|
||||
float y_m = 0.0F;
|
||||
float z_m = 0.0F;
|
||||
};
|
||||
|
||||
struct GprConfig {
|
||||
|
||||
@@ -309,6 +309,8 @@ void validate_gpr_config(const GprConfig& config, const RunConfig& run_config) {
|
||||
GprTxGeometry entry{};
|
||||
entry.output_pos = optional_u32(*entry_obj, "output_pos", 0U);
|
||||
entry.x_m = optional_f32(*entry_obj, "x_m", 0.0F);
|
||||
entry.y_m = optional_f32(*entry_obj, "y_m", 0.0F);
|
||||
entry.z_m = optional_f32(*entry_obj, "z_m", 0.0F);
|
||||
config.tx_geometry.push_back(std::move(entry));
|
||||
}
|
||||
}
|
||||
@@ -321,6 +323,8 @@ void validate_gpr_config(const GprConfig& config, const RunConfig& run_config) {
|
||||
GprRxGeometry entry{};
|
||||
entry.input_pos = optional_u32(*entry_obj, "input_pos", 0U);
|
||||
entry.x_m = optional_f32(*entry_obj, "x_m", 0.0F);
|
||||
entry.y_m = optional_f32(*entry_obj, "y_m", 0.0F);
|
||||
entry.z_m = optional_f32(*entry_obj, "z_m", 0.0F);
|
||||
config.rx_geometry.push_back(std::move(entry));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ struct ProcessingLiveConfig {
|
||||
bool gpr_background_subtract_enabled = true;
|
||||
std::uint32_t gpr_background_mean_count = 10U;
|
||||
bool gpr_remove_sidelobe_objects_enabled = true;
|
||||
// BP image is computed in the y=imaging_plane_y_m slice of the 3D grid.
|
||||
// Default 0 keeps legacy 1D antenna layouts imaging in the antenna plane.
|
||||
float gpr_imaging_plane_y_m = 0.0F;
|
||||
bool reprocess_current_result = true;
|
||||
std::uint64_t history_command_seq = 0;
|
||||
HistoryCommand history_command = HistoryCommand::None;
|
||||
|
||||
@@ -305,6 +305,12 @@ void apply_legacy_gpr_algorithm_alias(ProcessingLiveConfig& config, const std::s
|
||||
}
|
||||
config.gpr_remove_sidelobe_objects_enabled = found->get<bool>();
|
||||
}
|
||||
if (const auto found = root.find("gpr_imaging_plane_y_m"); found != root.end()) {
|
||||
if (!found->is_number()) {
|
||||
throw std::runtime_error("processing.gpr_imaging_plane_y_m must be number");
|
||||
}
|
||||
config.gpr_imaging_plane_y_m = static_cast<float>(found->get<double>());
|
||||
}
|
||||
if (const auto found = root.find("reprocess_current_result"); found != root.end()) {
|
||||
if (!found->is_boolean()) {
|
||||
throw std::runtime_error("processing.reprocess_current_result must be bool");
|
||||
|
||||
+126
-53
@@ -49,10 +49,16 @@ constexpr double kScoreCfEps = 1e-12;
|
||||
using PairKey = std::uint64_t;
|
||||
|
||||
struct GeometrySelection {
|
||||
// Per-local-index Tx/Rx antenna coordinates in metres. y_/z_ default to 0
|
||||
// for legacy configs so the imaging plane coincides with the antennas.
|
||||
std::vector<std::uint32_t> input_positions{};
|
||||
std::vector<std::uint32_t> output_positions{};
|
||||
std::vector<double> x_tx{};
|
||||
std::vector<double> y_tx{};
|
||||
std::vector<double> z_tx{};
|
||||
std::vector<double> x_rx{};
|
||||
std::vector<double> y_rx{};
|
||||
std::vector<double> z_rx{};
|
||||
std::unordered_map<std::uint32_t, std::uint32_t> input_local_by_pos{};
|
||||
std::unordered_map<std::uint32_t, std::uint32_t> output_local_by_pos{};
|
||||
};
|
||||
@@ -365,29 +371,43 @@ void normalize_in_place(std::vector<double>& values) {
|
||||
return result;
|
||||
}
|
||||
|
||||
struct AntennaXYZ {
|
||||
double x_m = 0.0;
|
||||
double y_m = 0.0;
|
||||
double z_m = 0.0;
|
||||
};
|
||||
|
||||
[[nodiscard]] auto build_geometry_selection(
|
||||
const config::RunConfig& run_config,
|
||||
const ProcessingLiveConfig& live_config
|
||||
) -> GeometrySelection {
|
||||
std::unordered_map<std::uint32_t, double> tx_x_by_pos{};
|
||||
std::unordered_map<std::uint32_t, AntennaXYZ> tx_by_pos{};
|
||||
for (const auto& entry : run_config.gpr.tx_geometry) {
|
||||
tx_x_by_pos[entry.output_pos] = static_cast<double>(entry.x_m);
|
||||
tx_by_pos[entry.output_pos] = AntennaXYZ{
|
||||
static_cast<double>(entry.x_m),
|
||||
static_cast<double>(entry.y_m),
|
||||
static_cast<double>(entry.z_m),
|
||||
};
|
||||
}
|
||||
|
||||
std::unordered_map<std::uint32_t, double> rx_x_by_pos{};
|
||||
std::unordered_map<std::uint32_t, AntennaXYZ> rx_by_pos{};
|
||||
for (const auto& entry : run_config.gpr.rx_geometry) {
|
||||
rx_x_by_pos[entry.input_pos] = static_cast<double>(entry.x_m);
|
||||
rx_by_pos[entry.input_pos] = AntennaXYZ{
|
||||
static_cast<double>(entry.x_m),
|
||||
static_cast<double>(entry.y_m),
|
||||
static_cast<double>(entry.z_m),
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> available_outputs{};
|
||||
available_outputs.reserve(tx_x_by_pos.size());
|
||||
for (const auto& [position, _] : tx_x_by_pos) {
|
||||
available_outputs.reserve(tx_by_pos.size());
|
||||
for (const auto& [position, _] : tx_by_pos) {
|
||||
available_outputs.push_back(position);
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> available_inputs{};
|
||||
available_inputs.reserve(rx_x_by_pos.size());
|
||||
for (const auto& [position, _] : rx_x_by_pos) {
|
||||
available_inputs.reserve(rx_by_pos.size());
|
||||
for (const auto& [position, _] : rx_by_pos) {
|
||||
available_inputs.push_back(position);
|
||||
}
|
||||
|
||||
@@ -395,18 +415,32 @@ void normalize_in_place(std::vector<double>& values) {
|
||||
selection.output_positions = selected_positions(live_config.gpr_output_positions, std::move(available_outputs));
|
||||
selection.input_positions = selected_positions(live_config.gpr_input_positions, std::move(available_inputs));
|
||||
|
||||
selection.x_tx.reserve(selection.output_positions.size());
|
||||
const auto reserve_axes = [](GeometrySelection& target, std::size_t tx_count, std::size_t rx_count) {
|
||||
target.x_tx.reserve(tx_count);
|
||||
target.y_tx.reserve(tx_count);
|
||||
target.z_tx.reserve(tx_count);
|
||||
target.x_rx.reserve(rx_count);
|
||||
target.y_rx.reserve(rx_count);
|
||||
target.z_rx.reserve(rx_count);
|
||||
};
|
||||
reserve_axes(selection, selection.output_positions.size(), selection.input_positions.size());
|
||||
|
||||
for (std::size_t index = 0U; index < selection.output_positions.size(); ++index) {
|
||||
const auto position = selection.output_positions[index];
|
||||
selection.output_local_by_pos[position] = static_cast<std::uint32_t>(index);
|
||||
selection.x_tx.push_back(tx_x_by_pos[position]);
|
||||
const auto& xyz = tx_by_pos[position];
|
||||
selection.x_tx.push_back(xyz.x_m);
|
||||
selection.y_tx.push_back(xyz.y_m);
|
||||
selection.z_tx.push_back(xyz.z_m);
|
||||
}
|
||||
|
||||
selection.x_rx.reserve(selection.input_positions.size());
|
||||
for (std::size_t index = 0U; index < selection.input_positions.size(); ++index) {
|
||||
const auto position = selection.input_positions[index];
|
||||
selection.input_local_by_pos[position] = static_cast<std::uint32_t>(index);
|
||||
selection.x_rx.push_back(rx_x_by_pos[position]);
|
||||
const auto& xyz = rx_by_pos[position];
|
||||
selection.x_rx.push_back(xyz.x_m);
|
||||
selection.y_rx.push_back(xyz.y_m);
|
||||
selection.z_rx.push_back(xyz.z_m);
|
||||
}
|
||||
|
||||
return selection;
|
||||
@@ -673,19 +707,23 @@ void normalize_pair_ascans(
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] auto distance_3d(double dx, double dy, double dz) -> double {
|
||||
return std::sqrt((dx * dx) + (dy * dy) + (dz * dz));
|
||||
}
|
||||
|
||||
[[nodiscard]] auto build_grid(
|
||||
const std::vector<double>& x_tx,
|
||||
const std::vector<double>& x_rx,
|
||||
const GeometrySelection& selection,
|
||||
double max_depth_m,
|
||||
double min_z_m
|
||||
double min_z_m,
|
||||
double imaging_plane_y_m
|
||||
) -> GridDefinition {
|
||||
GridDefinition grid{};
|
||||
if (x_tx.empty() || x_rx.empty() || !(max_depth_m > min_z_m)) {
|
||||
if (selection.x_tx.empty() || selection.x_rx.empty() || !(max_depth_m > min_z_m)) {
|
||||
return grid;
|
||||
}
|
||||
|
||||
const auto [tx_min_it, tx_max_it] = std::minmax_element(x_tx.begin(), x_tx.end());
|
||||
const auto [rx_min_it, rx_max_it] = std::minmax_element(x_rx.begin(), x_rx.end());
|
||||
const auto [tx_min_it, tx_max_it] = std::minmax_element(selection.x_tx.begin(), selection.x_tx.end());
|
||||
const auto [rx_min_it, rx_max_it] = std::minmax_element(selection.x_rx.begin(), selection.x_rx.end());
|
||||
const double x_min = std::min(*tx_min_it, *rx_min_it) - kXMarginM;
|
||||
const double x_max = std::max(*tx_max_it, *rx_max_it) + kXMarginM;
|
||||
|
||||
@@ -693,8 +731,8 @@ void normalize_pair_ascans(
|
||||
grid.z_grid = build_axis(min_z_m, max_depth_m, kGridHeight);
|
||||
|
||||
const std::size_t cell_count = grid.x_grid.size() * grid.z_grid.size();
|
||||
grid.tx_distance_grids.assign(x_tx.size(), std::vector<double>(cell_count, 0.0));
|
||||
grid.rx_distance_grids.assign(x_rx.size(), std::vector<double>(cell_count, 0.0));
|
||||
grid.tx_distance_grids.assign(selection.x_tx.size(), std::vector<double>(cell_count, 0.0));
|
||||
grid.rx_distance_grids.assign(selection.x_rx.size(), std::vector<double>(cell_count, 0.0));
|
||||
|
||||
for (std::size_t row = 0U; row < grid.z_grid.size(); ++row) {
|
||||
const double z_value = grid.z_grid[row];
|
||||
@@ -702,13 +740,19 @@ void normalize_pair_ascans(
|
||||
const double x_value = grid.x_grid[col];
|
||||
const auto cell_index = (row * grid.x_grid.size()) + col;
|
||||
|
||||
for (std::size_t tx_index = 0U; tx_index < x_tx.size(); ++tx_index) {
|
||||
grid.tx_distance_grids[tx_index][cell_index] =
|
||||
std::hypot(x_value - x_tx[tx_index], z_value);
|
||||
for (std::size_t tx_index = 0U; tx_index < selection.x_tx.size(); ++tx_index) {
|
||||
grid.tx_distance_grids[tx_index][cell_index] = distance_3d(
|
||||
x_value - selection.x_tx[tx_index],
|
||||
imaging_plane_y_m - selection.y_tx[tx_index],
|
||||
z_value - selection.z_tx[tx_index]
|
||||
);
|
||||
}
|
||||
for (std::size_t rx_index = 0U; rx_index < x_rx.size(); ++rx_index) {
|
||||
grid.rx_distance_grids[rx_index][cell_index] =
|
||||
std::hypot(x_value - x_rx[rx_index], z_value);
|
||||
for (std::size_t rx_index = 0U; rx_index < selection.x_rx.size(); ++rx_index) {
|
||||
grid.rx_distance_grids[rx_index][cell_index] = distance_3d(
|
||||
x_value - selection.x_rx[rx_index],
|
||||
imaging_plane_y_m - selection.y_rx[rx_index],
|
||||
z_value - selection.z_rx[rx_index]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,37 +781,50 @@ void normalize_pair_ascans(
|
||||
[[nodiscard]] auto attenuation_components(
|
||||
double r_tx,
|
||||
double r_rx,
|
||||
double z_m
|
||||
double dz_tx,
|
||||
double dz_rx
|
||||
) -> std::pair<double, double> {
|
||||
// Antennas boresight along +Z, so cos(theta) = (z_pixel - z_antenna) / R.
|
||||
const double geo = 1.0 / ((r_tx * r_rx) + 1e-12);
|
||||
const double angle =
|
||||
std::pow(z_m / (r_tx + 1e-12), 2.0) *
|
||||
std::pow(z_m / (r_rx + 1e-12), 2.0);
|
||||
std::pow(dz_tx / (r_tx + 1e-12), 2.0) *
|
||||
std::pow(dz_rx / (r_rx + 1e-12), 2.0);
|
||||
return {geo + 1e-30, angle + 1e-30};
|
||||
}
|
||||
|
||||
[[nodiscard]] auto attenuation_components_at_ref_depth(
|
||||
std::uint32_t tx_index,
|
||||
std::uint32_t rx_index,
|
||||
const std::vector<double>& x_tx,
|
||||
const std::vector<double>& x_rx
|
||||
const GeometrySelection& selection,
|
||||
double imaging_plane_y_m
|
||||
) -> std::pair<double, double> {
|
||||
const double x_center = 0.5 * (x_tx[tx_index] + x_rx[rx_index]);
|
||||
const double r_tx = std::hypot(x_center - x_tx[tx_index], kCompensationReferenceDepthM);
|
||||
const double r_rx = std::hypot(x_center - x_rx[rx_index], kCompensationReferenceDepthM);
|
||||
return attenuation_components(r_tx, r_rx, kCompensationReferenceDepthM);
|
||||
const double x_center = 0.5 * (selection.x_tx[tx_index] + selection.x_rx[rx_index]);
|
||||
const double dz_tx = kCompensationReferenceDepthM - selection.z_tx[tx_index];
|
||||
const double dz_rx = kCompensationReferenceDepthM - selection.z_rx[rx_index];
|
||||
const double r_tx = distance_3d(
|
||||
x_center - selection.x_tx[tx_index],
|
||||
imaging_plane_y_m - selection.y_tx[tx_index],
|
||||
dz_tx
|
||||
);
|
||||
const double r_rx = distance_3d(
|
||||
x_center - selection.x_rx[rx_index],
|
||||
imaging_plane_y_m - selection.y_rx[rx_index],
|
||||
dz_rx
|
||||
);
|
||||
return attenuation_components(r_tx, r_rx, dz_tx, dz_rx);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto compensation_weight(
|
||||
double r_tx,
|
||||
double r_rx,
|
||||
double z_m,
|
||||
double dz_tx,
|
||||
double dz_rx,
|
||||
double geo_ref,
|
||||
double angle_ref,
|
||||
double range_power,
|
||||
double angle_power
|
||||
) -> double {
|
||||
const auto [geo, angle] = attenuation_components(r_tx, r_rx, z_m);
|
||||
const auto [geo, angle] = attenuation_components(r_tx, r_rx, dz_tx, dz_rx);
|
||||
const double geo_norm = geo / geo_ref;
|
||||
const double angle_norm = angle / angle_ref;
|
||||
|
||||
@@ -788,8 +845,8 @@ void normalize_pair_ascans(
|
||||
const std::vector<SelectedTrace>& selected_traces,
|
||||
const std::unordered_map<PairKey, AscanResult>& ascans_by_pair,
|
||||
const GridDefinition& grid,
|
||||
const std::vector<double>& x_tx,
|
||||
const std::vector<double>& x_rx,
|
||||
const GeometrySelection& selection,
|
||||
double imaging_plane_y_m,
|
||||
double velocity_mps,
|
||||
double min_depth_m,
|
||||
double max_depth_m,
|
||||
@@ -821,11 +878,13 @@ void normalize_pair_ascans(
|
||||
const auto [geo_ref, angle_ref] = attenuation_components_at_ref_depth(
|
||||
trace.tx_local_index,
|
||||
trace.rx_local_index,
|
||||
x_tx,
|
||||
x_rx
|
||||
selection,
|
||||
imaging_plane_y_m
|
||||
);
|
||||
const auto& tx_distances = grid.tx_distance_grids[trace.tx_local_index];
|
||||
const auto& rx_distances = grid.rx_distance_grids[trace.rx_local_index];
|
||||
const double z_tx_ant = selection.z_tx[trace.tx_local_index];
|
||||
const double z_rx_ant = selection.z_rx[trace.rx_local_index];
|
||||
|
||||
for (std::size_t row = 0U; row < height; ++row) {
|
||||
const double z_m = grid.z_grid[row];
|
||||
@@ -833,6 +892,8 @@ void normalize_pair_ascans(
|
||||
if (!in_depth_gate) {
|
||||
continue;
|
||||
}
|
||||
const double dz_tx = z_m - z_tx_ant;
|
||||
const double dz_rx = z_m - z_rx_ant;
|
||||
|
||||
for (std::size_t col = 0U; col < width; ++col) {
|
||||
const auto cell_index = (row * width) + col;
|
||||
@@ -847,7 +908,8 @@ void normalize_pair_ascans(
|
||||
const double weight = compensation_weight(
|
||||
r_tx,
|
||||
r_rx,
|
||||
z_m,
|
||||
dz_tx,
|
||||
dz_rx,
|
||||
geo_ref,
|
||||
angle_ref,
|
||||
range_power,
|
||||
@@ -1209,14 +1271,24 @@ void apply_depth_gate(
|
||||
[[nodiscard]] auto bistatic_depth_signature(
|
||||
const ObjectRecord& object,
|
||||
const std::vector<SelectedTrace>& selected_traces,
|
||||
const std::vector<double>& x_tx,
|
||||
const std::vector<double>& x_rx
|
||||
const GeometrySelection& selection,
|
||||
double imaging_plane_y_m
|
||||
) -> std::vector<double> {
|
||||
std::vector<double> signature{};
|
||||
signature.reserve(selected_traces.size());
|
||||
for (const auto& trace : selected_traces) {
|
||||
const double r_tx = std::hypot(object.x_m - x_tx[trace.tx_local_index], object.z_m);
|
||||
const double r_rx = std::hypot(object.x_m - x_rx[trace.rx_local_index], object.z_m);
|
||||
const auto tx = trace.tx_local_index;
|
||||
const auto rx = trace.rx_local_index;
|
||||
const double r_tx = distance_3d(
|
||||
object.x_m - selection.x_tx[tx],
|
||||
imaging_plane_y_m - selection.y_tx[tx],
|
||||
object.z_m - selection.z_tx[tx]
|
||||
);
|
||||
const double r_rx = distance_3d(
|
||||
object.x_m - selection.x_rx[rx],
|
||||
imaging_plane_y_m - selection.y_rx[rx],
|
||||
object.z_m - selection.z_rx[rx]
|
||||
);
|
||||
signature.push_back(0.5 * (r_tx + r_rx));
|
||||
}
|
||||
return signature;
|
||||
@@ -1225,13 +1297,13 @@ void apply_depth_gate(
|
||||
void mark_sidelobe_candidates(
|
||||
std::vector<ObjectRecord>& objects,
|
||||
const std::vector<SelectedTrace>& selected_traces,
|
||||
const std::vector<double>& x_tx,
|
||||
const std::vector<double>& x_rx
|
||||
const GeometrySelection& selection,
|
||||
double imaging_plane_y_m
|
||||
) {
|
||||
std::vector<std::vector<double>> signatures{};
|
||||
signatures.reserve(objects.size());
|
||||
for (const auto& object : objects) {
|
||||
signatures.push_back(bistatic_depth_signature(object, selected_traces, x_tx, x_rx));
|
||||
signatures.push_back(bistatic_depth_signature(object, selected_traces, selection, imaging_plane_y_m));
|
||||
}
|
||||
|
||||
for (std::size_t object_index = 0U; object_index < objects.size(); ++object_index) {
|
||||
@@ -1554,7 +1626,8 @@ void add_bp_score_metrics(
|
||||
}
|
||||
normalize_pair_ascans(ascans_by_pair, velocity_mps, min_depth_m, max_depth_m);
|
||||
|
||||
const auto grid = build_grid(selection.x_tx, selection.x_rx, max_depth_m, kGridZMinM);
|
||||
const double imaging_plane_y_m = static_cast<double>(live_config.gpr_imaging_plane_y_m);
|
||||
const auto grid = build_grid(selection, max_depth_m, kGridZMinM, imaging_plane_y_m);
|
||||
if (grid.x_grid.empty() || grid.z_grid.empty()) {
|
||||
return results;
|
||||
}
|
||||
@@ -1563,8 +1636,8 @@ void add_bp_score_metrics(
|
||||
selected_traces,
|
||||
ascans_by_pair,
|
||||
grid,
|
||||
selection.x_tx,
|
||||
selection.x_rx,
|
||||
selection,
|
||||
imaging_plane_y_m,
|
||||
velocity_mps,
|
||||
min_depth_m,
|
||||
max_depth_m,
|
||||
@@ -1582,7 +1655,7 @@ void add_bp_score_metrics(
|
||||
auto objects = find_bp_objects(display_map, grid);
|
||||
add_local_prominence_metrics(objects, display_map, grid, min_depth_m, max_depth_m);
|
||||
add_incoherent_support_metrics(objects, incoherent_display_map, bp.coherence_factor);
|
||||
mark_sidelobe_candidates(objects, selected_traces, selection.x_tx, selection.x_rx);
|
||||
mark_sidelobe_candidates(objects, selected_traces, selection, imaging_plane_y_m);
|
||||
add_bp_score_metrics(objects, live_config);
|
||||
|
||||
if (live_config.gpr_remove_sidelobe_objects_enabled) {
|
||||
|
||||
@@ -678,7 +678,12 @@ void apply_legacy_motion_correction(
|
||||
return results;
|
||||
}
|
||||
|
||||
const auto grid = build_grid(selection.x_tx, selection.x_rx, max_depth_m, kLegacyGridZMinM);
|
||||
const auto grid = build_grid(
|
||||
selection,
|
||||
max_depth_m,
|
||||
kLegacyGridZMinM,
|
||||
static_cast<double>(live_config.gpr_imaging_plane_y_m)
|
||||
);
|
||||
if (grid.x_grid.empty() || grid.z_grid.empty()) {
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ class AppWindowLiveProcessingMixin:
|
||||
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()),
|
||||
gpr_imaging_plane_y_m=float(self._gpr_imaging_plane_y_m.value()),
|
||||
reprocess_current_result=bool(reprocess_current_result),
|
||||
history_command_seq=int(self._history_command_seq),
|
||||
history_command=str(history_command),
|
||||
@@ -213,6 +214,7 @@ class AppWindowLiveProcessingMixin:
|
||||
"Processing mode selected: pass_through "
|
||||
f"(show_magnitude={self._show_magnitude_checkbox.isChecked()}, "
|
||||
f"show_phase={self._show_phase_checkbox.isChecked()}, "
|
||||
f"combos={self._pass_through_combo_filter_input.text().strip() or '<all>'}, "
|
||||
f"fixed_y={self._pass_through_fixed_y_enabled.isChecked()}, "
|
||||
f"y_range={self._pass_through_y_min_db.value():g}..{self._pass_through_y_max_db.value():g} dB)"
|
||||
)
|
||||
@@ -239,6 +241,7 @@ class AppWindowLiveProcessingMixin:
|
||||
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"imaging_plane_y={self._gpr_imaging_plane_y_m.value():g} m, "
|
||||
f"render_mode={self._gpr_render_mode.currentText()}, "
|
||||
f"min_score={self._gpr_min_visible_score.value():g}, "
|
||||
f"max_draw={self._gpr_max_detected_objects_to_draw.value()}, "
|
||||
|
||||
@@ -235,6 +235,7 @@ class AppWindowConfigProfileIOMixin:
|
||||
self._processing_mode,
|
||||
self._show_magnitude_checkbox,
|
||||
self._show_phase_checkbox,
|
||||
self._pass_through_combo_filter_input,
|
||||
self._pass_through_fixed_y_enabled,
|
||||
self._pass_through_y_min_db,
|
||||
self._pass_through_y_max_db,
|
||||
@@ -262,6 +263,7 @@ class AppWindowConfigProfileIOMixin:
|
||||
self._gpr_background_subtract_enabled,
|
||||
self._gpr_background_mean_count,
|
||||
self._gpr_remove_sidelobe_objects_enabled,
|
||||
self._gpr_imaging_plane_y_m,
|
||||
self._gpr_render_mode,
|
||||
self._gpr_min_visible_score,
|
||||
self._gpr_visible_x_min_m,
|
||||
@@ -378,6 +380,7 @@ class AppWindowConfigProfileIOMixin:
|
||||
self._set_combo_current_text(self._processing_mode, gui_state.processing.selected_mode)
|
||||
self._show_magnitude_checkbox.setChecked(bool(gui_state.processing.pass_through.show_magnitude))
|
||||
self._show_phase_checkbox.setChecked(bool(gui_state.processing.pass_through.show_phase))
|
||||
self._pass_through_combo_filter_input.setText(str(gui_state.processing.pass_through.combo_filter))
|
||||
self._pass_through_fixed_y_enabled.setChecked(bool(gui_state.processing.pass_through.fixed_y_enabled))
|
||||
self._pass_through_y_min_db.setValue(float(gui_state.processing.pass_through.y_min_db))
|
||||
self._pass_through_y_max_db.setValue(float(gui_state.processing.pass_through.y_max_db))
|
||||
@@ -423,6 +426,7 @@ class AppWindowConfigProfileIOMixin:
|
||||
self._gpr_remove_sidelobe_objects_enabled.setChecked(
|
||||
bool(gui_state.processing.gpr.remove_sidelobe_objects_enabled)
|
||||
)
|
||||
self._gpr_imaging_plane_y_m.setValue(float(gui_state.processing.gpr.imaging_plane_y_m))
|
||||
self._set_combo_current_text(self._gpr_render_mode, gui_state.processing.gpr.render_mode)
|
||||
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))
|
||||
|
||||
@@ -65,41 +65,49 @@ class AppWindowConfigStateBuildersMixin:
|
||||
env[key] = value
|
||||
return env
|
||||
|
||||
@staticmethod
|
||||
def _parse_geometry_line_coordinates(parts: list[str]) -> tuple[float, float, float]:
|
||||
"""Parse 1/2/3 trailing coordinate fields into (x, y, z); missing axes default to 0."""
|
||||
x_m = float(parts[0])
|
||||
y_m = float(parts[1]) if len(parts) >= 2 else 0.0
|
||||
z_m = float(parts[2]) if len(parts) >= 3 else 0.0
|
||||
return x_m, y_m, z_m
|
||||
|
||||
@staticmethod
|
||||
def _parse_gpr_tx_geometry_text(text: str) -> list[GprTxGeometryModel]:
|
||||
"""Parse line-based Tx geometry editor text."""
|
||||
"""Parse line-based Tx geometry editor text: `output_pos x_m [y_m] [z_m]`."""
|
||||
entries: list[GprTxGeometryModel] = []
|
||||
for line_number, raw_line in enumerate(text.splitlines(), start=1):
|
||||
line = raw_line.strip()
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split()
|
||||
if len(parts) != 2:
|
||||
raise ValueError(f"Invalid Tx geometry line {line_number}: expected `output_pos x_m`")
|
||||
entries.append(
|
||||
GprTxGeometryModel(
|
||||
output_pos=int(parts[0]),
|
||||
x_m=float(parts[1]),
|
||||
if len(parts) < 2 or len(parts) > 4:
|
||||
raise ValueError(
|
||||
f"Invalid Tx geometry line {line_number}: expected `output_pos x_m [y_m] [z_m]`"
|
||||
)
|
||||
x_m, y_m, z_m = AppWindowConfigStateBuildersMixin._parse_geometry_line_coordinates(parts[1:])
|
||||
entries.append(
|
||||
GprTxGeometryModel(output_pos=int(parts[0]), x_m=x_m, y_m=y_m, z_m=z_m)
|
||||
)
|
||||
return entries
|
||||
|
||||
@staticmethod
|
||||
def _parse_gpr_rx_geometry_text(text: str) -> list[GprRxGeometryModel]:
|
||||
"""Parse line-based Rx geometry editor text."""
|
||||
"""Parse line-based Rx geometry editor text: `input_pos x_m [y_m] [z_m]`."""
|
||||
entries: list[GprRxGeometryModel] = []
|
||||
for line_number, raw_line in enumerate(text.splitlines(), start=1):
|
||||
line = raw_line.strip()
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split()
|
||||
if len(parts) != 2:
|
||||
raise ValueError(f"Invalid Rx geometry line {line_number}: expected `input_pos x_m`")
|
||||
entries.append(
|
||||
GprRxGeometryModel(
|
||||
input_pos=int(parts[0]),
|
||||
x_m=float(parts[1]),
|
||||
if len(parts) < 2 or len(parts) > 4:
|
||||
raise ValueError(
|
||||
f"Invalid Rx geometry line {line_number}: expected `input_pos x_m [y_m] [z_m]`"
|
||||
)
|
||||
x_m, y_m, z_m = AppWindowConfigStateBuildersMixin._parse_geometry_line_coordinates(parts[1:])
|
||||
entries.append(
|
||||
GprRxGeometryModel(input_pos=int(parts[0]), x_m=x_m, y_m=y_m, z_m=z_m)
|
||||
)
|
||||
return entries
|
||||
|
||||
@@ -175,6 +183,7 @@ class AppWindowConfigStateBuildersMixin:
|
||||
pass_through=GuiPassThroughStateModel(
|
||||
show_magnitude=True,
|
||||
show_phase=True,
|
||||
combo_filter="",
|
||||
fixed_y_enabled=False,
|
||||
y_min_db=-100.0,
|
||||
y_max_db=0.0,
|
||||
@@ -203,6 +212,7 @@ class AppWindowConfigStateBuildersMixin:
|
||||
background_subtract_enabled=True,
|
||||
background_mean_count=10,
|
||||
remove_sidelobe_objects_enabled=True,
|
||||
imaging_plane_y_m=0.0,
|
||||
render_mode="heatmap",
|
||||
min_visible_score=0.0,
|
||||
visible_x_min_m=default_gpr_x_min_m,
|
||||
@@ -287,6 +297,7 @@ class AppWindowConfigStateBuildersMixin:
|
||||
pass_through=GuiPassThroughStateModel(
|
||||
show_magnitude=bool(self._show_magnitude_checkbox.isChecked()),
|
||||
show_phase=bool(self._show_phase_checkbox.isChecked()),
|
||||
combo_filter=self._pass_through_combo_filter_input.text().strip(),
|
||||
fixed_y_enabled=bool(self._pass_through_fixed_y_enabled.isChecked()),
|
||||
y_min_db=float(self._pass_through_y_min_db.value()),
|
||||
y_max_db=float(self._pass_through_y_max_db.value()),
|
||||
@@ -315,6 +326,7 @@ class AppWindowConfigStateBuildersMixin:
|
||||
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()),
|
||||
imaging_plane_y_m=float(self._gpr_imaging_plane_y_m.value()),
|
||||
render_mode=self._gpr_render_mode.currentText(),
|
||||
min_visible_score=float(self._gpr_min_visible_score.value()),
|
||||
visible_x_min_m=float(self._gpr_visible_x_min_m.value()),
|
||||
|
||||
@@ -7,6 +7,7 @@ import numpy as np
|
||||
import pyqtgraph as pg
|
||||
|
||||
from python_app.models.dataset_model import ResultCollection, TraceData
|
||||
from python_app.models.run_config_model import parse_combos_from_text
|
||||
|
||||
|
||||
class AppWindowTracePlotMixin:
|
||||
@@ -26,6 +27,24 @@ class AppWindowTracePlotMixin:
|
||||
y_max = float(self._pass_through_y_max_db.value())
|
||||
return bool(self._pass_through_fixed_y_enabled.isChecked()), min(y_min, y_max), max(y_min, y_max)
|
||||
|
||||
def _pass_through_combo_filter(self) -> set[tuple[int, int]] | None:
|
||||
"""Return selected pass-through switch combos, or `None` when all are visible."""
|
||||
text = self._pass_through_combo_filter_input.text().strip()
|
||||
if not text:
|
||||
return None
|
||||
try:
|
||||
return {
|
||||
(int(combo.input), int(combo.output))
|
||||
for combo in parse_combos_from_text(text)
|
||||
}
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._log_warning(
|
||||
"Invalid pass-through switch-combo filter.",
|
||||
details=f"{exc}\nExpected format: input:output,input:output",
|
||||
once_key=f"pass_through_combo_filter_invalid_{text}",
|
||||
)
|
||||
return set()
|
||||
|
||||
def _configure_pass_through_magnitude_axis(self, plot: pg.PlotWidget) -> None:
|
||||
"""Apply pass-through magnitude-axis autorange or fixed Y window."""
|
||||
fixed_y_enabled, y_min, y_max = self._pass_through_fixed_y_range()
|
||||
@@ -91,6 +110,7 @@ class AppWindowTracePlotMixin:
|
||||
if not show_magnitude and not show_phase:
|
||||
self._clear_trace_plots()
|
||||
return False
|
||||
combo_filter = self._pass_through_combo_filter()
|
||||
|
||||
if show_magnitude:
|
||||
mag_item = magnitude_plot.getPlotItem()
|
||||
@@ -133,6 +153,8 @@ class AppWindowTracePlotMixin:
|
||||
x_max = -np.inf
|
||||
for block in collection.blocks:
|
||||
combo_key = (int(block.combo.input_pos), int(block.combo.output_pos))
|
||||
if combo_filter is not None and combo_key not in combo_filter:
|
||||
continue
|
||||
if combo_key not in combo_colors:
|
||||
combo_colors[combo_key] = palette[len(combo_colors) % len(palette)]
|
||||
color = combo_colors[combo_key]
|
||||
|
||||
@@ -480,10 +480,10 @@ class AppWindowPreprocessMixin:
|
||||
|
||||
try:
|
||||
capture_result = session.capture_current_combo()
|
||||
self._record_preprocess_capture(session, capture_result)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._show_exception("Failed to capture preprocess combo", exc)
|
||||
self._abort_capture_sequence()
|
||||
self._on_capture_combo_failed(session, exc)
|
||||
return
|
||||
self._record_preprocess_capture(session, capture_result)
|
||||
|
||||
def _capture_all_remaining(self) -> None:
|
||||
"""Capture all remaining combos for the active preprocess session."""
|
||||
@@ -505,13 +505,36 @@ class AppWindowPreprocessMixin:
|
||||
f"{display_name} batch capture started: remaining="
|
||||
f"{session.state().total_count - session.state().captured_count}"
|
||||
)
|
||||
try:
|
||||
while not session.is_complete():
|
||||
while not session.is_complete():
|
||||
try:
|
||||
capture_result = session.capture_current_combo()
|
||||
self._record_preprocess_capture(session, capture_result)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._show_exception("Failed to capture preprocess combo", exc)
|
||||
self._abort_capture_sequence()
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._on_capture_combo_failed(session, exc)
|
||||
return
|
||||
self._record_preprocess_capture(session, capture_result)
|
||||
|
||||
def _on_capture_combo_failed(
|
||||
self,
|
||||
session: SequentialCaptureSession | MultiRadarSequentialCaptureSession,
|
||||
exc: BaseException,
|
||||
) -> None:
|
||||
"""Report a failed combo capture while preserving the session and prior captures."""
|
||||
state = session.state()
|
||||
combo = state.current_combo
|
||||
combo_text = (
|
||||
f"input={combo.input}, output={combo.output}" if combo is not None else "<unknown>"
|
||||
)
|
||||
self._show_exception(
|
||||
f"Failed to capture combo {combo_text}; previous captures kept, retry when ready",
|
||||
exc,
|
||||
)
|
||||
display_name = preprocess_asset_display_name(session.kind)
|
||||
dialog = self._ensure_preprocess_dialog()
|
||||
dialog.set_status(
|
||||
f"{display_name} capture failed at {combo_text}: "
|
||||
f"{state.captured_count}/{state.total_count} kept, ready to retry"
|
||||
)
|
||||
self._update_capture_dialog_state()
|
||||
|
||||
def _record_preprocess_capture(
|
||||
self,
|
||||
@@ -696,7 +719,11 @@ class AppWindowPreprocessMixin:
|
||||
next_output=next_output,
|
||||
can_undo=state.can_undo,
|
||||
can_finalize=state.is_complete,
|
||||
can_capture_all=(not state.is_complete and state.current_combo is not None),
|
||||
can_capture_all=(
|
||||
state.supports_batch_capture
|
||||
and not state.is_complete
|
||||
and state.current_combo is not None
|
||||
),
|
||||
variant_count=state.variant_count,
|
||||
)
|
||||
|
||||
|
||||
@@ -20,10 +20,19 @@ from PyQt6.QtWidgets import (
|
||||
from python_app.gui.controllers.sections.layout_helpers import FormRow, build_two_column_form_widget
|
||||
|
||||
|
||||
def _format_geometry_row(position: int, x_m: float, y_m: float, z_m: float) -> str:
|
||||
"""Render one geometry row, trimming trailing zero y/z so 1D layouts stay compact."""
|
||||
if z_m != 0.0:
|
||||
return f"{position} {x_m:g} {y_m:g} {z_m:g}"
|
||||
if y_m != 0.0:
|
||||
return f"{position} {x_m:g} {y_m:g}"
|
||||
return f"{position} {x_m:g}"
|
||||
|
||||
|
||||
def _format_tx_geometry(owner) -> str:
|
||||
"""Render Tx geometry defaults into editable line-based text."""
|
||||
return "\n".join(
|
||||
f"{int(entry.output_pos)} {float(entry.x_m):g}"
|
||||
_format_geometry_row(int(entry.output_pos), float(entry.x_m), float(entry.y_m), float(entry.z_m))
|
||||
for entry in owner._defaults_config.gpr.tx_geometry
|
||||
)
|
||||
|
||||
@@ -31,7 +40,7 @@ def _format_tx_geometry(owner) -> str:
|
||||
def _format_rx_geometry(owner) -> str:
|
||||
"""Render Rx geometry defaults into editable line-based text."""
|
||||
return "\n".join(
|
||||
f"{int(entry.input_pos)} {float(entry.x_m):g}"
|
||||
_format_geometry_row(int(entry.input_pos), float(entry.x_m), float(entry.y_m), float(entry.z_m))
|
||||
for entry in owner._defaults_config.gpr.rx_geometry
|
||||
)
|
||||
|
||||
@@ -71,6 +80,9 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
owner._show_phase_checkbox = QCheckBox("Show phase")
|
||||
owner._show_phase_checkbox.setChecked(bool(pass_defaults.show_phase))
|
||||
|
||||
owner._pass_through_combo_filter_input = QLineEdit(str(pass_defaults.combo_filter))
|
||||
owner._pass_through_combo_filter_input.setPlaceholderText("empty = all, e.g. 0:0,1:0")
|
||||
|
||||
owner._pass_through_fixed_y_enabled = QCheckBox("Fix magnitude Y range")
|
||||
owner._pass_through_fixed_y_enabled.setChecked(bool(pass_defaults.fixed_y_enabled))
|
||||
|
||||
@@ -93,11 +105,12 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
[
|
||||
owner._show_magnitude_checkbox,
|
||||
owner._show_phase_checkbox,
|
||||
("Switch combos", owner._pass_through_combo_filter_input),
|
||||
owner._pass_through_fixed_y_enabled,
|
||||
("Y min dB", owner._pass_through_y_min_db),
|
||||
("Y max dB", owner._pass_through_y_max_db),
|
||||
],
|
||||
split_index=3,
|
||||
split_index=4,
|
||||
)
|
||||
owner._processing_mode_pages.addWidget(pass_through_page)
|
||||
|
||||
@@ -162,11 +175,11 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
owner._gpr_relative_permittivity.setValue(float(gpr_defaults.relative_permittivity))
|
||||
|
||||
owner._gpr_tx_geometry_input = QPlainTextEdit(_format_tx_geometry(owner))
|
||||
owner._gpr_tx_geometry_input.setPlaceholderText("output_pos x_m")
|
||||
owner._gpr_tx_geometry_input.setPlaceholderText("output_pos x_m [y_m] [z_m]")
|
||||
owner._gpr_tx_geometry_input.setFixedHeight(78)
|
||||
|
||||
owner._gpr_rx_geometry_input = QPlainTextEdit(_format_rx_geometry(owner))
|
||||
owner._gpr_rx_geometry_input.setPlaceholderText("input_pos x_m")
|
||||
owner._gpr_rx_geometry_input.setPlaceholderText("input_pos x_m [y_m] [z_m]")
|
||||
owner._gpr_rx_geometry_input.setFixedHeight(78)
|
||||
|
||||
owner._gpr_common_page = _build_processing_mode_page(
|
||||
@@ -277,6 +290,15 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
owner._gpr_visible_z_max_m.setSingleStep(0.1)
|
||||
owner._gpr_visible_z_max_m.setValue(float(gpr_live_defaults.visible_z_max_m))
|
||||
|
||||
owner._gpr_imaging_plane_y_m = QDoubleSpinBox()
|
||||
owner._gpr_imaging_plane_y_m.setDecimals(3)
|
||||
owner._gpr_imaging_plane_y_m.setRange(-50.0, 50.0)
|
||||
owner._gpr_imaging_plane_y_m.setSingleStep(0.05)
|
||||
owner._gpr_imaging_plane_y_m.setValue(float(gpr_live_defaults.imaging_plane_y_m))
|
||||
owner._gpr_imaging_plane_y_m.setToolTip(
|
||||
"Y coordinate of the BP imaging slice (m). Use 0 for legacy 1D antenna layouts."
|
||||
)
|
||||
|
||||
gpr_page = _build_processing_mode_page(
|
||||
owner._processing_mode_pages,
|
||||
[
|
||||
@@ -293,6 +315,7 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
("Draw top M objects", owner._gpr_draw_top_m_objects),
|
||||
("Start MHz", owner._gpr_start_freq_mhz),
|
||||
("Stop MHz", owner._gpr_stop_freq_mhz),
|
||||
("Imaging plane Y m", owner._gpr_imaging_plane_y_m),
|
||||
("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),
|
||||
@@ -445,6 +468,7 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
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)
|
||||
owner._pass_through_combo_filter_input.editingFinished.connect(owner._on_trace_visibility_changed)
|
||||
owner._pass_through_fixed_y_enabled.toggled.connect(owner._sync_pass_through_y_controls)
|
||||
owner._pass_through_fixed_y_enabled.toggled.connect(owner._on_processing_live_settings_changed)
|
||||
owner._pass_through_y_min_db.valueChanged.connect(owner._on_processing_live_settings_changed)
|
||||
@@ -472,6 +496,7 @@ def build_processing_group(owner) -> QGroupBox:
|
||||
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_imaging_plane_y_m.valueChanged.connect(owner._on_processing_live_settings_changed)
|
||||
owner._gpr_render_mode.currentTextChanged.connect(owner._on_gpr_visual_settings_changed)
|
||||
owner._gpr_min_visible_score.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
|
||||
owner._gpr_max_detected_objects_to_draw.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
|
||||
|
||||
@@ -49,10 +49,10 @@ def build_switch_group(owner) -> QGroupBox:
|
||||
single_row = QHBoxLayout()
|
||||
single_row.setSpacing(8)
|
||||
single_row.addWidget(QLabel("Single combo"))
|
||||
single_row.addWidget(QLabel("Output"))
|
||||
single_row.addWidget(owner._single_combo_output)
|
||||
single_row.addWidget(QLabel("Input"))
|
||||
single_row.addWidget(owner._single_combo_input)
|
||||
single_row.addWidget(QLabel("Output"))
|
||||
single_row.addWidget(owner._single_combo_output)
|
||||
single_row.addWidget(owner._single_combo_select_button)
|
||||
layout.addLayout(single_row)
|
||||
|
||||
|
||||
@@ -93,6 +93,14 @@ class MultiDeviceVnaController:
|
||||
if not self._reference_configuration_applied:
|
||||
self._configure_reference_clocks()
|
||||
|
||||
# Even when the device-side configuration matches and we skip reconfiguration,
|
||||
# the host-side packet queue has been accumulating datapoints from cycles that
|
||||
# ran between calls. Draining here guarantees the next collect_running_sweep_cycles
|
||||
# returns a freshly-arriving cycle (the cycle tracker waits for point_index==0).
|
||||
# Without this drain, callers would receive whichever stale cycle happened to be
|
||||
# at the head of the queue — e.g. data from before a manual cable swap.
|
||||
self._drain_all_received_packets()
|
||||
|
||||
if (
|
||||
self._sweep_is_running
|
||||
and self._last_applied_sweep_configuration == sweep_configuration
|
||||
@@ -104,7 +112,6 @@ class MultiDeviceVnaController:
|
||||
self._send_idle_to_all_devices()
|
||||
time.sleep(self._reconfigure_delay_s)
|
||||
|
||||
self._drain_all_received_packets()
|
||||
self._configure_sweep_on_all_devices(
|
||||
sweep_configuration,
|
||||
master_stimulus_ports=stimulus_ports,
|
||||
|
||||
@@ -180,6 +180,12 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
|
||||
gui.processing.pass_through.show_phase,
|
||||
"gui.processing.pass_through",
|
||||
),
|
||||
combo_filter=_optional_string(
|
||||
pass_through_object,
|
||||
"combo_filter",
|
||||
gui.processing.pass_through.combo_filter,
|
||||
"gui.processing.pass_through",
|
||||
),
|
||||
fixed_y_enabled=_optional_bool(
|
||||
pass_through_object,
|
||||
"fixed_y_enabled",
|
||||
@@ -313,6 +319,12 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
|
||||
gui.processing.gpr.remove_sidelobe_objects_enabled,
|
||||
"gui.processing.gpr",
|
||||
),
|
||||
imaging_plane_y_m=_optional_float(
|
||||
gpr_object,
|
||||
"imaging_plane_y_m",
|
||||
gui.processing.gpr.imaging_plane_y_m,
|
||||
"gui.processing.gpr",
|
||||
),
|
||||
render_mode=_optional_string(
|
||||
gpr_object,
|
||||
"render_mode",
|
||||
@@ -482,6 +494,7 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]:
|
||||
"pass_through": {
|
||||
"show_magnitude": gui.processing.pass_through.show_magnitude,
|
||||
"show_phase": gui.processing.pass_through.show_phase,
|
||||
"combo_filter": gui.processing.pass_through.combo_filter,
|
||||
"fixed_y_enabled": gui.processing.pass_through.fixed_y_enabled,
|
||||
"y_min_db": gui.processing.pass_through.y_min_db,
|
||||
"y_max_db": gui.processing.pass_through.y_max_db,
|
||||
@@ -510,6 +523,7 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]:
|
||||
"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,
|
||||
"imaging_plane_y_m": gui.processing.gpr.imaging_plane_y_m,
|
||||
"render_mode": gui.processing.gpr.render_mode,
|
||||
"min_visible_score": gui.processing.gpr.min_visible_score,
|
||||
"visible_x_min_m": gui.processing.gpr.visible_x_min_m,
|
||||
|
||||
@@ -27,6 +27,7 @@ class GuiPassThroughStateModel:
|
||||
|
||||
show_magnitude: bool = True
|
||||
show_phase: bool = True
|
||||
combo_filter: str = ""
|
||||
fixed_y_enabled: bool = False
|
||||
y_min_db: float = -100.0
|
||||
y_max_db: float = 0.0
|
||||
@@ -63,6 +64,7 @@ class GuiGprStateModel:
|
||||
background_subtract_enabled: bool = True
|
||||
background_mean_count: int = 10
|
||||
remove_sidelobe_objects_enabled: bool = True
|
||||
imaging_plane_y_m: float = 0.0
|
||||
render_mode: str = "heatmap"
|
||||
min_visible_score: float = 0.0
|
||||
visible_x_min_m: float = -2.0
|
||||
|
||||
@@ -327,6 +327,8 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
|
||||
GprTxGeometryModel(
|
||||
output_pos=int(entry_payload.get("output_pos", 0)),
|
||||
x_m=float(entry_payload.get("x_m", 0.0)),
|
||||
y_m=float(entry_payload.get("y_m", 0.0)),
|
||||
z_m=float(entry_payload.get("z_m", 0.0)),
|
||||
)
|
||||
)
|
||||
model.gpr.rx_geometry = []
|
||||
@@ -338,6 +340,8 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
|
||||
GprRxGeometryModel(
|
||||
input_pos=int(entry_payload.get("input_pos", 0)),
|
||||
x_m=float(entry_payload.get("x_m", 0.0)),
|
||||
y_m=float(entry_payload.get("y_m", 0.0)),
|
||||
z_m=float(entry_payload.get("z_m", 0.0)),
|
||||
)
|
||||
)
|
||||
model.apply_device_model_constraints()
|
||||
@@ -519,6 +523,8 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
|
||||
{
|
||||
"output_pos": entry.output_pos,
|
||||
"x_m": entry.x_m,
|
||||
"y_m": entry.y_m,
|
||||
"z_m": entry.z_m,
|
||||
}
|
||||
for entry in model.gpr.tx_geometry
|
||||
],
|
||||
@@ -526,6 +532,8 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
|
||||
{
|
||||
"input_pos": entry.input_pos,
|
||||
"x_m": entry.x_m,
|
||||
"y_m": entry.y_m,
|
||||
"z_m": entry.z_m,
|
||||
}
|
||||
for entry in model.gpr.rx_geometry
|
||||
],
|
||||
|
||||
@@ -223,10 +223,15 @@ class PreprocessModel:
|
||||
|
||||
@dataclass(slots=True)
|
||||
class GprTxGeometryModel:
|
||||
"""One transmitter geometry record keyed by output switch position."""
|
||||
"""One transmitter geometry record keyed by output switch position.
|
||||
|
||||
y_m / z_m default to 0 so 1D antenna layouts keep their pre-3D semantics.
|
||||
"""
|
||||
|
||||
output_pos: int = 0
|
||||
x_m: float = 0.0
|
||||
y_m: float = 0.0
|
||||
z_m: float = 0.0
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -235,6 +240,8 @@ class GprRxGeometryModel:
|
||||
|
||||
input_pos: int = 0
|
||||
x_m: float = 0.0
|
||||
y_m: float = 0.0
|
||||
z_m: float = 0.0
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
|
||||
@@ -43,6 +43,7 @@ class ProcessingLiveConfig:
|
||||
gpr_background_subtract_enabled: bool = True
|
||||
gpr_background_mean_count: int = 10
|
||||
gpr_remove_sidelobe_objects_enabled: bool = True
|
||||
gpr_imaging_plane_y_m: float = 0.0
|
||||
reprocess_current_result: bool = True
|
||||
history_command_seq: int = 0
|
||||
history_command: str = "none"
|
||||
@@ -93,6 +94,7 @@ class ProcessingLiveConfig:
|
||||
"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),
|
||||
"gpr_imaging_plane_y_m": float(self.gpr_imaging_plane_y_m),
|
||||
"reprocess_current_result": bool(self.reprocess_current_result),
|
||||
"history_command_seq": int(self.history_command_seq),
|
||||
"history_command": str(self.history_command),
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Tests for GUI profile persistence."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from python_app.models.gui_profile_model import (
|
||||
GuiPassThroughStateModel,
|
||||
GuiProcessingStateModel,
|
||||
GuiProfileModel,
|
||||
GuiStateModel,
|
||||
)
|
||||
|
||||
|
||||
class GuiProfileCodecTest(unittest.TestCase):
|
||||
def test_pass_through_combo_filter_round_trips(self) -> None:
|
||||
profile = GuiProfileModel(
|
||||
gui=GuiStateModel(
|
||||
processing=GuiProcessingStateModel(
|
||||
pass_through=GuiPassThroughStateModel(combo_filter="0:0,1:0")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
encoded = profile.to_dict()
|
||||
decoded = GuiProfileModel.from_dict(encoded)
|
||||
|
||||
self.assertIsNotNone(decoded.gui)
|
||||
assert decoded.gui is not None
|
||||
self.assertEqual(decoded.gui.processing.pass_through.combo_filter, "0:0,1:0")
|
||||
self.assertEqual(encoded["gui"]["processing"]["pass_through"]["combo_filter"], "0:0,1:0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -176,6 +176,7 @@ class MultiRadarSequentialCaptureSession:
|
||||
can_undo=bool(self._captured_batches),
|
||||
is_complete=self.is_complete(),
|
||||
variant_count=len(self._radar_variants),
|
||||
supports_batch_capture=not self._manual_multi_device_capture,
|
||||
)
|
||||
|
||||
def capture_current_combo(self) -> MultiRadarCaptureBatch:
|
||||
@@ -186,9 +187,11 @@ class MultiRadarSequentialCaptureSession:
|
||||
if combo is None:
|
||||
raise RuntimeError("Capture session is already complete")
|
||||
|
||||
pending_traces_by_radar_key: dict[str, list[TraceData]] = {}
|
||||
display_traces: list[TraceData] = []
|
||||
variant_labels: list[str] = []
|
||||
|
||||
if self._is_multi_device:
|
||||
traces: list[TraceData] = []
|
||||
variant_labels: list[str] = []
|
||||
for variant in self._radar_variants:
|
||||
self._radar.configure(variant.config.radar.sweep)
|
||||
if self._base_config.runtime.settling_ms > 0:
|
||||
@@ -198,56 +201,47 @@ class MultiRadarSequentialCaptureSession:
|
||||
raise RuntimeError(f"Multi-device variant {variant.display_name} returned no traces")
|
||||
if self._manual_multi_device_capture:
|
||||
trace = select_trace_for_combo(collection, combo)
|
||||
self._traces_by_radar_key[variant.radar_key].append(trace)
|
||||
traces.append(trace)
|
||||
pending_traces_by_radar_key[variant.radar_key] = [trace]
|
||||
display_traces.append(trace)
|
||||
else:
|
||||
self._traces_by_radar_key[variant.radar_key].extend(collection.traces)
|
||||
traces.append(collection.traces[-1])
|
||||
pending_traces_by_radar_key[variant.radar_key] = list(collection.traces)
|
||||
display_traces.append(collection.traces[-1])
|
||||
variant_labels.append(variant.display_name)
|
||||
|
||||
batch = MultiRadarCaptureBatch(
|
||||
combo=combo,
|
||||
traces=tuple(traces),
|
||||
variant_labels=tuple(variant_labels),
|
||||
)
|
||||
self._captured_batches.append(batch)
|
||||
if self._manual_multi_device_capture:
|
||||
self._next_index += 1
|
||||
else:
|
||||
self._next_index = len(self._combos)
|
||||
return batch
|
||||
|
||||
assert self._input_switch is not None
|
||||
assert self._output_switch is not None
|
||||
self._output_switch.switch_to(combo.output)
|
||||
self._input_switch.switch_to(combo.input)
|
||||
if self._base_config.runtime.settling_ms > 0:
|
||||
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
|
||||
|
||||
traces: list[TraceData] = []
|
||||
variant_labels: list[str] = []
|
||||
for variant in self._radar_variants:
|
||||
self._radar.configure(variant.config.radar.sweep)
|
||||
else:
|
||||
assert self._input_switch is not None
|
||||
assert self._output_switch is not None
|
||||
self._output_switch.switch_to(combo.output)
|
||||
self._input_switch.switch_to(combo.input)
|
||||
if self._base_config.runtime.settling_ms > 0:
|
||||
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
|
||||
sweep = self._radar.acquire()
|
||||
trace = TraceData(
|
||||
combo=ComboKey(input_pos=combo.input, output_pos=combo.output),
|
||||
frequency_hz=np.asarray(sweep.x, dtype=np.float32),
|
||||
s11=np.asarray(sweep.trace("s11"), dtype=np.complex64),
|
||||
s21=np.asarray(sweep.trace("s21"), dtype=np.complex64),
|
||||
)
|
||||
traces.append(trace)
|
||||
variant_labels.append(variant.display_name)
|
||||
self._traces_by_radar_key[variant.radar_key].append(trace)
|
||||
|
||||
for variant in self._radar_variants:
|
||||
self._radar.configure(variant.config.radar.sweep)
|
||||
if self._base_config.runtime.settling_ms > 0:
|
||||
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
|
||||
sweep = self._radar.acquire()
|
||||
trace = TraceData(
|
||||
combo=ComboKey(input_pos=combo.input, output_pos=combo.output),
|
||||
frequency_hz=np.asarray(sweep.x, dtype=np.float32),
|
||||
s11=np.asarray(sweep.trace("s11"), dtype=np.complex64),
|
||||
s21=np.asarray(sweep.trace("s21"), dtype=np.complex64),
|
||||
)
|
||||
pending_traces_by_radar_key[variant.radar_key] = [trace]
|
||||
display_traces.append(trace)
|
||||
variant_labels.append(variant.display_name)
|
||||
|
||||
for radar_key, traces in pending_traces_by_radar_key.items():
|
||||
self._traces_by_radar_key[radar_key].extend(traces)
|
||||
batch = MultiRadarCaptureBatch(
|
||||
combo=combo,
|
||||
traces=tuple(traces),
|
||||
traces=tuple(display_traces),
|
||||
variant_labels=tuple(variant_labels),
|
||||
)
|
||||
self._captured_batches.append(batch)
|
||||
self._next_index += 1
|
||||
if self._is_multi_device and not self._manual_multi_device_capture:
|
||||
self._next_index = len(self._combos)
|
||||
else:
|
||||
self._next_index += 1
|
||||
return batch
|
||||
|
||||
def undo_last_capture(self) -> MultiRadarCaptureBatch:
|
||||
|
||||
@@ -30,6 +30,7 @@ class SequentialCaptureState:
|
||||
can_undo: bool
|
||||
is_complete: bool
|
||||
variant_count: int = 1
|
||||
supports_batch_capture: bool = True
|
||||
|
||||
|
||||
class SequentialCaptureSession:
|
||||
@@ -141,6 +142,7 @@ class SequentialCaptureSession:
|
||||
current_combo=current_combo,
|
||||
can_undo=bool(self._traces),
|
||||
is_complete=self.is_complete(),
|
||||
supports_batch_capture=not self._manual_multi_device_capture,
|
||||
)
|
||||
|
||||
def capture_current_combo(self) -> TraceData:
|
||||
@@ -153,6 +155,8 @@ class SequentialCaptureSession:
|
||||
|
||||
if self._is_multi_device:
|
||||
collection = self._radar.acquire_collection(collection_id=1)
|
||||
if not collection.traces:
|
||||
raise RuntimeError("Multi-device capture returned no traces")
|
||||
if self._manual_multi_device_capture:
|
||||
trace = select_trace_for_combo(collection, combo)
|
||||
self._traces.append(trace)
|
||||
@@ -161,8 +165,6 @@ class SequentialCaptureSession:
|
||||
|
||||
self._traces.extend(collection.traces)
|
||||
self._next_index = len(self._combos)
|
||||
if not collection.traces:
|
||||
raise RuntimeError("Multi-device capture returned no traces")
|
||||
return collection.traces[-1]
|
||||
|
||||
assert self._input_switch is not None
|
||||
|
||||
Reference in New Issue
Block a user