Render sample_spectrogram for split-I/Q RadioDataset samples #36

Merged
benchinnery merged 1 commits from fix-spectrogram-split-iq into main 2026-07-14 13:54:10 -04:00
Owner

Four spec changes to src/ria_toolkit_oss/viz/radio_dataset.py:

  1. Added _to_complex_1d: Normalizes any sample to a 1-D complex signal. None on empty.
  2. Compatibility gate now normalizes first, so split-I/Q (2, T) reports true length T instead of 2
  3. sample_spectrogram_plot normalizes once, returns the styled "Not Available" figure for unusable/<32 samples, and uses sample_data.size.
  4. _compute_spectrogram measures length via reshape(-1)

Tests (new tests/viz/test_radio_dataset.py)

Parametrized over every layout in the spec: complex 1-D, (2, 1024) I/Q rows (the reported bug), (1024, 2) I/Q cols, real 1-D, (2, 4, 256) multi-channel all render a real spectrogram; (2,)/empty still return
"Not Available". 16 passed.

Four spec changes to src/ria_toolkit_oss/viz/radio_dataset.py: 1. Added _to_complex_1d: Normalizes any sample to a 1-D complex signal. None on empty. 2. Compatibility gate now normalizes first, so split-I/Q (2, T) reports true length T instead of 2 3. sample_spectrogram_plot normalizes once, returns the styled "Not Available" figure for unusable/<32 samples, and uses sample_data.size. 4. _compute_spectrogram measures length via reshape(-1) Tests (new tests/viz/test_radio_dataset.py) Parametrized over every layout in the spec: complex 1-D, (2, 1024) I/Q rows (the reported bug), (1024, 2) I/Q cols, real 1-D, (2, 4, 256) multi-channel all render a real spectrogram; (2,)/empty still return "Not Available". 16 passed.
benchinnery added 1 commit 2026-07-14 12:22:51 -04:00
fix(viz): render sample_spectrogram for split-I/Q RadioDataset samples
RadioDataset samples are commonly split I/Q with shape (2, T) (row 0 = I,
row 1 = Q). `sample_spectrogram_plot` assumed 1-D complex, so `len(sample)`
returned 2 (the I/Q axis) — the compatibility gate saw `2 < 32` and every
dataset showed "doesn't have sufficient signal data for spectrogram
visualization", and the fallback path raised "need at least 32 samples, got 2".

Normalize each sample to a 1-D complex signal before measuring/plotting:
- add `_to_complex_1d` (complex any-shape -> flat; (2, ...) I/Q rows and
  (..., 2) I/Q cols -> I + jQ; real 1-D -> real signal; None on empty).
- compatibility gate and `sample_spectrogram_plot` normalize first, then use
  the true length; plot returns the styled "Not Available" figure for
  unusable/too-short (<32) samples.
- `_compute_spectrogram` measures length via reshape(-1) (belt-and-suspenders).

Tests: parametrized `_to_complex_1d` and `sample_spectrogram_plot` over
complex 1-D, (2, T) rows, (T, 2) cols, real 1-D, and (2, 4, 256) multi-channel
I/Q (all render), plus (2,)/empty (still "Not Available"). 16 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All checks were successful
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 1m5s
Build Project / Build Project (3.10) (pull_request) Successful in 3m3s
Build Project / Build Project (3.11) (pull_request) Successful in 2m27s
Build Project / Build Project (3.12) (pull_request) Successful in 1m20s
Test with tox / Test with tox (3.11) (pull_request) Successful in 2m57s
Test with tox / Test with tox (3.10) (pull_request) Successful in 4m3s
Test with tox / Test with tox (3.12) (pull_request) Successful in 1m27s
3d58760b5e
benchinnery requested review from gillian 2026-07-14 12:22:57 -04:00
G gillian approved these changes 2026-07-14 13:49:14 -04:00
benchinnery merged commit de03071c9b into main 2026-07-14 13:54:10 -04:00
benchinnery deleted branch fix-spectrogram-split-iq 2026-07-14 13:54:15 -04:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: qoherent/ria-toolkit-oss#36
No description provided.