detectTimeShift

time TPT.detectTimeShift(timed_float a, timed_float b, [float min], [float max])

When working with signal that have been recorded in different temporal contexts (i.e. data acquired from a TPT test execution vs. data acquired from external measurement equipment and imported to the assessment using TPT.readRecord() or the "Import Measurement Assesslet"), this function computes the temporal correlation between the two signals a(t) and b(t).

Note that the detection of the time shift is based on the cross correlation function and is not suitable for all kind of signals: The algorithm used for this function is straight forward and best suited for non-periodic signals though it may also work with periodic signals when the original time shift between those signals is less than half the length of a period.

You can call "TPT.detectTimeShift(...)" in time contexts. The "time offset" value will be constant in this case for all samples.

The result of this function is typically used in conjunction with the signal.shift() function in order to shift the signal b into the temporal context of a.

Parameters:

a first time dependent float expression from one temporal context to determine the time shift

b second time dependent float expression from another temporal context to determine the time shift

[min] (optional) minimum value for shift that will be accepted. If None is specified there is no limitation.

[max] (optional) maximum value for shift that will be accepted. If None is specified there is no limitation.

Returns:

time offset/difference between both signals

Examples:

   # assume signal a was defined and is already available
   myrecord = TPT.readRecord("measurement.mdf");
   b = myrecord.getVariable("b"); # obtain var "b" from file content
   
   # detect time shift between a and b and shift b into the context of a
   offset = TPT.detectTimeShift(a,b);
   b.shift(offset);