pycbc.fft package

Submodules

pycbc.fft.backend_cpu module

pycbc.fft.backend_cpu.get_backend()[source]
pycbc.fft.backend_cpu.set_backend(backend_list)[source]

pycbc.fft.backend_cupy module

pycbc.fft.backend_cupy.get_backend()[source]
pycbc.fft.backend_cupy.set_backend(backend_list)[source]

pycbc.fft.backend_mkl module

pycbc.fft.backend_mkl.get_backend()[source]
pycbc.fft.backend_mkl.set_backend(backend_list)[source]

pycbc.fft.backend_support module

This package provides a front-end to various fast Fourier transform implementations within PyCBC.

pycbc.fft.backend_support.get_backend()[source]
pycbc.fft.backend_support.get_backend_modules()[source]
pycbc.fft.backend_support.get_backend_names()[source]
pycbc.fft.backend_support.set_backend(backend_list)[source]

pycbc.fft.class_api module

This package provides a front-end to various fast Fourier transform implementations within PyCBC.

class pycbc.fft.class_api.FFT(*args, **kwargs)[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.

  • by (The addresses in memory of both vectors should be divisible)

  • pycbc.PYCBC_ALIGNMENT.

class pycbc.fft.class_api.IFFT(*args, **kwargs)[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.

  • by (The addresses in memory of both vectors should be divisible)

  • pycbc.PYCBC_ALIGNMENT.

pycbc.fft.core module

This package provides a front-end to various fast Fourier transform implementations within PyCBC.

pycbc.fft.cupyfft module

This module provides the cupy backend of the fast Fourier transform for the PyCBC package.

class pycbc.fft.cupyfft.FFT(invec, outvec, nbatch=1, size=None)[source]

Bases: _BaseFFT

Class for performing FFTs via the cupy 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.cupyfft.IFFT(invec, outvec, nbatch=1, size=None)[source]

Bases: _BaseIFFT

Class for performing IFFTs via the cupy 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.cupyfft.fft(invec, outvec, _, itype, otype)[source]
pycbc.fft.cupyfft.ifft(invec, outvec, _, itype, otype)[source]

pycbc.fft.fft_callback module

pycbc.fft.fft_callback.c2c_correlate_ifft(htilde, stilde, outvec)[source]
pycbc.fft.fft_callback.c2c_half_correlate_ifft(htilde, stilde, outvec)[source]
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.fft_callback.get_fn_plan(callback=None, out_callback=None, name='pycbc_cufft', parameters=None)[source]

Get the IFFT execute and plan functions

class pycbc.fft.fft_callback.param[source]

Bases: Structure

htilde

Structure/Union member

class pycbc.fft.fft_callback.param2[source]

Bases: Structure

htilde

Structure/Union member

in_kmax

Structure/Union member

out_kmax

Structure/Union member

out_kmin

Structure/Union member

pycbc.fft.fftw module

class pycbc.fft.fftw.FFT(invec, outvec, nbatch=1, size=None)[source]

Bases: _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: _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.execute(plan, invec, outvec)[source]
pycbc.fft.fftw.export_double_wisdom_to_filename(filename)[source]
pycbc.fft.fftw.export_single_wisdom_to_filename(filename)[source]
pycbc.fft.fftw.fft(invec, outvec, prec, itype, otype)[source]
pycbc.fft.fftw.from_cli(opt)[source]
pycbc.fft.fftw.get_flag(mlvl, aligned)[source]
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.ifft(invec, outvec, prec, itype, otype)[source]
pycbc.fft.fftw.import_double_wisdom_from_filename(filename)[source]
pycbc.fft.fftw.import_single_wisdom_from_filename(filename)[source]
pycbc.fft.fftw.import_sys_wisdom()[source]
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.plan(size, idtype, odtype, direction, mlvl, aligned, nthreads, inplace)[source]
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.set_planning_limit(time)[source]
pycbc.fft.fftw.set_threads_backend(backend=None)[source]
pycbc.fft.fftw.verify_fft_options(opt, parser)[source]
Parses the FFT options and verifies that they are

reasonable.

Parameters:
  • opt (object) – Result of parsing the CLI with OptionParser, or any object with the required attributes.

  • parser (object) – OptionParser instance.

pycbc.fft.fftw.wisdom_io(filename, precision, action)[source]

Import or export an FFTW plan for single or double precision.

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 write-up.)

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 write-up.)

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:
  • invec (array) – The input array.

  • outvec (array) – The output array.

  • N1 (int) – Number of rows.

  • N2 (int) – Number of columns.

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:
  • N1 (int) – Number of rows.

  • N2 (int) – Number of columns.

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:
  • N1 (int) – Number of rows.

  • N2 (int) – Number of columns.

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 pre-transposed, 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 sample-rate 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:
  • invec – The result of the first phase FFT

  • indices (array of ints) – The index locations to calculate the FFT

  • N1 (int) – The length of the second phase “FFT”

  • N2 (int) – The length of the first phase FFT

Returns:

out

Return type:

array of floats

pycbc.fft.fftw_pruned.splay(vec)[source]

Determine two lengths to split stride the input vector by

pycbc.fft.fftw_pruned_cython module

pycbc.fft.fftw_pruned_cython.second_phase_cython(N1, N2, NI, indices, out, invec)

pycbc.fft.func_api module

This package provides a front-end 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:
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:

pycbc.fft.mkl module

class pycbc.fft.mkl.FFT(invec, outvec, nbatch=1, size=None)[source]

Bases: _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: _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.mkl.check_status(status)[source]

Check the status of a mkl functions and raise a python exeption if there is an error.

pycbc.fft.mkl.create_descriptor(size, idtype, odtype, inplace)[source]
pycbc.fft.mkl.fft(invec, outvec, prec, itype, otype)[source]
pycbc.fft.mkl.ifft(invec, outvec, prec, itype, otype)[source]

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: _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: _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.npfft.fft(invec, outvec, _, itype, otype)[source]
pycbc.fft.npfft.ifft(invec, outvec, _, itype, otype)[source]

pycbc.fft.parser_support module

This package provides a front-end 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

pycbc.fft.parser_support.verify_fft_options(opt, parser)[source]
Parses the FFT options and verifies that they are

reasonable.

Parameters:
  • opt (object) – Result of parsing the CLI with OptionParser, or any object with the required attributes.

  • parser (object) – OptionParser instance.

Module contents