def Forecast_CellrsxEE(self,ellBinEdges,fsky,option='None'): ellMids = old_div((ellBinEdges[1:] + ellBinEdges[:-1]), 2) cls_rsxEE = self.fgs.rs_crossEE(self.evalells,self.fgs.nu_rs)/self.cc.c['TCMBmuK']**2./((self.evalells+1.)*self.evalells) * 2.* np.pi cls_rs = self.fgs.rs_auto(self.evalells,self.fgs.nu_rs,self.fgs.nu_rs) / self.cc.c['TCMBmuK']**2.\ / ((self.evalells+1.)*self.evalells) * 2.* np.pi cls_cmbEE = self.cc.cleefunc(self.evalells) LF = LensForecast() if (option=='None'): LF.loadGenericCls("rr",self.evalells,cls_rs,self.evalells,self.N_ll_rsxEE_c_cmb)#self.N_ll_rsxEE) LF.loadGenericCls("xx",self.evalells,cls_rsxEE,self.evalells,self.N_ll_rsx*0.0) LF.loadGenericCls("ee",self.evalells,cls_cmbEE,self.evalells,self.N_ll_rsxEE_c_rs)#self.N_ll_cmb) Nellrs = self.N_ll_rsxEE_c_cmb NellcmbEE = self.N_ll_rsxEE_c_rs elif (option=='NoILC'): LF.loadGenericCls("rr",self.evalells,cls_rs,self.evalells,self.N_ll_rsxEE_NoFG) LF.loadGenericCls("xx",self.evalells,cls_rsxEE,self.evalells,self.N_ll_rsx*0.0) LF.loadGenericCls("ee",self.evalells,cls_cmbEE,self.evalells,self.N_ll_cmbee_NoFG) Nellrs = self.N_ll_rsxEE_NoFG NellcmbEE = self.N_ll_cmbee_NoFG else: return "Wrong option" sn2=(2.*self.evalells+1.)*np.nan_to_num((cls_rsxEE**2)/((cls_rs+Nellrs)*(cls_cmbEE+NellcmbEE)+(cls_rsxEE)**2))#**2)#)/(cls_cmbEE+NellcmbEE)) snsq=fsky/2.*sum(sn2) sn=np.sqrt(snsq) cls_out = np.interp(ellMids,self.evalells,cls_rsxEE) ellMids = (ellBinEdges[1:] + ellBinEdges[:-1]) / 2 ellWidths = np.diff(ellBinEdges) covs = [] for ell_left,ell_right in zip(ellBinEdges[:-1],ellBinEdges[1:]): ClSum = LF._bin_cls("rr",ell_left,ell_right)*LF._bin_cls("ee",ell_left,ell_right)+(LF._bin_cls("xx",ell_left,ell_right))**2 ellMid = (ell_right+ell_left)/2. ellWidth = ell_right-ell_left var = ClSum/(2.*ellMid+1.)/ellWidth/fsky covs.append(var) #print(LF._bin_cls("xx",ell_left,ell_right)) errs=np.sqrt(np.array(covs)) return ellMids,cls_out,errs,sn
def Forecast_Cellrsx(self,ellBinEdges,fsky,option='None'): ellMids = (ellBinEdges[1:] + ellBinEdges[:-1])/ 2. cls_rsx = self.fgs.rs_cross(self.evalells,self.fgs.nu_rs) / self.cc.c['TCMBmuK']**2.\ / ((self.evalells+1.)*self.evalells) * 2.* np.pi cls_rs = self.fgs.rs_auto(self.evalells,self.fgs.nu_rs,self.fgs.nu_rs) / self.cc.c['TCMBmuK']**2.\ / ((self.evalells+1.)*self.evalells) * 2.* np.pi cls_cmb = self.cc.clttfunc(self.evalells) LF = LensForecast() if (option=='None'): LF.loadGenericCls("rr",self.evalells,cls_rs,self.evalells,self.N_ll_rs_c_cmb)#self.N_ll_rsx) LF.loadGenericCls("xx",self.evalells,cls_rsx,self.evalells,self.N_ll_rsx*0.0) LF.loadGenericCls("tt",self.evalells,cls_cmb,self.evalells,self.N_ll_cmb_c_rs)#self.N_ll_cmb) Nellrs = self.N_ll_rs_c_cmb #self.N_ll_rsx Nellcmb = self.N_ll_cmb_c_rs #self.N_ll_cmb elif (option=='NoILC'): LF.loadGenericCls("rr",self.evalells,cls_rs,self.evalells,self.N_ll_rsx_NoFG) LF.loadGenericCls("xx",self.evalells,cls_rsx,self.evalells,self.N_ll_rsx*0.0) LF.loadGenericCls("tt",self.evalells,cls_cmb,self.evalells,self.N_ll_cmb_NoFG) Nellrs = self.N_ll_rsx_NoFG Nellcmb = self.N_ll_cmb_NoFG else: return "Wrong option" sn2=(2.*self.evalells+1.)*np.nan_to_num((cls_rsx**2)/((cls_rs+Nellrs)*(cls_cmb+Nellcmb)+(cls_rsx)**2)) snsq=fsky/2.*sum(sn2) sn=np.sqrt(snsq) cls_out = np.interp(ellMids,self.evalells,cls_rsx) #errs = cls_out * 0.0 + 1. ellMids = (ellBinEdges[1:] + ellBinEdges[:-1]) / 2 ellWidths = np.diff(ellBinEdges) covs = [] for ell_left,ell_right in zip(ellBinEdges[:-1],ellBinEdges[1:]): ClSum = LF._bin_cls("rr",ell_left,ell_right)*LF._bin_cls("tt",ell_left,ell_right)+(LF._bin_cls("xx",ell_left,ell_right))**2 ellMid = (ell_right+ell_left)/2. ellWidth = ell_right-ell_left var = ClSum/(2.*ellMid+1.)/ellWidth/fsky covs.append(var) errs=np.sqrt(np.array(covs)) ''' ellMids = (ellBinEdges[1:] + ellBinEdges[:-1])/ 2. ellWidth = (ellBinEdges[1:] - ellBinEdges[:-1]) #cls_rsx = self.fgs.rs_cross(self.evalells,self.freq[0]) / self.cc.c['TCMBmuK']**2.\ # / ((self.evalells+1.)*self.evalells) * 2.* np.pi #print (cls_rsx, self.freq[0],self.fgs.nu_rs) cls_rsx = self.fgs.rs_cross(self.evalells,self.fgs.nu_rs) / self.cc.c['TCMBmuK']**2.\ / ((self.evalells+1.)*self.evalells) * 2.* np.pi cls_rs = self.fgs.rs_auto(self.evalells,self.fgs.nu_rs,self.fgs.nu_rs) / self.cc.c['TCMBmuK']**2.\ / ((self.evalells+1.)*self.evalells) * 2.* np.pi cls_cmb = self.cc.clttfunc(self.evalells) print (cls_rsx,cls_rs, cls_cmb) LF = LensForecast() if (option=='None'): LF.loadGenericCls("rr",self.evalells,cls_rsx,self.evalells,self.N_ll_rsx) #LF.loadGenericCls("tt",self.evalells,cls_cmb,self.evalells,self.N_ll_cmb) Nellrsx = self.N_ll_rs_c_cmb #self.N_ll_rsx Nellcmb = self.N_ll_cmb_c_rs #self.N_ll_cmb elif (option=='NoILC'): LF.loadGenericCls("rr",self.evalells,cls_rsx,self.evalells,self.N_ll_rsx_NoFG) #LF.loadGenericCls("tt",self.evalells,cls_cmb,self.evalells,self.N_ll_rsx_NoFG) Nellrsx = self.N_ll_rsx_NoFG Nellcmb = self.N_ll_cmb_NoFG else: return "Wrong option" print (Nellrsx,Nellcmb) #vars, _, _ = LF.KnoxCov("rr","tt",ellBinEdges,fsky) #sn,errs = LF.sn(ellBinEdges,fsky,"rr") # not squared ind = np.isfinite(Nellrsx) sn = np.sqrt ( fsky / 2 * np.sum( (2.*self.evalells[ind] + 1) * (cls_rsx[ind]**2) / ((cls_rs[ind] + Nellrsx[ind])* (cls_cmb[ind] + Nellcmb[ind])) ) ) errs = 1.#np.sqrt(vars) cls_out = np.interp(ellMids,self.evalells,cls_rsx) #errs = cls_out * 0.0 + 1. return ellMids,cls_out,errs,sn ''' return ellMids,cls_out,errs,sn