Beispiel #1
0
    def test_chisq(self):
        chisq_quick = {}
        chisq_full = {}
        chisq_ref = {}
        for ifo in self.ifos:
            nbins = 26
            dof = nbins * 2 - 2

            bins = power_chisq_bins(self.hp,
                                    nbins,
                                    self.psd[ifo],
                                    low_frequency_cutoff=20.0)
            chisq = power_chisq_at_points_from_precomputed \
                (self.corr[ifo], self.snr_unnorm[ifo][27402:27492].data,
                 self.norm[ifo], bins, indices=numpy.arange(27402,27492))
            chisq_quick[ifo] = chisq / dof

            chisq = power_chisq(self.hp,
                                self.data[ifo],
                                nbins,
                                self.psd[ifo],
                                low_frequency_cutoff=20.0)
            chisq_full[ifo] = chisq[27402:27492] / dof
            max_diff = max(abs(chisq_full[ifo] - chisq_quick[ifo]))
            self.assertTrue(max_diff < 1E-5)
Beispiel #2
0
def xis(snr, template, strain, psd_o, fc, grafica, time_max, duration, hc,
        shift, time_trigger):

    nbins = 16

    chisq = power_chisq(template,
                        strain,
                        nbins,
                        psd_o,
                        low_frequency_cutoff=fc,
                        high_frequency_cutoff=hc)

    chisq = chisq.crop(4, 4)

    dof = nbins * 2 - 2
    chisq /= dof

    nsnr = newsnr(snr, chisq)

    maximo = max(nsnr)

    print 'maximo ', abs(maximo)

    MaxInd = np.argmax(nsnr)

    time = snr.sample_times[MaxInd]

    if grafica == 1:

        pylab.figure('Superposition')
        pylab.plot(snr.sample_times, abs(nsnr), label='Re-weighted SNR')
        #pylab.plot(snr.sample_times,abs(snr),label='Original SNR')
        #pylab.title('Re-weighted SNR')
        #pylab.ylabel('Signal-to-noise ratio')
        pylab.xlabel('Time(s)')
        pylab.legend()
        #pylab.xlim(time_max-0.05, time_max+0.05)
        pylab.grid()
        pylab.show()

        pylab.figure('Re-weighted SNR')
        pylab.plot(snr.sample_times, abs(nsnr))
        pylab.grid()
        pylab.show()

    return maximo, time, nsnr
Beispiel #3
0
    def test_chisq(self):
        chisq_quick = {}
        chisq_full = {}
        chisq_ref = {}
        for ifo in self.ifos:
            nbins = 26
            dof = nbins * 2 - 2

            bins = power_chisq_bins(self.hp, nbins, self.psd[ifo],
                                    low_frequency_cutoff=20.0)
            chisq = power_chisq_at_points_from_precomputed \
                (self.corr[ifo], self.snr_unnorm[ifo][27402:27492].data,
                 self.norm[ifo], bins, indices=numpy.arange(27402,27492))
            chisq_quick[ifo] = chisq /  dof

            chisq = power_chisq(self.hp, self.data[ifo], nbins,
                                self.psd[ifo], low_frequency_cutoff=20.0)
            chisq_full[ifo] = chisq[27402:27492] / dof
            max_diff = max(abs(chisq_full[ifo] - chisq_quick[ifo]))
            self.assertTrue(max_diff < 1E-5)
