def valueCross(self,pars): qso_boost = pars["qso_metal_boost"] qso_evol = [pars['qso_evol_0'],pars['qso_evol_1']] bias_qso = pars["bias_qso"] growth_rate = pars["growth_rate"] beta_qso = growth_rate/bias_qso bias_met = sp.array([pars['bias_'+met] for met in self.met_names]) beta_met = sp.array([pars['beta_'+met] for met in self.met_names]) Lpar = pars["Lpar_cross"] Lper = pars["Lper_cross"] ### Scales if (self.different_drp): drp_met = sp.array([pars['drp_'+met] for met in self.met_names]) drp = sp.outer(sp.ones(self.nd_cross),drp_met) else: drp = pars["drp"] if self.grid: ### Redshift evolution z = self.grid_qso_met[:,:,2] evol = sp.power( self.evolution_growth_factor(z)/self.evolution_growth_factor(self.zref),2. ) evol *= self.evolution_Lya_bias(z,[pars["alpha_lya"]])/self.evolution_Lya_bias(self.zref,[pars["alpha_lya"]]) evol *= self.evolution_QSO_bias(z,qso_evol)/self.evolution_QSO_bias(self.zref,qso_evol) rp_shift = self.grid_qso_met[:,:,0]+drp rt = self.grid_qso_met[:,:,1] r = sp.sqrt(rp_shift**2 + rt**2) mur = rp_shift/r muk = cosmo_model.muk kp = self.k * muk kt = self.k * sp.sqrt(1.-muk**2) ### Correction to linear power-spectrum pk_corr = (1.+0.*muk)*self.pk pk_corr *= sp.sinc(kp*Lpar/2./sp.pi)**2 pk_corr *= sp.sinc(kt*Lper/2./sp.pi)**2 ### Biases b1b2 = qso_boost*bias_qso*bias_met if self.grid: xi_qso_met = sp.zeros(self.grid_qso_met[:,0,0].size) for i in range(self.nmet): pk_full = b1b2[i]*(1. + beta_met[i]*muk**2)*(1. + beta_qso*muk**2)*pk_corr xi_qso_met += cosmo_model.Pk2Xi(r[:,i],mur[:,i],self.k,pk_full,ell_max=self.ell_max)*evol[:,i] else: nbins = list(self.xdmat.values())[0].shape[0] xi_qso_met = sp.zeros(nbins) for i in self.met_names: bias_met = pars["bias_"+i] beta_met = pars["beta_"+i] recalc = beta_met != self.prev_pmet['beta_'+i] or\ growth_rate != self.prev_pmet['growth_rate'] or\ not sp.allclose(qso_evol,self.prev_pmet['qso_evol']) or\ self.prev_pmet['drp'] != drp if recalc: if self.verbose: print("recalculating metal {}".format(i)) self.prev_pmet['beta_'+i] = beta_met self.prev_pmet['growth_rate'] = growth_rate self.prev_pmet['qso_evol'] = qso_evol self.prev_pmet['drp'] = drp z = self.xzeff[i] evol = sp.power( self.evolution_growth_factor(z)/self.evolution_growth_factor(self.zref),2. ) evol *= self.evolution_Lya_bias(z,[pars["alpha_"+i]])/self.evolution_Lya_bias(self.zref,[pars["alpha_"+i]]) evol *= self.evolution_QSO_bias(z,qso_evol)/self.evolution_QSO_bias(self.zref,qso_evol) rp = self.xrp[i] + drp rt = self.xrt[i] r = sp.sqrt(rp**2+rt**2) w=r==0 r[w]=1e-6 mur = rp/r pk_full = (1. + beta_met*muk**2)*(1. + beta_qso*muk**2)*pk_corr self.prev_xi_qso_met[i] = cosmo_model.Pk2Xi(r,mur,self.k,pk_full,ell_max=self.ell_max) self.prev_xi_qso_met[i] = self.xdmat[i].dot(self.prev_xi_qso_met[i]*evol) xi_qso_met += qso_boost*bias_qso*bias_met*self.prev_xi_qso_met[i] return xi_qso_met
def valueAuto(self,pars): bias_lya=pars["bias_lya*(1+beta_lya)"] beta_lya=pars["beta_lya"] bias_lya /= 1+beta_lya if self.templates: bias_met=sp.array([pars['bias_'+met] for met in self.met_names]) beta_met=sp.array([pars['beta_'+met] for met in self.met_names]) amp=sp.zeros([self.nmet,3]) amp[:,0] = bias_met*(1 + (beta_lya+beta_met)/3 + beta_lya*beta_met/5) amp[:,1] = bias_met*(2*(beta_lya+beta_met)/3 + 4*beta_lya*beta_met/7) amp[:,2] = bias_met*8*beta_met*beta_lya/35 amp*=bias_lya xi_lya_met=amp*self.temp_lya_met xi_lya_met=sp.sum(xi_lya_met,axis=(1,2)) amp=sp.zeros([self.nmet,self.nmet,3]) bias_met2 = bias_met*bias_met[None,:] amp[:,:,0] = bias_met2*(1+(beta_met+beta_met[None,:])/3+beta_met*beta_met[None,:]/5) amp[:,:,1] = bias_met2*(2*(beta_met+beta_met[None,:])/3+4*beta_met*beta_met[None,:]/7) amp[:,:,2] = bias_met2*8*beta_met*beta_met[None,:]/35 xi_met_met=amp*self.temp_met_met xi_met_met=sp.sum(xi_met_met,axis=(1,2,3)) else: muk = cosmo_model.muk k = self.k kp = k*muk kt = k*sp.sqrt(1-muk**2) nbins = self.dmat["LYA_"+self.met_names[0]].shape[0] if self.hcds_mets: bias_lls = pars["bias_lls"] beta_lls = pars["beta_lls"] L0_lls = pars["L0_lls"] Flls = sp.sin(kp*L0_lls)/(kp*L0_lls) Lpar_auto = pars["Lpar_auto"] Lper_auto = pars["Lper_auto"] alpha_lya = pars["alpha_lya"] Gpar = sp.sinc(kp*Lpar_auto/2/sp.pi)**2 Gper = sp.sinc(kt*Lper_auto/2/sp.pi)**2 xi_lya_met = sp.zeros(nbins) for met in self.met_names: bias_met = pars['bias_'+met] beta_met = pars['beta_'+met] alpha_met = pars["alpha_"+met] dm = self.dmat["LYA_"+met] recalc = beta_met != self.prev_pmet["beta_"+met]\ or beta_lya != self.prev_pmet["beta_lya"]\ or alpha_lya != self.prev_pmet["alpha_lya"]\ or alpha_met != self.prev_pmet["alpha_"+met] rt = self.auto_rt["LYA_"+met] rp = self.auto_rp["LYA_"+met] zeff = self.auto_zeff["LYA_"+met] r = sp.sqrt(rt**2+rp**2) w = (r==0) r[w] = 1e-6 mur = rp/r if recalc: if self.verbose: print("recalculating ",met) pk = (1+beta_lya*muk**2)*(1+beta_met*muk**2)*self.pk pk *= Gpar*Gper xi = cosmo_model.Pk2Xi(r,mur,self.k,pk,ell_max=self.ell_max) xi *= ((1+zeff)/(1+self.zref))**((alpha_lya-1)*(alpha_met-1)) self.prev_xi_lya_met["LYA_"+met] = self.dmat["LYA_"+met].dot(xi) if self.hcds_mets: recalc = self.prev_pmet["beta_lls"] != beta_lls\ or self.prev_pmet["L0_lls"] != L0_lls if recalc: pk = (1+beta_lls*muk**2)*(1+beta_met*muk**2)*self.pk*Flls pk *= Gpar*Gper xi = cosmo_model.Pk2Xi(r,mur,self.k,pk,ell_max=self.ell_max) xi *= ((1+zeff)/(1+self.zref))**((alpha_lya-1)*(alpha_met-1)) self.prev_xi_dla_met[met] = xi xi_lya_met += bias_lya*bias_met*self.prev_xi_lya_met["LYA_"+met] if self.hcds_mets: xi_lya_met += bias_lls*bias_met*self.prev_xi_dla_met[met] xi_met_met = sp.zeros(nbins) for i,met1 in enumerate(self.met_names): bias_met1 = pars['bias_'+met1] beta_met1 = pars['beta_'+met1] alpha_met1 = pars["alpha_"+met1] for met2 in self.met_names[i:]: rt = self.auto_rt[met1+"_"+met2] rp = self.auto_rp[met1+"_"+met2] zeff = self.auto_zeff[met1+"_"+met2] bias_met2 = pars['bias_'+met2] beta_met2 = pars['beta_'+met2] alpha_met2 = pars["alpha_"+met2] dm = self.dmat[met1+"_"+met2] recalc = beta_met1 != self.prev_pmet["beta_"+met1]\ or beta_met2 != self.prev_pmet["beta_"+met2] if recalc: if self.verbose: print("recalculating ",met1,met2) r = sp.sqrt(rt**2+rp**2) w=r==0 r[w]=1e-6 mur = rp/r pk = (1+beta_met1*muk**2)*(1+beta_met2*muk**2)*self.pk pk *= Gpar*Gper xi = cosmo_model.Pk2Xi(r,mur,self.k,pk,ell_max=self.ell_max) xi *= ((1+zeff)/(1+self.zref))**((alpha_met1-1)*(alpha_met2-1)) self.prev_xi_met_met[met1+"_"+met2] = self.dmat[met1+"_"+met2].dot(xi) xi_met_met += bias_met1*bias_met2*self.prev_xi_met_met[met1+"_"+met2] for i in self.prev_pmet: self.prev_pmet[i] = pars[i] return xi_lya_met + xi_met_met