def plotBothChannels_talkPlot(self, dataOne, dataTwo, updatePlots, timeAxis):
		numSamples = 19960
		times = timeAxis[0:numSamples]*5e9
		#plots look better if the traces are to scale.  try normalizing them
		normalizedOne = self.normalizeTrace(dataOne[0:numSamples])
		normalizedTwo = self.normalizeTrace(dataTwo[0:numSamples])

		if updatePlots:
			#find where hits are on the two traces
			rawData, hitIndicesOne, hitLimitsHighOne, convPeakMaxOne = CFD(normalizedOne)
			rawData, hitIndicesTwo, hitLimitsHighTwo, convPeakMaxTwo = CFD(normalizedTwo)

			#clear previous lines
			linesOld = self.axisTraces.lines
			for i in range(len(linesOld)):
				lineToDel = linesOld.pop(0)
				del lineToDel
			#clear previous scatter plots
			scatterOld = self.axisTraces.collections
			for i in range(len(scatterOld)):
				scatterToDel = scatterOld.pop(0)
				del scatterToDel
			#plot normalized traces
			self.axisTraces.plot(times, normalizedTwo, color="green")
			self.axisTraces.plot(times, normalizedOne, color="blue")
			plt.legend(["Short ToF", "Long ToF"], fontsize=20)
			#set limits
			self.axisTraces.set_xlim(times[self.xLimits])
			self.axisTraces.set_ylim([-0.12, 1.1])

			#update calls to draw the plot
			self.figHandleTraces.canvas.draw()
def executeSingleTraceAnalysis(dataIn):
    #if each trace is being cycled through, it is probably nice to plot out each trace in the user output
    if (flagEachTraceStop):
        #call CFD to help make the per trace plots
        rawData, hitIndices, hitLimitsHigh, convPeakMax = CFD(dataIn)

        #make the per trace raw data plot
        if (len(hitIndices) > 0):
            makePlotTraceWithHits(dataIn,
                                  np.concatenate((hitIndices, hitLimitsHigh),
                                                 axis=0),
                                  xLimLow=hitIndices[0] - 50,
                                  xLimHigh=hitIndices[0] + 1200)
            # makePlotTraceWithHits(dataIn, hitIndices, colorIn="green")
        else:
            # makePlotTraceWithHits(dataIn, hitIndices, colorIn="green")
            pass

    numHits = len(hitIndices)
    #if there's one hit, this trace may be useful to look at in fft domain
    if (numHits == 1):
        #calculate the FFT and only look at half of it (say, just positive frequencies)
        fourierFull = scipy.fft(dataIn)
        fourierMagnitude = np.absolute(fourierFull)
        fourierHalf = cutFourierScaleInHalf(fourierMagnitude)
        # plotSimple(fourierHalf)

        #call a bunch of functions to try and calculate/profile the single hit.  These functions should return meaningful characteristics of the single hit, and produce a quantity that can be used to compile a data set's statistics
        #create a normalized wavefunction
        normalizedData = normalizeTrace(dataIn)
