def OSupperLimit(psr, GCGnoiseInv, ORF, OSsmbhb, ul_list=None, far=None, drlist=None, tex=True, nlims=60): if tex == True: plt.rcParams['text.usetex'] = True gam_bkgrd = np.linspace(1.01,6.99,nlims) optStatList=[] ct=0 for indx in gam_bkgrd: optStatList.append( utils.optStat(psr, GCGnoiseInv, ORF, gam_gwb=indx)[:3] ) ct+=1 print "Finished {0}% of optimal-statistic upper-limit calculations...".format( 100.0*ct/(1.0*nlims) ) optStatList = np.array(optStatList) fig, ax = plt.subplots() stylelist = ['solid','dashed','dotted'] if ul_list is not None: for ii in range(len(ul_list)): ax.plot(gam_bkgrd, np.sqrt( optStatList[:,0] + optStatList[:,1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-ul_list[ii])) ) ), linestyle=stylelist[ii], color='black', linewidth=3.0, label='$A_h$ {0}$\%$ upper-limit'.format(ul_list[ii]*100)) plt.hlines(y=np.sqrt( OSsmbhb[0] + OSsmbhb[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-ul_list[ii])) ) ), xmin=gam_bkgrd.min(), xmax=13./3., linewidth=3.0, linestyle='solid', color='red') plt.vlines(x=13./3., ymin=0.0, ymax=np.sqrt( OSsmbhb[0] + OSsmbhb[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-ul_list[ii])) ) ), linewidth=3.0, linestyle='solid', color='red') else: for ii in range(len(drlist)): ax.plot(gam_bkgrd, np.sqrt( optStatList[:,1]*np.sqrt(2.0)*( ss.erfcinv(2.0*far) - ss.erfcinv(2.0*drlist[ii]) ) ), linestyle=stylelist[ii], color='black', linewidth=3.0, label='$A_h$ ({0}$\%$ FAR, {1}$\%$ DR)'.format(far*100,drlist[ii]*100)) plt.hlines(y=np.sqrt( OSsmbhb*np.sqrt(2.0)*( ss.erfcinv(2.0*far) - ss.erfcinv(2.0*drlist[ii]) ) ), xmin=gam_bkgrd.min(), xmax=13./3., linewidth=3.0, linestyle='solid', color='red') plt.vlines(x=13./3., ymin=0.0, ymax=np.sqrt( OSsmbhb*np.sqrt(2.0)*( ss.erfcinv(2.0*far) - ss.erfcinv(2.0*drlist[ii]) ) ), linewidth=3.0, linestyle='solid', color='red') ax.set_yscale('log') ax.set_xlabel(r'$\gamma\equiv 3-2\alpha$', fontsize=20) ax.set_ylabel(r'$A_h$', fontsize=20) ax.minorticks_on() plt.tick_params(labelsize=18) plt.grid(which='major') plt.grid(which='minor') plt.title('Optimal-statistic bounds') plt.legend(loc='lower left', shadow=True, frameon=True, prop={'size':15}) plt.show()
def OSupperLimit(psr, GCGnoiseInv, ORF, OSsmbhb, ul_list=None, far=None, drlist=None, tex=True, nlims=60): if tex == True: plt.rcParams['text.usetex'] = True gam_bkgrd = np.linspace(1.01, 6.99, nlims) optStatList = [] ct = 0 for indx in gam_bkgrd: optStatList.append( utils.optStat(psr, GCGnoiseInv, ORF, gam_gwb=indx)[:3]) ct += 1 print "Finished {0}% of optimal-statistic upper-limit calculations...".format( 100.0 * ct / (1.0 * nlims)) optStatList = np.array(optStatList) fig, ax = plt.subplots() stylelist = ['solid', 'dashed', 'dotted'] if ul_list is not None: for ii in range(len(ul_list)): ax.plot( gam_bkgrd, np.sqrt(optStatList[:, 0] + optStatList[:, 1] * np.sqrt(2.0) * (ss.erfcinv(2.0 * (1. - ul_list[ii])))), linestyle=stylelist[ii], color='black', linewidth=3.0, label='$A_h$ {0}$\%$ upper-limit'.format(ul_list[ii] * 100)) plt.hlines(y=np.sqrt(OSsmbhb[0] + OSsmbhb[1] * np.sqrt(2.0) * (ss.erfcinv(2.0 * (1. - ul_list[ii])))), xmin=gam_bkgrd.min(), xmax=13. / 3., linewidth=3.0, linestyle='solid', color='red') plt.vlines(x=13. / 3., ymin=0.0, ymax=np.sqrt(OSsmbhb[0] + OSsmbhb[1] * np.sqrt(2.0) * (ss.erfcinv(2.0 * (1. - ul_list[ii])))), linewidth=3.0, linestyle='solid', color='red') else: for ii in range(len(drlist)): ax.plot( gam_bkgrd, np.sqrt( optStatList[:, 1] * np.sqrt(2.0) * (ss.erfcinv(2.0 * far) - ss.erfcinv(2.0 * drlist[ii]))), linestyle=stylelist[ii], color='black', linewidth=3.0, label='$A_h$ ({0}$\%$ FAR, {1}$\%$ DR)'.format( far * 100, drlist[ii] * 100)) plt.hlines(y=np.sqrt( OSsmbhb * np.sqrt(2.0) * (ss.erfcinv(2.0 * far) - ss.erfcinv(2.0 * drlist[ii]))), xmin=gam_bkgrd.min(), xmax=13. / 3., linewidth=3.0, linestyle='solid', color='red') plt.vlines( x=13. / 3., ymin=0.0, ymax=np.sqrt( OSsmbhb * np.sqrt(2.0) * (ss.erfcinv(2.0 * far) - ss.erfcinv(2.0 * drlist[ii]))), linewidth=3.0, linestyle='solid', color='red') ax.set_yscale('log') ax.set_xlabel(r'$\gamma\equiv 3-2\alpha$', fontsize=20) ax.set_ylabel(r'$A_h$', fontsize=20) ax.minorticks_on() plt.tick_params(labelsize=18) plt.grid(which='major') plt.grid(which='minor') plt.title('Optimal-statistic bounds') plt.legend(loc='lower left', shadow=True, frameon=True, prop={'size': 15}) plt.show()
tgrid = utils.makeTimeGrid(psr[ii], psr[ii]) #Cgwb_ML = utils.makeRedTDcov(Agwb_ML, 13./3., tgrid) Cred = utils.makeRedTDcov(Ared_ML[ii], gam_red_ML[ii], tgrid) Cdm = utils.makeDmTDcov(psr[ii], Adm_ML[ii], gam_dm_ML[ii], tgrid) Cwhite = np.diag(psr[ii].toaerrs**2.0) ######## #GCGnoise = np.dot(psr[ii].G.T, np.dot(Cgwb_ML+Cred+Cdm+Cwhite, psr[ii].G)) GCGnoise = np.dot(psr[ii].G.T, np.dot(Cred+Cdm+Cwhite, psr[ii].G)) GCGnoise = np.nan_to_num(GCGnoise) cho = sl.cho_factor(GCGnoise) GCGnoiseInv.append(sl.cho_solve(cho, np.eye(len(GCGnoise)))) gam_bkgrd = 4.33333 optimalStat = utils.optStat(psr, GCGnoiseInv, HnD, gam_gwb=gam_bkgrd) print "\n A^2 = {0}, std = {1}, SNR = {2}\n".format(optimalStat[0],optimalStat[1],optimalStat[2]) print "\n In this data, the minimum Ah of an SMBHB background that is required for 5% FAR and 68% DR is {0}\n".\ format(np.sqrt( optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*0.05) - ss.erfcinv(2.0*0.68) ) )) print "\n In this data, the minimum Ah of an SMBHB background that is required for 5% FAR and 95% DR is {0}\n".\ format(np.sqrt( optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*0.05) - ss.erfcinv(2.0*0.95) ) )) print "\n The 90% upper-limit on Ah is {0}\n".\ format(np.sqrt( optimalStat[0] + optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-0.90)) ) )) print "\n The 95% upper-limit on Ah is {0}\n".\ format(np.sqrt( optimalStat[0] + optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-0.95)) ) )) if args.make_plot:
tgrid = utils.makeTimeGrid(psr[ii], psr[ii]) #Cgwb_ML = utils.makeRedTDcov(Agwb_ML, 13./3., tgrid) Cred = utils.makeRedTDcov(Ared_ML[ii], gam_red_ML[ii], tgrid) Cdm = utils.makeDmTDcov(psr[ii], Adm_ML[ii], gam_dm_ML[ii], tgrid) Cwhite = np.diag(psr[ii].toaerrs**2.0) ######## #GCGnoise = np.dot(psr[ii].G.T, np.dot(Cgwb_ML+Cred+Cdm+Cwhite, psr[ii].G)) GCGnoise = np.dot(psr[ii].G.T, np.dot(Cred + Cdm + Cwhite, psr[ii].G)) GCGnoise = np.nan_to_num(GCGnoise) cho = sl.cho_factor(GCGnoise) GCGnoiseInv.append(sl.cho_solve(cho, np.eye(len(GCGnoise)))) gam_bkgrd = 4.33333 optimalStat = utils.optStat(psr, GCGnoiseInv, HnD, gam_gwb=gam_bkgrd) print "\n A^2 = {0}, std = {1}, SNR = {2}\n".format(optimalStat[0], optimalStat[1], optimalStat[2]) print "\n In this data, the minimum Ah of an SMBHB background that is required for 5% FAR and 68% DR is {0}\n".\ format(np.sqrt( optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*0.05) - ss.erfcinv(2.0*0.68) ) )) print "\n In this data, the minimum Ah of an SMBHB background that is required for 5% FAR and 95% DR is {0}\n".\ format(np.sqrt( optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*0.05) - ss.erfcinv(2.0*0.95) ) )) print "\n The 90% upper-limit on Ah is {0}\n".\ format(np.sqrt( optimalStat[0] + optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-0.90)) ) )) print "\n The 95% upper-limit on Ah is {0}\n".\ format(np.sqrt( optimalStat[0] + optimalStat[1]*np.sqrt(2.0)*( ss.erfcinv(2.0*(1.-0.95)) ) )) if args.make_plot: