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

Sub-sample interpolation for matched filter time series.

Example

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')
ax_amp.set_ylabel('Amplitude')
ax_arg.set_ylabel('Phase')
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)
ax_arg.legend()
fig.tight_layout()

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

../../../_images/interpolation-1.png
ligo.skymap.bayestar.interpolation.interpolate_max(imax, y, window_length, method='catmull-rom')[source]

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

Parameters
imaxint

The index of the maximum sample in the series.

ynumpy.ndarray

The complex series.

window_lengthint

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’, ‘lanczos’, ‘nearest-neighbor’, ‘quadratic-fit’}

The interpolation method. Can be any of the following:

  • catmull-rom: Catmull-Rom cubic splines 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.

Returns
imax_interpfloat

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

ymax_interpcomplex

The interpolated value at the maximum.