Пример #3
0
def returnWaveformHitsAndPSD(dataIn):
    #binary .trc files provide the raw waveform as the dataIn
    dataTrace, hitIndices = CFD(dataIn)
    #call calculatePSD to get the power spectral density of the FFT of the current trace
    PSDOfTrace = calculatePSD(dataIn)

    return dataIn, hitIndices, PSDOfTrace
	def addToHistograms(self, dataOne, dataTwo, updatePlots):
		#normalize the raw traces
		normalizedOne = self.normalizeTrace(dataOne)
		normalizedTwo = self.normalizeTrace(dataTwo)

		#process new trace and add hits for channel 1
		rawData, hitIndices, hitLimitsHigh, convPeakMax = CFD(normalizedOne)
		self.histogramOne = addHitsToHistogram(hitIndices, self.histogramOne)

		#do the same for channel 2
		rawData, hitIndices, hitLimitsHigh, convPeakMax = CFD(normalizedTwo)
		self.histogramTwo = addHitsToHistogram(hitIndices, self.histogramTwo)


		if updatePlots:
			#plot the current histogram for channel 1
			#clear previous lines in time histogram
			linesOld = self.axisHistogram.lines
			for i in range(len(linesOld)):
				lineToDel = linesOld.pop(0)
				del lineToDel

			#clear previous lines in energy histogram
			linesOld = self.axisEnergyHistogram.lines
			for i in range(len(linesOld)):
				lineToDel = linesOld.pop(0)
				del lineToDel

			#plot the current/new histograms
			self.axisHistogram.plot(calculateBinnedHistogramTrace(self.histogramOne, binWidth))
			self.axisHistogram.plot(calculateBinnedHistogramTrace(self.histogramTwo, binWidth))
			#set limits
			self.axisHistogram.set_xlim(self.xLimits)

			#calculate new energy histogram values
			self.energyHistogramOne = np.matmul(self.overlapMatrix, self.histogramOne)
			self.energyHistogramTwo = np.matmul(self.overlapMatrix, self.histogramTwo)
			#plot the new energy histogram values on the appropriate axis
			self.axisEnergyHistogram.plot(self.energyVector, self.energyHistogramOne)
			# self.axisEnergyHistogram.plot(self.energyHistogramTwo)


			#update calls to draw the plots
			self.figHandleHistograms.canvas.draw()
			self.figHandleEnergyHistogram.canvas.draw()

		pass
	def plotBothChannels(self, dataOne, dataTwo, updatePlots):
		#plots look better if the traces are to scale.  try normalizing them
		normalizedOne = dataOne#self.normalizeTrace(dataOne)
		normalizedTwo = dataTwo#self.normalizeTrace(dataTwo)

		if updatePlots:
			#find where hits are on the two traces
			rawData, hitIndicesOne, hitLimitsHighOne, convPeakMaxOne = CFD(normalizedOne)
			rawData, hitIndicesTwo, hitLimitsHighTwo, convPeakMaxTwo = CFD(normalizedTwo)

			#clear previous lines
			linesOld = self.axisTraces.lines
			for i in range(len(linesOld)):
				lineToDel = linesOld.pop(0)
				del lineToDel
			#clear previous scatter plots
			scatterOld = self.axisTraces.collections
			for i in range(len(scatterOld)):
				scatterToDel = scatterOld.pop(0)
				del scatterToDel
			#plot normalized traces
			self.axisTraces.plot(normalizedOne, color="blue")
			self.axisTraces.plot(normalizedTwo, color="green")
			#plot scatter markers to denote hits
			for i in range(len(hitIndicesOne)):
				collectionToPlot = [hitIndicesOne[i], hitLimitsHighOne[i]]
				self.axisTraces.scatter(collectionToPlot, normalizedOne[collectionToPlot], color="red")
			#repeat for hits for trace two
			for i in range(len(hitIndicesTwo)):
				collectionToPlot = [hitIndicesTwo[i], hitLimitsHighTwo[i]]
				# self.axisTraces.scatter(collectionToPlot, normalizedTwo[collectionToPlot], color="red")
			#set limits
			#self.axisTraces.set_xlim(self.xLimits)

			#update calls to draw the plot
			self.figHandleTraces.canvas.draw()
        #convert binary segment into a numpy array of appropriate data type
        traceNow = np.frombuffer(segmentNow, dtype=dt)

        if (len(traceNow) == 0):
            moreToRead = False
            print(
                "The end of file was reached, with 0 bytes in the final read")
        elif (len(traceNow) < traceDataSize / savedDataTypeSizeInBytes):
            print(
                "A trace was read in with a byte size that is not equal to the size prescribed in the header file."
            )
        else:
            #a normal, complete trace has been extracted.  This section may be used to process traces as desired by user.

            #perform processing similar to that done on the o-scope
            rawData, hitIndices, hitLimitsHigh, convPeakMax = CFD(traceNow)
            normedTrace = normalizeTrace(rawData)

            #			plt.figure()
            #			plt.plot(traceNow)
            #			if (hitIndices.size > 0):
            #				plt.scatter(hitIndices, traceNow[hitIndices], s=150)
            #			plt.draw()
            #			plt.pause(0.001)

            totalNumberHits = totalNumberHits + len(hitIndices)

            #if this is the first trace, set up some variables for the first time
            if (tracesProcessed == 0):
                histogramCollected = initializeHistogram(rawData)
Пример #7
0
def returnWaveformAndHits(dataIn):
    #binary .trc files provide the raw waveform as the dataIn
    dataTrace, hitIndices = CFD(dataIn)
    return dataIn, hitIndices