Show non-plotted measurements #6

Merged
iamdoubz merged 1 commits from show_nodata_plots into main 2026-05-01 00:16:24 -05:00
2 changed files with 40 additions and 8 deletions
Showing only changes of commit 6f24535542 - Show all commits

No files matched your search

+12
View File
@@ -94,6 +94,18 @@ class Session:
values.append(sum(readings) / len(readings)) values.append(sum(readings) / len(readings))
return points, values return points, values
def get_missing_points(self, bssids: list[str]) -> list[tuple[float, float]]:
"""
Return positions of measurements where none of the requested BSSIDs
were visible. These are locations where the user took a reading but
the selected network(s) were completely out of range.
"""
missing = []
for m in self.measurements:
if not any(b in m.signals for b in bssids):
missing.append((m.x, m.y))
return missing
def save(self, path: str): def save(self, path: str):
"""Save session to JSON file.""" """Save session to JSON file."""
data = { data = {
+28 -8
View File
@@ -16,8 +16,10 @@ from data import Session, Measurement
from interpolator import interpolate, HeatmapData, get_signal_at from interpolator import interpolate, HeatmapData, get_signal_at
# Custom colormap: deep blue (weak) → cyan → green → yellow → red (strong) # Custom colormap: black (no signal) → dark navy → blue → cyan → green → yellow → red (strong)
# Black occupies the very bottom so "not found" markers read naturally against the scale.
SIGNAL_COLORS = [ SIGNAL_COLORS = [
(0.00, 0.00, 0.00), # no signal: black ← new
(0.05, 0.05, 0.35), # very weak: dark navy (0.05, 0.05, 0.35), # very weak: dark navy
(0.10, 0.40, 0.80), # weak: blue (0.10, 0.40, 0.80), # weak: blue
(0.10, 0.80, 0.80), # moderate: cyan (0.10, 0.80, 0.80), # moderate: cyan
@@ -69,6 +71,7 @@ def render_heatmap(
ax.clear() ax.clear()
points, values = session.get_points_and_values_multi(bssids) points, values = session.get_points_and_values_multi(bssids)
missing_points = session.get_missing_points(bssids) # positions with no signal
w, h = session.canvas_width, session.canvas_height w, h = session.canvas_width, session.canvas_height
# Build a human-readable label for the title # Build a human-readable label for the title
@@ -119,6 +122,10 @@ def render_heatmap(
fontsize=7, color='gray', va='bottom') fontsize=7, color='gray', va='bottom')
cbar.ax.text(1.4, -30, "Excellent", transform=cbar.ax.get_yaxis_transform(), cbar.ax.text(1.4, -30, "Excellent", transform=cbar.ax.get_yaxis_transform(),
fontsize=7, color='gray', va='top') fontsize=7, color='gray', va='top')
# Black swatch at the very bottom representing "no signal found"
cbar.ax.text(1.4, -95, "No signal", transform=cbar.ax.get_yaxis_transform(),
fontsize=7, color='black', va='top',
bbox=dict(facecolor='white', edgecolor='none', pad=1.5))
else: else:
# ── Not enough points yet — show progress indicator ──────────────── # ── Not enough points yet — show progress indicator ────────────────
collected = len(points) collected = len(points)
@@ -141,19 +148,32 @@ def render_heatmap(
zorder=3) zorder=3)
# ── Draw measurement points ─────────────────────────────────────────────── # ── Draw measurement points ───────────────────────────────────────────────
if show_points and points: radius = max(w, h) * 0.012
if show_points:
# Valid signal points — colored by strength
for (px, py), dbm in zip(points, values): for (px, py), dbm in zip(points, values):
color = SIGNAL_CMAP((dbm + 90) / 60) color = SIGNAL_CMAP((dbm + 90) / 60)
circle = Circle((px, py), radius=max(w, h) * 0.012, ax.add_patch(Circle((px, py), radius=radius,
facecolor=color, edgecolor='white', facecolor=color, edgecolor='white',
linewidth=1.5, zorder=5, alpha=0.95) linewidth=1.5, zorder=5, alpha=0.95))
ax.add_patch(circle) ax.text(px, py - radius * 1.8, f"{int(round(dbm))}",
ax.text(px, py - max(w, h) * 0.022, f"{int(round(dbm))}",
ha='center', va='bottom', fontsize=7, color='white', ha='center', va='bottom', fontsize=7, color='white',
fontweight='bold', zorder=6) fontweight='bold', zorder=6)
# Missing signal points — black circle with "?" label
for (px, py) in missing_points:
ax.add_patch(Circle((px, py), radius=radius,
facecolor='black', edgecolor='white',
linewidth=1.5, zorder=5, alpha=0.95))
ax.text(px, py, "?",
ha='center', va='center', fontsize=7, color='white',
fontweight='bold', zorder=6)
# ── Labels & styling ────────────────────────────────────────────────────── # ── Labels & styling ──────────────────────────────────────────────────────
point_note = f"{len(points)} measurement{'s' if len(points) != 1 else ''}" total_points = len(points) + len(missing_points)
point_note = f"{total_points} measurement{'s' if total_points != 1 else ''}"
if missing_points:
point_note += f" • {len(missing_points)} out of range (●)"
if len(bssids) > 1: if len(bssids) > 1:
point_note += f" • avg of {len(bssids)} BSSIDs" point_note += f" • avg of {len(bssids)} BSSIDs"
if not session.floorplan_path: if not session.floorplan_path: