Difference between revisions of "Shift traces"

From Elsys Wiki - Help and Recources for TranAX and TraNET DAQ
Jump to: navigation, search
(Created page with "Category:TranAX Category:FormulaEditor In some cases it useful to have the possibility to shift multiple traces in the time axis. E.g. sliced traces from continuous re...")
 
Line 7: Line 7:
 
Cursor A marks the current position of the trace (event, spike) and will be shifted to postition of cursor B.
 
Cursor A marks the current position of the trace (event, spike) and will be shifted to postition of cursor B.
  
 +
=== Formula Editor code snippet ===
 
<syntaxhighlight lang=vb style="border:0px dashed blue">
 
<syntaxhighlight lang=vb style="border:0px dashed blue">
 
; Shift all traces from a file
 
; Shift all traces from a file
Line 36: Line 37:
 
Save("myNewFile.tpc5", trFileName, trChnName)
 
Save("myNewFile.tpc5", trFileName, trChnName)
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Graphical result in TranAX YT Waveform ===
 +
[[File:ShiftedTraces.png]]

Revision as of 16:30, 12 October 2017

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

Shift multiple traces in a files

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 postition 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

ShiftedTraces.png