Пример #1
0
if False:
    isPlot=False
    isVerbose=False
    
    #make Template
    rawData, rawTime = mAD.makePoissonData(totalTime=2*131.072e-3,amplitudes='random',maxSignalToNoise=10,isVerbose=isVerbose)
    rawData*=2 #make data distributed around amplitude =1 
    finalTemplate, time , noiseSpectrumDict, _ , _ = mT.makeTemplate(rawData,nSigmaTrig=4.,numOffsCorrIters=2,isVerbose=isVerbose,isPlot=isPlot)
    fittedTemplate, startFit, riseFit, fallFit = mT.makeFittedTemplate(finalTemplate,time,riseGuess=3.e-6,fallGuess=55.e-6)
    matchedFilter=mF.makeMatchedFilter(fittedTemplate, noiseSpectrumDict['noiseSpectrum'], nTaps=50, tempOffs=75)
    superMatchedFilter=mF.makeSuperMatchedFilter(fittedTemplate, noiseSpectrumDict['noiseSpectrum'], fallFit, nTaps=50, tempOffs=75)

    #test filters on piled up pulses
    time=np.arange(0,400e-6,1e-6)
    pulses=np.zeros(len(time))
    pulses+=mAD.makePulse(time,50e-6,2e-6,50e-6)
    pulses+=mAD.makePulse(time,140e-6,2e-6,50e-6)
    pulses+=.6*(np.random.rand(len(pulses))-0.5)
    pulses=mT.hpFilter(pulses)
    filteredData=np.convolve(pulses,matchedFilter,mode='same') 
    superFilteredData=np.convolve(pulses,superMatchedFilter,mode='same')
    
    fig=plt.figure()
    plt.plot(time,pulses,label='piled-up pulses')
    plt.show()
    
    fig=plt.figure()
    plt.plot(time,filteredData ,label = 'matched filter')
    plt.plot(time,superFilteredData, label= 'pre-pulse robust matched filter')
    plt.legend()
    plt.show()
Пример #2
0
 rawdata, rawtime = mAD.makePoissonData(totalTime=2*131.072e-3,isVerbose=True,maxSignalToNoise=2)
   
 if isPlotPoisson:
     fig1=plt.figure(0)
     plt.plot(rawtime,rawdata)
     plt.show()
 
 #calculate templates    
 finalTemplate, time , _, templateList, _ = mT.makeTemplate(rawdata,nSigmaTrig=4.,numOffsCorrIters=2,isVerbose=True,isPlot=isPlot)
 roughTemplate = templateList[0]
 
 #make fitted template
 fittedTemplate, startFit, riseFit, fallFit = mT.makeFittedTemplate(finalTemplate,time,riseGuess=3.e-6,fallGuess=55.e-6)
 
 #calculate real template
 realTemplate = mAD.makePulse(time,t0,riseTime,fallTime)
 realTemplate = mT.hpFilter(realTemplate)
 realTemplate /= np.abs(realTemplate[np.argmax(np.abs(realTemplate))])
 
 if isPlotRes:
     fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True)
     h1, = ax0.plot(time*1e6,roughTemplate,'r',linewidth=2); h1Label='initial template'
     h2, = ax0.plot(time*1e6,finalTemplate,'g',linewidth=2); h2Label='offset corrected template'
     h3, = ax0.plot(time*1e6,realTemplate,'b', linewidth=2); h3Label='real pulse shape'
     
     ax1.plot(time*1e6,realTemplate-roughTemplate,'r',linewidth=2)
     ax1.plot(time*1e6,realTemplate-finalTemplate,'g',linewidth=2)
     
     ax1.set_xlabel('time [$\mu$s]')
     ax0.set_ylabel('normalized pulse height')
     ax1.set_ylabel('residuals')