Skip to content

Refactor delay calculation#7

Merged
osherlock1 merged 14 commits into
masterfrom
add-functional-tests
Mar 31, 2026
Merged

Refactor delay calculation#7
osherlock1 merged 14 commits into
masterfrom
add-functional-tests

Conversation

@osherlock1
Copy link
Copy Markdown
Owner

@osherlock1 osherlock1 commented Mar 31, 2026

Summary

Refactored the code handling the matched filter delay calculation and interpolation for sub-sample delay. Additionally. developed tests for the delay calculations.

  • Moved upsample(), scale_rx_signal(), calculate_sub_sample_delay_parabolic(), and calculate_sub_sample_delay_zp() from script-level definitions into src/ofdm/channel/delay.py
  • calc_delay.py is now pure orchestration file I/O, argparse, and calling package functions
  • Added conftest.py with shared session-scoped fixtures to eliminate repeated setup across test files
  • Added test classes for all new delay functions including sub-sample accuracy tests

What changed

src/ofdm/channel/delay.py

  • Added upsample() FFT-based signal upsampling
  • Added scale_rx_signal() normalizes signal amplitude to 0.9 max
  • Added calculate_sub_sample_delay_parabolic() sub-sample delay via parabolic interpolation
  • Added calculate_sub_sample_delay_zp() sub-sample delay via zero-padded FFT interpolation
  • Added _correlate() internal helper shared by both delay estimators

scripts/delay/calc_delay.py

  • Removed all DSP function definitions, now imports them from the package
  • Fixed bug: double .append() call in the else branch of main()
  • Fixed argparse ordering parse_args() now called before loading config files

tests/conftest.py

  • Added shared fixtures: cfg, active_bins, pilot_vals, pilot_symbol_freq, data_symbol_freq, pilot_symbol_time, data_symbol_time, generator

tests/test_delay.py

  • Added TestUpsample, TestScaleRxSignal, TestCalculateSubSampleDelayParabolic, TestCalculateSubSampleDelayZP
  • Tests cover output shape, known integer delay recovery, sub-sample delay accuracy, and edge cases
  • Bug caught by tests: scale_rx_signal() raised UnboundLocalError on zero input fixed

osherlock1 and others added 14 commits March 30, 2026 17:49
The function would check if the max value was greater than 0 and if it was then it would scale the input array and return if.  If the input is all zeros, the scaled array would never be created but it would still try to return it.  Changed to if the input is all zeros it just returns the input
This is the current way that the data needs to be unpacked when using the parabolic interpolation delay calculation method.
@osherlock1 osherlock1 merged commit 74e64da into master Mar 31, 2026
1 check passed
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.

1 participant