samuroi.event package

class samuroi.event.biexponential.BiExponentialParameters(tau1, tau2)[source]

Bases: object

amplitude
baseline
kernel(x=None)[source]

Create a kernel for the given parameters. x may be a numpy array to be used as support. tau1 is slow, tau2 is fast. i.e. tau1 >= tau2 If x is None, the support is chosen automatically such that the difference of the last value of the kernel and the baseline is less than 1%.

tau1
tau2
class samuroi.event.template_matching.ClementsBekkersResult(indices, crit, s, c, threshold, kernel)[source]

Bases: object

Collection of results of least squares optimization for template matching.

c = None

the vector of optimal offset parameters

crit = None

the criterion vector used for comparison with the threshold

indices = None

the indices of detected events, since zero padding is used for convolution, all indices need to get shifted by N/2 where N is the length of the kernel

kernel = None

the kernel that was used for matching

s = None

the vector of optimal scaling parameters

threshold = None

the threshold used for detection

samuroi.event.template_matching.template_matching(data, kernel, threshold)[source]

Note

Threshold values usually should be in the range 1 to 5 for reasonable results.

Input \(\mathbf{y}\) and \(\mathbf{e}\) are two vectors, the normalized(todo: what means normalized?) template that should be used for matching and the data vector. Some intermediate values are:

\(\overline{e} = \frac{1}{K}\sum_k e_k\)

\(\overline{y_n} = \frac{1}{K}\sum_k y_{n+k}\)

The goal is to minimize the least squares distance:

\(\chi_n^2(S,C)=\sum_K\left[y_{n+k} - (S e_k +C)\right]^2\)

W.r.t. the variables \(S\) and \(C\). According to (ClementsBekkers, Appendix I)[1] the result is:

\(S_n = \frac{\sum_k e_k y_{n+k}-1/K \sum_k e_k \sum_k y_{n+k}}{\sum e_k^2-1/K \sum_k e_k \sum_k e_k} = \frac{\sum_k e_k y_{n+k}-K\overline{e}\ \overline{y_n}}{\sum e_k^2-K\overline{e}^2}\)

and

\(C_n = \overline{y_n} -S_n \overline{e}\)

Parameters:
  • data – 1D numpy array with the timeseries to analyze, above denoted as \(\mathbf{y}\)
  • kernel – 1D numpy array with the template to use, above denoted as \(\mathbf{e}\)
  • threshold – scalar value usually between 4 to 5.
Returns:

A result object samuroi.event.template_matching.ClementsBekkersResult

[1] http://dx.doi.org/10.1016%2FS0006-3495(97)78062-7