Sub-Sample SNR Interpolation (ligo.skymap.bayestar.interpolation)

Sub-sample interpolation for matched filter time series.


from ligo.skymap.bayestar.interpolation import interpolate_max
from matplotlib import pyplot as plt
import numpy as np

z = np.asarray([ 9.135017 -2.8185585j,  9.995214 -1.1222992j,
                10.682851 +0.8188147j, 10.645139 +3.0268786j,
                 9.713133 +5.5589147j,  7.9043484+7.9039335j,
                 5.511646 +9.333084j ,  2.905198 +9.715742j ,
                 0.5302934+9.544538j ])

amp = np.abs(z)
arg = np.rad2deg(np.unwrap(np.angle(z)))
arg -= (np.median(arg) // 360) * 360
imax = np.argmax(amp)
window = 4

fig, (ax_amp, ax_arg) = plt.subplots(2, 1, figsize=(5, 6), sharex=True)
ax_arg.set_xlabel('Sample index')
args, kwargs = ('.-',), dict(color='lightgray', label='data')
ax_amp.plot(amp, *args, **kwargs)
ax_arg.plot(arg, *args, **kwargs)
for method in ['lanczos', 'catmull-rom',
               'quadratic-fit', 'nearest-neighbor']:
    i, y = interpolate_max(imax, z, window, method)
    amp = np.abs(y)
    arg = np.rad2deg(np.angle(y))
    args, kwargs = ('o',), dict(mfc='none', label=method)
    ax_amp.plot(i, amp, *args, **kwargs)
    ax_arg.plot(i, arg, *args, **kwargs)

(Source code, png, hires.png, pdf)

ligo.skymap.bayestar.interpolation.interpolate_max(imax, y, window_length, method='catmull-rom-amp-phase')[source] [edit on github]

Perform sub-sample interpolation to find the phase and amplitude at the maximum of the absolute value of a complex series.


The index of the maximum sample in the series.


The complex series.


The window of the interpolation function for the lanczos and quadratic-fit methods. The interpolation will consider a sliding window of 2 * window_length + 1 samples centered on imax.

method{‘catmull-rom-amp-phase’, ‘catmull-rom’, ‘lanczos’, ‘nearest-neighbor’, ‘quadratic-fit’}

The interpolation method. Can be any of the following:

  • catmull-rom-amp-phase: Catmull-Rom cubic splines on amplitude and phase The window_length parameter is ignored (understood to be 2).

  • catmull-rom: Catmull-Rom cubic splines on real and imaginary parts The window_length parameter is ignored (understood to be 2).

  • lanczos: Lanczos filter interpolation

  • nearest-neighbor: Nearest neighbor (e.g., no interpolation). The window_length parameter is ignored (understood to be 0).

  • quadratic-fit: Fit the absolute value of the SNR to a quadratic function and the phase to a linear function.


The interpolated index of the maximum sample, which should be between imax - 0.5 and imax + 0.5.


The interpolated value at the maximum.