Degradation Correction

Exposure

tsipy.correction.compute_exposure(x, method='num_measurements', x_mean=1.0)

Computes exposure of a given signal.

In literature, exposure is found under an alias exposure time. If num_measurements method is selected, then the exposure equals to the number of measurements up to time t. If exposure_sum method is selected, then the exposure equals to the cumulative sum of measurement values up to time t. Works only for measurements with positive values. x_mean normalizes values before cumulative sum.

Examples:
>>> import numpy as np
>>> x = np.array([1.0, np.nan, 3.0, 4.0, 5.0])
>>> compute_exposure(x, method="num_measurements")
array([1., 1., 2., 3., 4.])
>>> compute_exposure(x, method="exposure_sum")
array([ 1.,  1.,  4.,  8., 13.])
Return type

ndarray

Algorithms

class tsipy.correction.History(iteration, a, b, ratio)

History(iteration, a, b, ratio)A namedtuple representing step at aparticular step of degradation correction.

a

Corrected signal a at iteration.

b

Corrected signal b at iteration.

iteration

Iteration of degradation correction algorithm.

ratio

Ratio between a and ˙˙b˙˙ at iteration iteration.

tsipy.correction.correct_both(t_m, a_m, e_a_m, b_m, e_b_m, model, verbose=False, eps=1e-06, max_iter=100)

Executes degradation correction algorithm CorrectBoth.

The algorithm is described in Kolar et al. [1].

It is shown that corrected signals converge to the ground truth in the absence of measurement noise.

Returns:

Corrected signals a and b, degradation model d_c(.) and correction history.

Return type

Tuple[ndarray, ndarray, DegradationModel, List[History]]

tsipy.correction.correct_degradation(t_m, a_m, e_a_m, b_m, e_b_m, model, method='correct_one', verbose=False, eps=1e-06, max_iter=100)

Selects and executes a correction algorithm.

This is a wrapper function for correct_one() and correct_both().

Return type

Tuple[ndarray, ndarray, DegradationModel, List[History]]

tsipy.correction.correct_one(t_m, a_m, e_a_m, b_m, e_b_m, model, verbose=False, eps=1e-06, max_iter=100)

Executes degradation correction algorithm CorrectOne.

The algorithm is described in Kolar et al. [1].

It is shown that corrected signals converge to the ground truth in the absence of measurement noise.

Returns:

Corrected signals a and b, degradation model d_c(.) and correction history.

Return type

Tuple[ndarray, ndarray, DegradationModel, List[History]]

Degradation Models

class tsipy.correction.DegradationModel

Abstract class for degradation model, that learns the degradation function.

It must implement two methods ˙__call__() for inference and fit() for training.

For each degradation model, it must hold

\[f(0, \theta) = 1.\]
abstract fit(x_a, ratio)

Learns a mapping from exposure to signal ratio..

Return type

None

initial_fit(x_a, y_a, y_b)

Obtains an initial approximation for the model.

Return type

None

class tsipy.correction.ExpLinModel

Degradation model with prediction function in exponential form.

Exact equation is:

\[f(x, \theta) = 1 - e^{\theta_1 \cdot \theta_2} + \theta_3 \cdot x.\]
fit(x_a, ratio)

Learns a mapping from exposure to signal ratio..

Return type

None

initial_fit(x_a, y_a, y_b)

Obtains an initial approximation for the model.

Return type

None

class tsipy.correction.ExpModel

Degradation model with prediction function in exponential form.

Exact equation is:

\[f(x, \theta) = 1 - e^{\theta_1 \cdot \theta_2}.\]
fit(x_a, ratio)

Learns a mapping from exposure to signal ratio..

Return type

None

initial_fit(x_a, y_a, y_b)

Obtains an initial approximation for the model.

Return type

None

class tsipy.correction.MRModel(y_max=1.0, y_min=0.0, out_of_bounds='clip')
fit(x_a, ratio)

Learns a mapping from exposure to signal ratio..

Return type

None

class tsipy.correction.SmoothMRModel(y_max=1.0, y_min=0.0, out_of_bounds='clip', n_pts=999, lam=10.0, solver='quadprog', convex=False)
fit(x_a, ratio)

Learns a mapping from exposure to signal ratio..

Return type

None

tsipy.correction.load_model(model)

Loads a degradation model given the model name.

Currently, the following models are implemented
  • exponential exp,

  • exponential with linear term explin,

  • monotonic regression mr, and

  • smooth monotonic regression smr.

Args:

model: String abbreviation of the model name.

Return type

DegradationModel

Signal Generator

class tsipy.correction.SignalGenerator(length=100000, y_center=10.0, add_degradation=True, add_noise=True, downsampling_rates=(0.9, 0.2), noise_stds=(0.025, 0.015), exposure_method='num_measurements', random_seed=0)

Class for generating sample signals.

property data: pandas.core.frame.DataFrame

Two.

Return type

DataFrame

References

1(1,2)

Luka Kolar, Rok Šikonja, and Lenart Treven. Iterative correction of sensor degradation and a bayesian multi-sensor data fusion method. 2020. arXiv:2009.03091.