pyacs.gts.lib.step_detect module
Thomas Kahn thomas.b.kahn@gmail.com
- pyacs.gts.lib.step_detect.find_steps(array, threshold)[source]
Finds local maxima by segmenting array based on positions at which the threshold value is crossed. Note that this thresholding is applied after the absolute value of the array is taken. Thus, the distinction between upward and downward steps is lost. However, get_step_sizes can be used to determine directionality after the fact. :param array: 1 dimensional array that represents time series of data points :type array: numpy array :param threshold: Threshold value that defines a step :type threshold: int / float
- Returns:
steps – List of indices of the detected steps
- Return type:
list
- pyacs.gts.lib.step_detect.get_step_sizes(array, indices, window=1000)[source]
Calculates step size for each index within the supplied list. Step size is determined by averaging over a range of points (specified by the window parameter) before and after the index of step occurrence. The directionality of the step is reflected by the sign of the step size (i.e. a positive value indicates an upward step, and a negative value indicates a downward step). The combined standard deviation of both measurements (as a measure of uncertainty in step calculation) is also provided.
- Parameters:
array (numpy array) – 1 dimensional array that represents time series of data points
indices (list) – List of indices of the detected steps (as provided by find_steps, for example)
window (int, optional) – Number of points to average over to determine baseline levels before and after step.
- Returns:
step_sizes (list) – List of the calculated sizes of each step
step_error (list)
- pyacs.gts.lib.step_detect.mz_fwt(x, n=2)[source]
Computes the multiscale product of the Mallat-Zhong discrete forward wavelet transform up to and including scale n for the input data x. If n is even, the spikes in the signal will be positive. If n is odd the spikes will match the polarity of the step (positive for steps up, negative for steps down). This function is essentially a direct translation of the MATLAB code provided by Sadler and Swami in section A.4 of the following: http://www.dtic.mil/dtic/tr/fulltext/u2/a351960.pdf :param x: 1 dimensional array that represents time series of data points :type x: numpy array :param n: Highest scale to multiply to :type n: int
- Returns:
prod – The multiscale product for x
- Return type:
numpy array
- pyacs.gts.lib.step_detect.t_scan(L, window=1000.0, num_workers=-1)[source]
Compute t statistic for sliding windows along a 1D time series.
For each index i, compares the segment [i, i+window) with [i-window, i) using a t statistic. Uses multiple processes; the array is decomposed into frames (points spaced at window intervals) so mean and variance are computed once per segment.
- Parameters:
L (array_like, shape (n,)) – One-dimensional time series of data points.
window (int or float, optional) – Number of points in each half-window. Default 1000.
num_workers (int, optional) – Number of worker processes for parallel computation. If -1, uses
cpu_count() - 1. Default -1.
- Returns:
t_stat – t statistic at each point. The first and last
windowpoints are zero (calculation not defined there).- Return type:
ndarray, shape (n,)