pycbc.fft package¶
Submodules¶
pycbc.fft.backend_cpu module¶
pycbc.fft.backend_mkl module¶
pycbc.fft.backend_support module¶
This package provides a frontend to various fast Fourier transform implementations within PyCBC.
pycbc.fft.class_api module¶
This package provides a frontend to various fast Fourier transform implementations within PyCBC.

class
pycbc.fft.class_api.
FFT
[source]¶ Bases:
object
Create a forward FFT engine
Parameters:  invec (complex64 or float32) – Input pycbc.types.Array (or subclass); its FFT will be computed
 outvec (complex64) – Output pycbc.types.Array (or subclass); it will hold the FFT of invec
 nbatch (int (default 1)) – When not one, specifies that invec and outvec should each be interpreted as nbatch distinct vectors. The total length of invec and outvec should then be that appropriate to a single vector, multiplied by nbatch
 size (int (default None)) – When nbatch is not 1, this parameter gives the logical size of each transform. If nbatch is 1 (the default) this can be None, and the logical size is the length of invec.
 addresses in memory of both vectors should be divisible by (The) –
 pycbc.PYCBC_ALIGNMENT. –

class
pycbc.fft.class_api.
IFFT
[source]¶ Bases:
object
Create a reverse FFT engine
Parameters:  invec (complex64) – Input pycbc.types.Array (or subclass); its IFFT will be computed
 outvec (complex64 or float32) – Output pycbc.types.Array (or subclass); it will hold the IFFT of invec
 nbatch (int (default 1)) – When not one, specifies that invec and outvec should each be interpreted as nbatch distinct vectors. The total length of invec and outvec should then be that appropriate to a single vector, multiplied by nbatch
 size (int (default None)) – When nbatch is not 1, this parameter gives the logical size of each transform. If nbatch is 1 (the default) this can be None, and the logical size is the length of outvec.
 addresses in memory of both vectors should be divisible by (The) –
 pycbc.PYCBC_ALIGNMENT. –
pycbc.fft.core module¶
This package provides a frontend to various fast Fourier transform implementations within PyCBC.
pycbc.fft.fft_callback module¶

pycbc.fft.fft_callback.
compile
(source, name)[source]¶ Compile the string source code into a shared object linked against the static version of cufft for callback support.
pycbc.fft.fftw module¶

class
pycbc.fft.fftw.
FFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseFFT

execute
()[source]¶ Compute the (forward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).


class
pycbc.fft.fftw.
IFFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseIFFT

execute
()[source]¶ Compute the (backward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).


pycbc.fft.fftw.
get_measure_level
()[source]¶ Get the current ‘measure level’ used in deciding how much effort to put into creating FFTW plans. From least effort (and shortest planning time) to most they are 0 to 3. No arguments.

pycbc.fft.fftw.
insert_fft_options
(optgroup)[source]¶ Inserts the options that affect the behavior of this backend
Parameters: optgroup (fft_option) – OptionParser argument group whose options are extended

pycbc.fft.fftw.
set_measure_level
(mlvl)[source]¶ Set the current ‘measure level’ used in deciding how much effort to expend creating FFTW plans. Must be an integer from 0 (least effort, shortest time) to 3 (most effort and time).
pycbc.fft.fftw_pruned module¶
This module provides a functions to perform a pruned FFT based on FFTW
This should be considered a test and example module, as the functionality can and should be generalized to other FFT backends, and precisions.
These functions largely implemented the generic FFT decomposition as described rather nicely by wikipedia.
http://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm
I use a similar naming convention here, with minor simplifications to the twiddle factors.

pycbc.fft.fftw_pruned.
fft_transpose
(vec)¶ Perform an FFT transpose from vec into outvec. (Alex to provide more details in a writeup.)
Parameters: vec (array) – Input array. Returns: outvec – Transposed output array. Return type: array

pycbc.fft.fftw_pruned.
fft_transpose_fftw
(vec)[source]¶ Perform an FFT transpose from vec into outvec. (Alex to provide more details in a writeup.)
Parameters: vec (array) – Input array. Returns: outvec – Transposed output array. Return type: array

pycbc.fft.fftw_pruned.
first_phase
(invec, outvec, N1, N2)[source]¶ This implements the first phase of the FFT decomposition, using the standard FFT many plans.
Parameters:

pycbc.fft.fftw_pruned.
plan_first_phase
(N1, N2)[source]¶ Create a plan for the first stage of the pruned FFT operation. (Alex to provide a write up with more details.)
Parameters: Returns: plan – The plan for performing the first phase FFT.
Return type: FFTWF plan

