-
Notifications
You must be signed in to change notification settings - Fork 348
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
Use more class-based FFTs in pycbc_live #4096
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9b51dc0
Use class-based API in StrainBuffer - PART 1
spxiwh f20bc27
Fixes to previous
spxiwh 710c541
FIx to previous
spxiwh 4ad5b0a
Attempt to move other block to strain API
spxiwh 08ea923
Add cache-based class-based FFTs in resample and strain
spxiwh 7a308b1
Pycbc live to use cached FFTs
spxiwh 328b96f
Some fixes to previous
spxiwh dd05619
CodeClimating
spxiwh 9442701
Some reordering as per discussion on PR
spxiwh 89942c3
Typo
spxiwh 07212b9
Various fixes
spxiwh aa5dc01
Remove additional complication that isn't needed
spxiwh 4a9a4e7
Significant rework of cached_FFT
spxiwh f51a797
Some clean up
spxiwh 7dec230
More cleanup
spxiwh bcb2abb
Code climating
spxiwh 5563186
Add UIDs as constants
spxiwh 7afad24
Copy output by default
spxiwh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Significant rework of cached_FFT
- Loading branch information
commit 4a9a4e790a9333a56be758c74668971d1dfa8c9e
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
import scipy.signal | ||
from pycbc.types import TimeSeries, Array, zeros, FrequencySeries, real_same_precision_as | ||
from pycbc.types import complex_same_precision_as | ||
from pycbc.fft import ifft, fft, create_memory_and_engine_for_class_based_fft | ||
from pycbc.fft import ifft, fft | ||
|
||
_resample_func = {numpy.dtype('float32'): lal.ResampleREAL4TimeSeries, | ||
numpy.dtype('float64'): lal.ResampleREAL8TimeSeries} | ||
|
@@ -72,6 +72,9 @@ def lfilter(coefficients, timeseries): | |
epoch=timeseries.start_time, | ||
delta_t=timeseries.delta_t) | ||
elif (len(timeseries) < fillen * 10) or (len(timeseries) < 2**18): | ||
from pycbc.strain.strain import create_memory_and_engine_for_class_based_fft | ||
from pycbc.strain.strain import execute_cached_fft, execute_cached_ifft | ||
|
||
cseries = (Array(coefficients[::-1] * 1)).astype(timeseries.dtype) | ||
cseries.resize(len(timeseries)) | ||
cseries.roll(len(timeseries) - fillen + 1) | ||
|
@@ -91,39 +94,27 @@ def lfilter(coefficients, timeseries): | |
|
||
else: | ||
npoints = len(cseries) | ||
if (npoints, ftype) not in fft_cache: | ||
fft1outs = create_memory_and_engine_for_class_based_fft( | ||
npoints, | ||
timeseries.dtype, | ||
ifft=False | ||
) | ||
|
||
fft2outs = create_memory_and_engine_for_class_based_fft( | ||
npoints, | ||
timeseries.dtype, | ||
ifft=False | ||
) | ||
|
||
ifftouts = create_memory_and_engine_for_class_based_fft( | ||
npoints, | ||
timeseries.dtype, | ||
ifft=True | ||
) | ||
|
||
fft_cache[(npoints, ftype)] = [fft1outs, fft2outs, ifftouts] | ||
|
||
fft1outs, fft2outs, ifftouts = fft_cache[(npoints, ftype)] | ||
vec, cfreq, fft_class = fft1outs | ||
vec._data[:] = cseries._data[:] | ||
fft_class.execute() | ||
|
||
vec, tfreq, fft_class = fft2outs | ||
vec._data[:] = timeseries._data[:] | ||
fft_class.execute() | ||
# NOTE: This function is cached! | ||
ifftouts = create_memory_and_engine_for_class_based_fft( | ||
npoints, | ||
timeseries.dtype, | ||
ifft=True, | ||
uid=486876761 | ||
) | ||
|
||
# FFT contents of cseries into cfreq | ||
cfreq = execute_cached_fft(cseries, uid=46464651, | ||
normalize_by_rate=False) | ||
|
||
# FFT contents of timeseries into tfreq | ||
tfreq = execute_cached_fft(timeseries, uid=91236752, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about magic number UID. |
||
normalize_by_rate=False) | ||
|
||
cout, out, fft_class = ifftouts | ||
|
||
# Correlate cfreq and tfreq | ||
correlate(cfreq, tfreq, cout) | ||
# IFFT correlation output into out | ||
fft_class.execute() | ||
|
||
return TimeSeries(out.numpy() / len(out), epoch=timeseries.start_time, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming that the number you select for the uid here is just so that it's different from anything else? If there's a reason it has this value (also below) then please add a code comment explaining what determines the value.
If it's just to be unique from other calls of the same function, would it be clearer to just define some constants in this file, like
LFILTER_UNIQUE_ID = 1
, or whatever?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Josh. This is just to give different outputs if called with the same inputs from different functions. The number just has to be unique. I made this a constant, with some inline comments, as suggested.