# Remove waveforms that show saturation. i.e. Ones in which the maximum value is 100mV AllWaveforms = RemoveSaturation(AllWaveforms, SatLimit) if (RandomSample): # Randomly select NoOfWaveforms from all the waveforms. Selection = random.sample(AllWaveforms, np.shape(AllWaveforms)[0]) if (not RandomSample): ## Or... find the NoOfWaveforms that have the greatest sum (Largest Signals) SumAllWaveforms = PSD.GetFullIntegral(AllWaveforms) ## Get NoOfWaveforms indices of the AllWaveforms N_Max = SumAllWaveforms.argsort()[-NoOfWaveforms:] Selection = AllWaveforms[N_Max] # Convert to Numpy Array Waveforms = np.array(Selection) #print "Length of Waveforms : ", len(Waveforms) Waveforms = PSD.BaselineSubtraction(Waveforms, BaselineSamples) # Get peak value of each waveform PeakList = PSD.GetSignalPeak(Waveforms) # Normalize each signal. for wf, val in enumerate(Waveforms): Waveforms[wf] = val / PeakList[wf] del PeakList # Get trigger sample (the sample at which the waveform crosses threshold) TriggerList = PSD.GetTriggerPosition(Waveforms, Threshold) #print TriggerList TimeAlignedWaveforms, Status = TimeAlign(Waveforms, TriggerList) # Normalize each timealigned averaged signal. if (Normalise):