kernels module

class kernels.PSDFirKernel[source]

Bases: object

linear_phase_fir_kernel_to_minimum_phase_whitening_fir_kernel(linear_phase_kernel: ndarray, sample_rate: int) Tuple[ndarray, ndarray][source]

Compute the minimum-phase response filter (zero latency) associated with a linear-phase response filter (latency equal to half the filter length).

From “Design of Optimal Minimum-Phase Digital FIR Filters Using Discrete Hilbert Transforms”, IEEE Trans. Signal Processing, vol. 48, pp. 1491-1495, May 2000.

Args:
linear_phase_kernel:

numpy.ndarray, the kernel to compute the minimum-phase kernel with

sample_rate:

int, the sample rate

Returns:

Tuple[numpy.ndarray. numpy.ndarray], the kernel and the phase response. The kernel is a numpy array containing the filter kernel. The kernel can be used, for example, with gstreamer’s stock audiofirfilter element.

psd_to_linear_phase_whitening_fir_kernel(psd: REAL8FrequencySeries, invert: Optional[bool] = True, nyquist: Optional[float] = None) Tuple[ndarray, int, int][source]

Compute an acausal finite impulse-response filter kernel from a power spectral density conforming to the LAL normalization convention, such that if colored Gaussian random noise with the given PSD is fed into an FIR filter using the kernel the filter’s output will be zero-mean unit-variance Gaussian random noise. The PSD must be provided as a lal.REAL8FrequencySeries object.

The phase response of this filter is 0, just like whitening done in the frequency domain.

Args:
psd:

lal.REAL8FrequencySeries, the reference PSD

invert:

bool, default true, whether to invert the kernel

nyquist:

float, disabled by default, whether to change the Nyquist frequency.

Returns:

Tuple[numpy.ndarray, int, int], the kernel, latency, sample rate pair. The kernel is a numpy array containing the filter kernel, the latency is the filter latency in samples and the sample rate is in Hz. The kernel and latency can be used, for example, with gstreamer’s stock audiofirfilter element.

set_phase(psd: REAL8FrequencySeries, f_low: float = 10.0, m1: float = 1.4, m2: float = 1.4) None[source]

Compute the phase response of zero-latency whitening filter given a reference PSD.

kernels.fir_whitener_kernel(length: int, duration: float, sample_rate: int, psd: REAL8FrequencySeries) COMPLEX16FrequencySeries[source]

Create an FIR whitener kernel.

kernels.fixed_duration_bandpass_kernel(rate: int, flow: float = 0, fhigh: float = inf, duration: float = 1.0) ndarray[source]

Create a fixed-duration band-pass kernel.

Args:
rate (Hz):

int, the sampling rate

flow (Hz):

float, default 0, the low frequency of the pass band

fhigh (Hz):

float, default +inf, the high frequency of the pass band

duration (s):

float, default 1.0, the duration of the kernel

Returns:

numpy.ndarray, the band-passed kernel

kernels.one_second_highpass_kernel(rate: int, cutoff: int = 12) ndarray[source]

Create a one second high-pass kernel.

Args:
rate (Hz):

int, the sampling rate

cutoff (Hz):

int, the high-pass cutoff

Returns:

numpy.ndarray, the high-passed kernel