Shift traces

From Elsys Wiki - Help and Recources for TranAX and TraNET DAQ
Jump to: navigation, search

In some cases it is useful to have the possibility to shift multiple traces in the X-axis (time). E.g. sliced traces from continuous recordings or not synchronised traces from multiple devices.

Shift multiple traces in a file

In this example, the *.tpc5 file has be set to Reference 1 (ref1) in the Signal Source Browser. Cursor A marks the current position of the trace (event, spike) and will be shifted to position of cursor B.

Formula Editor code snippet

; Shift all traces from a file
; 12.10.2017 Elsys AG / TBE 
; TranAX 4.0 or newer

UseMemory(True)

t1 = GetCrs("Waveform 1","A") ;cursor A current postion
t2 = GetCrs("Waveform 1","B") ;cursor B new position
tshift = t2-t1


; Prepare list with traces and name of traces
nTraces = Length(ref1)
trChnName = Array(0 to nTraces-1) as String
trFileName = List()

; Open each trace, shift, and save it to the list
for n = 0 to nTraces-1 step 1.0 
    tr = File(ref1, n)
    trChnName(n) = GetChName(File(ref1, n))
    tr = Shift(tr, tshift)
    SetVariableValue("trnew" + n, tr)
    trFileName() = GetVariableValue("trnew" + n)
next

; Save all traces into a new File
Save("myNewFile.tpc5", trFileName, trChnName)

Graphical result in TranAX YT Waveform

tumb