Ejemplo n.º 1
0
################## SIMULATED RESIDUALS ########################

# create idealized TOAs
if args.real == False:
    print 'Creating Idealized TOAs'
    for p in pp:
        p.stoas[:] -= p.residuals()/86400
        p.fit()

# add gwb
if args.gwb:
    
    print 'Simulating GWB with Amp = {0} and gamma = {1}'.format(args.gwbAmp, args.gwbIndex)

    inducedRes = PALutils.createGWB(psr, args.gwbAmp, args.gwbIndex)
        
    # add to site arrival times of pulsar
    for ct, p in enumerate(pp):
        p.stoas[:] += np.longdouble(inducedRes[ct]/86400)

# add DM variations
if args.DM:

    print 'Simulating DM using values in hdf5 file'

    for ct, p in enumerate(psr):

        # get values from hdf5 file
        try:
            DMAmp = pfile['Data']['Pulsars'][p.name]['DMAmp'].value
Ejemplo n.º 2
0
def upperLimitFunc(A, optstat_ref, nreal):
    """
    Compute the value of the Optimal Statistic for different signal realizations
    
    @param A: value of GWB amplitude
    @param optstat_ref: value of optimal statistic with no injection 
    @param nreal: number of realizations

    """
    count = 0
    for ii in range(nreal):
        
        # create residuals
        inducedRes = PALutils.createGWB(psr, A, 4.3333)

        Pinvr = []
        Pinv = []
        for ct, p in enumerate(psr):

            # replace residuals in pulsar object
            p.res = res[ct] + np.dot(R[ct], inducedRes[ct])

            # determine injected amplitude by minimizing Likelihood function
            c = np.dot(Dmatrix[ct], p.res)
            f = lambda x: -PALutils.twoComponentNoiseLike(x, D[ct], c)
            fbounded = minimize_scalar(f, bounds=(0, 1e-14, 3.0e-13), method='Brent')
            Amp = np.abs(fbounded.x)
            #print Amp
            #Amp = A

            # construct P^-1 r
            Pinvr.append(c/(Amp**2 * D[ct] + 1))
            Pinv.append(1/(Amp**2 * D[ct] + 1))

        # construct optimal statstic
        k = 0
        top = 0
        bot = 0
        for ll in range(npsr):
            for kk in range(ll+1, npsr):

                # compute numerator of optimal statisic
                top += ORF[k]/2 * np.dot(Pinvr[ll], np.dot(SIJ[k], Pinvr[kk]))

                # compute trace term
                bot += (ORF[k]/2)**2 * np.trace(np.dot((Pinv[ll]*SIJ[k].T).T, (Pinv[kk]*SIJ[k]).T))
                # iterate counter 
                k += 1

        # get optimal statistic and SNR
        optStat = top/bot
        snr = top/np.sqrt(bot)
        
        # check to see if larger than in real data
        if optStat > optstat_ref:
            count += 1


    # now get detection probability
    detProb = count/nreal

    print A, detProb
    injAmp.append(A)
    injDetProb.append(detProb)

    return detProb - 0.95
Ejemplo n.º 3
0
    for ct, p in enumerate(pp):

        inducedRes = (PALutils.createResiduals(psr[ct], np.pi/2-args.gwdec, args.gwra, args.gwchirpmass, \
                                args.gwdist, args.gwfreq, args.gwphase, args.gwpolarization, \
                                args.gwinc))

        # add to site arrival times of pulsar
        p.stoas[:] += np.longdouble(inducedRes/86400)

# add gwb
if args.gwb:
    
    print 'Simulating GWB with Amp = {0} and gamma = {1}'.format(args.gwbAmp, args.gwbIndex)

    inducedRes = PALutils.createGWB(psr, args.gwbAmp, args.gwbIndex)
        
    # add to site arrival times of pulsar
    for ct, p in enumerate(pp):
        p.stoas[:] += np.longdouble(inducedRes[ct]/86400)

# add noise based on values in hdf5 file
if args.noise:
    
    print 'Simulating noise based on values in hdf5 file'

    for ct, p in enumerate(psr):

        # get values from hdf5 file
        Amp = pfile['Data']['Pulsars'][p.name]['Amp'].value
        gam = pfile['Data']['Pulsars'][p.name]['gam'].value