pycbc.fft.fftw_pruned.
plan_transpose
(N1, N2)[source]¶ Create a plan for transposing internally to the pruned_FFT calculation. (Alex to provide a write up with more details.)
Parameters: Returns: plan – The plan for performing the FFTW transpose.
Return type: FFTWF plan

pycbc.fft.fftw_pruned.
pruned_c2cifft
(invec, outvec, indices, pretransposed=False)[source]¶ Perform a pruned iFFT, only valid for power of 2 iffts as the decomposition is easier to choose. This is not a strict requirement of the functions, but it is unlikely to the optimal to use anything but power of 2. (Alex to provide more details in write up.
Parameters:  invec (array) – The input vector. This should be the correlation between the data and the template at full sample rate. Ideally this is pretransposed, but if not this will be transposed in this function.
 outvec (array) – The output of the first phase of the pruned FFT.
 indices (array of ints) – The indexes at which to calculate the full samplerate SNR.
 pretransposed (boolean, default=False) – Used to indicate whether or not invec is pretransposed.
Returns: SNRs – The complex SNRs at the indexes given by indices.
Return type: array

pycbc.fft.fftw_pruned.
second_phase
(invec, indices, N1, N2)[source]¶ This is the second phase of the FFT decomposition that actually performs the pruning. It is an explicit calculation for the subset of points. Note that there seem to be some numerical accumulation issues at various values of N1 and N2.
Parameters: Returns: out
Return type: array of floats
pycbc.fft.func_api module¶
This package provides a frontend to various fast Fourier transform implementations within PyCBC.

pycbc.fft.func_api.
fft
(invec, outvec)[source]¶ Fourier transform from invec to outvec.
Perform a fourier transform. The type of transform is determined by the dtype of invec and outvec.
Parameters:  invec (TimeSeries or FrequencySeries) – The input vector.
 outvec (TimeSeries or FrequencySeries) – The output.

pycbc.fft.func_api.
ifft
(invec, outvec)[source]¶ Inverse fourier transform from invec to outvec.
Perform an inverse fourier transform. The type of transform is determined by the dtype of invec and outvec.
Parameters:  invec (TimeSeries or FrequencySeries) – The input vector.
 outvec (TimeSeries or FrequencySeries) – The output.
pycbc.fft.mkl module¶

class
pycbc.fft.mkl.
FFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseFFT

execute
()[source]¶ Compute the (forward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).


class
pycbc.fft.mkl.
IFFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseIFFT

execute
()[source]¶ Compute the (backward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).

pycbc.fft.npfft module¶
This module provides the numpy backend of the fast Fourier transform for the PyCBC package.

class
pycbc.fft.npfft.
FFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseFFT
Class for performing FFTs via the numpy interface.

execute
()[source]¶ Compute the (forward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).


class
pycbc.fft.npfft.
IFFT
(invec, outvec, nbatch=1, size=None)[source]¶ Bases:
pycbc.fft.core._BaseIFFT
Class for performing IFFTs via the numpy interface.

execute
()[source]¶ Compute the (backward) FFT of the input vector specified at object instantiation, putting the output into the output vector specified at objet instantiation. The intention is that this method should be called many times, with the contents of the input vector changing between invocations, but not the locations in memory or length of either input or output vector.
Unlike the function based API, the class based API does NOT rescale its output by the input vector’s delta_t (when input is a TimeSeries) or delta_f (when input is a FrequencySeries).

pycbc.fft.parser_support module¶
This package provides a frontend to various fast Fourier transform implementations within PyCBC.

pycbc.fft.parser_support.
from_cli
(opt)[source]¶ Parses the command line options and sets the FFT backend for each (available) scheme. Aside from setting the default backed for this context, this function will also call (if it exists) the from_cli function of the specified backends in the current scheme; typically one would only call this function once inside of a scheme context manager, but if it is desired to perform FFTs both inside and outside of a context, then this function would need to be called again.
Parameters:  opt (object) – Result of parsing the CLI with OptionParser, or any object with the required attributes.
 Returns –

pycbc.fft.parser_support.
insert_fft_option_group
(parser)[source]¶ Adds the options used to choose an FFT backend. This should be used if your program supports the ability to select the FFT backend; otherwise you may simply call the fft and ifft functions and rely on default choices. This function will also attempt to add any options exported by available backends through a function called insert_fft_options. These submodule functions should take the fft_group object as argument.
Parameters: parser (object) – OptionParser instance