Merging Traces

From Elsys Wiki - Help and Recources for TranAX and TraNET DAQ
Revision as of 07:29, 13 August 2018 by Rbertschi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

With the function MergeTraces you can merge multiple waveforms into one waveform. This can be useful if you want to separate specific events from your measured curve. You are also able to pick single events from a Multiblock measurement and put specific blocks into a new waveform.

Merge events from Continuous Measurement into another trace

If you have a continuous measurement which is fairly long and just have several events which are interesting then you can merge those events into a new trace (tpc5). The function MergeTraces will help you with this task.

; Works with TranAX or newer

; Don't close files. Improves performance.
SetEnvironment(1, False)

; Don't save files. Improves performance.
SetEnvironment(5, True)

; File which has to be analyzed
filepathToAnalyze = "X:\TBE\T1_1428_USS002_16kHz_anschleifen.tpc5"

; File destination
filepathForMergedTraces = "mergedTrace.tpc5"

listOfTraces = List()
nrOfTraces = NTracesInFile(filepathToAnalyze)

; Keep all traces from the file in a list
for chanIdx = 0 to nrOfTraces-1 step 1.0 
    trace = File(filepathToAnalyze, chanIdx)
	listOfTraces() = trace

; Evaluate start and end time of trace number 2
trace2 = listOfTraces(2)
tstart = TBegin(trace2)
tstop = TEnd(trace2)

; We use a constant time window for slicing the events
sliceLength[s] = 170e-6

; Loop all events (positive slope) in trace2
for each timeVal in EnEvents(trace2, 0, tstart, tstop, 1, 0.25) 
    for chanIdx = 0 to nrOfTraces-1 step 1.0 
        trace = listOfTraces(chanIdx)
        slicedTrace = Slice(trace, timeVal, timeVal + sliceLength)
        channelName = GetChName(trace)
        ; Merge the slice into the file.
        MergeTraces(filepathForMergedTraces, channelName, chanIdx, slicedTrace)

; Close the file

Graphical result in TranAX YT Waveform