tune_blinks_kalman#
- pypillometry.signal.tune_blinks_kalman(train, fs, window, test=None, refine=None, start=None, bounds=None, n_grid=6, n_fine=5)[source]#
Tune the margins of the Kalman interpolation on transplanted blinks.
The Kalman interpolation (see
interpolate_blinks_kalman()) has no parameters for finding the transients around a blink: it replaces the core of the blink and a margin before and after it. The margins are searched on a grid of n_grid x n_grid values within bounds (on the blinks in train), and then on a finer grid of n_fine x n_fine values around the best one (on the blinks in train and refine). The error changes smoothly with the margins, so the grid suffices. If test is given, the tuned margins are only used if they are better on those blinks than the starting margins.- Parameters:
train (BlinkTransplant or list of BlinkTransplant) – signal(s) with transplanted blinks (see
transplant_blinks()); a list of lists is flattenedfs (float) – sampling rate (Hz)
window (int) – samples before and after each blink that the Kalman smoother uses
test (BlinkTransplant or list of BlinkTransplant, optional) – further transplanted blinks to check the result and for the fine grid
refine (BlinkTransplant or list of BlinkTransplant, optional) – further transplanted blinks to check the result and for the fine grid
start (tuple of int, optional) – starting margins (before, after) (samples); default: the middle of bounds
bounds (tuple of tuple, optional) – search ranges ((lo, hi), (lo, hi)) of the margins before and after the core (samples); default: from 0 to the window of the transplanted blinks on each side
n_grid (int) – number of values per margin on the coarse and the fine grid
n_fine (int) – number of values per margin on the coarse and the fine grid
- Return type:
- Returns:
result.paramsare{"margin": (before, after)}(samples); the history has"margin_before","margin_after","loss"and"stage"(1: coarse grid, 2: fine grid)