Beispiel #4
0
def xis(snr,template,strain,psd_o,fc,grafica,time_max,duration,hc,shift,time_trigger):
    
    
    nbins = 32
    
    
    start_time = strain.start_time
  
    end_time = strain.start_time+32
  
    
    

    
    chisq = power_chisq(template, strain, nbins, psd_o, low_frequency_cutoff=fc,high_frequency_cutoff=hc)



    if grafica == 1:
            
        print(start_time)
        print(end_time)
        print(time_max)    
        print(strain.delta_f)
        print(template.delta_f)
        print(psd_o.delta_f)
       
        crop_left = abs(start_time - time_max)-1.98
    
        crop_right = abs(end_time - time_max)-1.98
    
        print(crop_left)
    
        print(crop_right)
            
        chisq = chisq.crop(crop_left, crop_right)
    
        dof = 2*nbins-2
    
        chisq /= dof
        
        low_chisq =  abs(chisq).numpy().argmin()
    
    if grafica == 0:
        
        chisq = chisq.crop(4,4)
        
        dof = 2*nbins-2
    
        chisq /= dof
    
        low_chisq = chisq[time_trigger]
        
    
    print('Lower value of Chi')
    print(low_chisq)

    if grafica == 1: 
        
        nsnr=newsnr(snr,chisq)
        
        pylab.plot(chisq.sample_times,chisq)
        pylab.ylabel('$chi^2_r$')
        pylab.xlabel('Time(s)')
        pylab.xlim(time_max-0.1, time_max+0.1)
        
        pylab.grid()
        pylab.show() 
        
        pylab.figure('Superposition',figsize=[15,5])
        pylab.plot(snr.sample_times,abs(nsnr),label='Re-weighted SNR')
        pylab.plot(snr.sample_times,abs(snr),label='Original SNR')
        pylab.plot(chisq.sample_times,chisq,label='$Chi^2$')
        #pylab.title('Re-weighted SNR')
        #pylab.ylabel('Signal-to-noise ratio')
        pylab.xlabel('Time(s)')
        pylab.legend()
        #pylab.xlim(time_max-0.05, time_max+0.05)
        
        pylab.grid()
        pylab.show()  
        

        pylab.plot(snr.sample_times,abs(snr))
        pylab.title('Matched filter output')
        pylab.ylabel('Signal-to-noise ratio')
        pylab.xlabel('Time(s)')
        pylab.xlim(time_max-0.1, time_max+0.1)
        
        pylab.grid()
        pylab.show()  
    
    
    return chisq, low_chisq
Beispiel #5
0
def xis(snr, template, strain, psd, fc, grafica, time_max, duration, hc,
        shift):

    nbins = 32

    start_time = strain.start_time

    end_time = strain.start_time + 32

    #crop_left = abs(start_time - time_max-5)

    #crop_right = abs(end_time - time_max-5)

    #strain = strain.crop(crop_left,crop_right)
    #psd   = psd.crop(crop_left,crop_right)

    chisq = power_chisq(template,
                        strain,
                        nbins,
                        psd,
                        low_frequency_cutoff=fc,
                        high_frequency_cutoff=hc)
    chisq = chisq.crop(4, 4)
    dof = 2 * nbins - 2

    chisq /= dof

    low_chisq = min(chisq)

    #print 'Lower value of Chi'
    #print low_chisq

    if grafica == 1:

        nsnr = newsnr(snr, chisq)

        pylab.plot(chisq.sample_times, chisq)
        pylab.ylabel('$chi^2_r$')
        pylab.xlabel('Time(s)')
        pylab.xlim(time_max - 0.1, time_max + 0.1)

        pylab.grid()
        pylab.show()

        pylab.figure('Superposition', figsize=[15, 5])
        pylab.plot(snr.sample_times, abs(nsnr), label='Re-weighted SNR')
        pylab.plot(snr.sample_times, abs(snr), label='Original SNR')
        pylab.plot(chisq.sample_times, chisq, label='$Chi^2$')
        #pylab.title('Re-weighted SNR')
        #pylab.ylabel('Signal-to-noise ratio')
        pylab.xlabel('Time(s)')
        pylab.legend()
        pylab.xlim(time_max - 0.05, time_max + 0.05)

        pylab.grid()
        pylab.show()

        pylab.plot(snr.sample_times, abs(snr))
        pylab.title('Matched filter output')
        pylab.ylabel('Signal-to-noise ratio')
        pylab.xlabel('Time(s)')
        pylab.xlim(time_max - 0.1, time_max + 0.1)

        pylab.grid()
        pylab.show()

    return chisq, low_chisq