Skip to content

feat: add phi_hat delay tracking to BasebandReplayChannel#85

Open
Yugam2508 wants to merge 7 commits into
org-arl:masterfrom
Yugam2508:replay-delay-tracking
Open

feat: add phi_hat delay tracking to BasebandReplayChannel#85
Yugam2508 wants to merge 7 commits into
org-arl:masterfrom
Yugam2508:replay-delay-tracking

Conversation

@Yugam2508

@Yugam2508 Yugam2508 commented Jun 20, 2026

Copy link
Copy Markdown

What this does

Brings the Julia BasebandReplayChannel to parity with the MATLAB/Python
reference implementations in the uwa-channels
project, so it works with current channel-library files.

Changes

  • Delay tracking (phi_hat). Implements the previously-stubbed
    (# TODO: apply drift) delay-tracking mode: re-inserts both the phase
    (via cis.(φ)) and the delay drift (Δτ = φ / 2πfc, applied by
    re-interpolating on a time-shifted grid), matching the reference.
  • File reader. Loads phi_hat, theta_hat, or neither (pure
    convolution), plus the optional f_resamp passband factor, per the
    UACR file-format spec.
    Previously theta_hat was mandatory.
  • Phase-index fix. Corrects a pre-existing one-step offset in the
    phase-vector indexing (start * step(start-1) * step + 1) that
    affected both phi_hat and theta_hat modes.
  • Precision. Promotes the phase fields and fc to Float64 (delay-grid
    and long-signal carrier accuracy) while keeping h as ComplexF32 to
    preserve the memory characteristics for large channels.
  • Tests. Adds test/test_replay.jl (physics, zero-phase identity,
    constant-phase recovery), resolving the open # TODO: add test cases.

Validation

  • New tests pass; full suite green (511/511).
  • Cross-validated against the Python reference on a real delay-tracking
    channel (black.mat): per-receiver correlation 0.9997, lag 0,
    power ratio 1.0 across all 8 receivers.

Implementation note: interpolation differences

This is a port to Julia-native primitives, not a line-by-line translation, so
it is not expected to be bit-identical to the Python reference. Two sites use
different (but equivalent-in-the-interior) interpolation:

  • IR over time: the reference interpolates the impulse response across the
    time axis with scipy CubicSpline; this PR uses DSP.resample (polyphase
    FIR), consistent with how transmit already resamples the baseband signal.
  • Delay drift: the reference re-interpolates the drifted output with scipy
    CubicSpline (not-a-knot boundaries); this PR uses
    Interpolations.BSpline(Cubic(Line())) with linear extrapolation outside
    the grid.

Both schemes are cubic and agree in the signal interior, differing most at the
edges due to the different boundary conditions. This is what accounts for the
residual in the cross-validation (0.9997 rather than 1.0): the two
implementations agree on the physics and diverge only at the level of numerical
interpolation, not algorithm. If bit-level parity with the reference is
preferred, the drift interpolation can be switched to a not-a-knot cubic to
match — happy to do so on request.

Notes

  • Commit scope is pm (channel models are closely related to
    data-driven propagation models).
  • UACR noise-model support remains out of scope here and is still
    marked # TODO: support UACR noise models. Will work on it next.

mchitre and others added 4 commits May 11, 2026 14:45
Implement delay-tracking (phi_hat) replay matching the MATLAB/Python reference implementations: re-insert phase and delay drift via time-shifted interpolation. Update the file reader to accept phi_hat, theta_hat, or neither, plus the optional f_resamp factor, per the UACR file-format spec.

Fix a pre-existing one-step offset in the phase-vector indexing that affected both phi_hat and theta_hat modes. Promote phase fields and fc to Float64 for delay-grid precision while keeping h as ComplexF32 for memory. Add test cases (physics, zero-phase identity, constant-phase recovery), resolving the open TODO.

Validated against the Python reference on a real channel (black.mat): per-receiver correlation 0.9997, lag 0, power ratio 1.0.
@mchitre mchitre self-requested a review June 22, 2026 17:05
@mchitre

mchitre commented Jun 22, 2026

Copy link
Copy Markdown
Member

@Yugam2508 there seem to be a merge conflict. Would you like to resolve it before I review?

@Yugam2508

Copy link
Copy Markdown
Author

@Yugam2508 there seem to be a merge conflict. Would you like to resolve it before I review?

Apologies, resolved.

@mchitre

mchitre commented Jun 23, 2026

Copy link
Copy Markdown
Member

Scope can be pm. Channel models are closely related to data-driven propagation models.

Comment thread test/test_replay.jl
Comment thread test/test_replay.jl
Comment thread test/test_replay.jl
Comment thread test/test_replay.jl
@@ -0,0 +1,86 @@
using TestItems

@testsnippet ReplaySetup begin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test that checks the whole replayed impulse response against a Python version (can be a stored version so we don't have to call Python)? We need to cover various cases with phi, theta, etc, so we may need more than one channels in the tests?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working on this, will update it soon.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds full phi_hat (delay-tracking) support and updated UACR .mat parsing to BasebandReplayChannel, bringing the Julia replay channel in line with the referenced channel-library formats and behavior.

Changes:

  • Implement phi_hat phase reinsertion + delay-drift (time-grid) re-interpolation in transmit, plus f_resamp passband resampling support.
  • Update .mat loader to accept phi_hat, theta_hat, or neither (pure convolution), and validate phase/IR duration.
  • Add replay-focused tests and include SignalAnalysis as a test dependency; ignore large channel/noise data artifacts via .gitignore.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/replay.jl Implements phi_hat drift handling, updates file loading logic, adds f_resamp, and adjusts phase indexing.
test/test_replay.jl Adds physics/identity/constant-phase replay tests for the updated replay channel behavior.
test/Project.toml Adds SignalAnalysis dependency needed by the new replay tests.
.gitignore Ignores large binary channel/noise data files (*.mat, *.bin).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/replay.jl
Comment thread src/replay.jl
Comment thread src/replay.jl
Comment thread src/replay.jl Outdated
Comment thread test/test_replay.jl
Yugam2508 and others added 2 commits June 23, 2026 14:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Apply Copilot review suggestions to BasebandReplayChannel:
- guard power normalisation against divide-by-zero on all-zero output
- use a view in the drift interpolation to avoid a per-receiver copy
- represent an absent theta_hat as a 0x0 matrix, consistent with phi_hat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants