Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new, general purpose convolution function #802

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Conversation

tskisner
Copy link
Member

@tskisner tskisner commented Dec 5, 2024

In several places throughout the code we perform Fourier domain convolution and use a variety of techniques. This work aims to have a common function for some of these use cases which carefully handles the symmetric extension of data in the Fourier domain buffer and is unit tested. Changes include:

  • New toast.fft.convolve function that can take precomputed kernels or use a callback function to generate the kernels. Unit tests verify roundtrip and expected sample phase shift introduced by a Butterworth filter.

  • Porting of the timeconstant deconvolution operator to this new function.

  • Small unrelated fix to toast timing plots

  • Unrelated fixes to DetectorData indexing. In a couple places we were triggering data copying by using numpy "advanced indexing".

In several places throughout the code we perform Fourier domain convolution
and use a variety of techniques.  This work aims to have a common function
for some of these use cases which carefully handles the symmetric extension
of data in the Fourier domain buffer and is unit tested.  Changes include:

- New toast.fft.convolve function that can take precomputed kernels or
  use a callback function to generate the kernels.  Unit tests that
  verify roundtrip and expected sample phase shift introduced by a
  Butterworth filter.

- Porting of the timeconstant deconvolution operator to this new function.

- Small unrelated fix to toast timing plots

- Unrelated fixes to DetectorData indexing.  In a couple places we were
  triggering data copying by using numpy "advanced indexing".
@tskisner tskisner requested a review from keskitalo December 5, 2024 20:37
@tskisner
Copy link
Member Author

tskisner commented Dec 5, 2024

Some diagnostic plots from the unit tests:

Input fake data with 2 sine waves:
conv_common_in_0-500 pdf
After applying a butterworth low-pass using both numpy and toast internal fft:
conv_common_compare_output_0-500 pdf
Difference between those two code paths:
conv_common_compare_diff_0-500 pdf
Comparison with the input low-frequency sine wave after phase shifting by the expected amount considering the filter kernel:
conv_common_compare_shifted_0-500 pdf

Copy link
Member

@keskitalo keskitalo left a comment

Choose a reason for hiding this comment

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

Looks great!

src/toast/fft.py Show resolved Hide resolved
src/toast/fft.py Show resolved Hide resolved
src/toast/fft.py Show resolved Hide resolved
src/toast/ops/time_constant.py Show resolved Hide resolved
@tskisner tskisner merged commit 5eabddc into toast3 Dec 12, 2024
7 checks passed
@tskisner tskisner deleted the det_filter branch December 12, 2024 20:26
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.

2 participants