import numpy as np from .constants import * # ----------------------------------------------------------------------------- # Generic profile generator # ----------------------------------------------------------------------------- class KSZ_Profile(object): R_star= 0.015 # 15 kpc/h L_gal0 = 10**(0.4*(tmpp_cat['Msun']-tmpp_cat['Mstar'])) def __init__(self): self.rGalaxy = 1.0 def evaluate_profile(self, r): raise NotImplementedError("Abstract function") def projected_profile(self, cos_theta,angularDistance): idx_base = idx = np.where(cos_theta > 0)[0] tan_theta_2 = 1/(cos_theta[idx]**2) - 1 tan_theta_2_max = (self.rGalaxy/angularDistance)**2 tan_theta_2_min = (self.R_star/angularDistance)**2 idx0 = np.where((tan_theta_2 < tan_theta_2_max)) idx = idx_base[idx0] tan_theta_2 = tan_theta_2[idx0] tan_theta = np.sqrt(tan_theta_2) r = (tan_theta*angularDistance) m,idx_mask = self.evaluate_profile(r) idx_mask = idx[idx_mask] idx_mask = np.append(idx_mask,idx[np.where(tan_theta_2 0: idx_mask = np.append(idx_mask,idx[tan_theta_2.argmin()]) return idx,idx_mask,m # ----------------------------------------------------------------------------- # Isothermal profile generator # ----------------------------------------------------------------------------- class KSZ_Isothermal(KSZ_Profile): sigma_FP=160e3 #m/s R_innergal = 0.226 def __init__(self, Lgal, x, y=0.0): "Support for Isothermal profile" super(KSZ_Isothermal,self).__init__() self.R_gal = 0.226 * x self.R_innergal *= y self.rho0 = self.sigma_FP**2/(2*np.pi*G) # * (Lgal/L_gal0)**(2./3) self.rGalaxy = self.R_gal*(Lgal/self.L_gal0)**(1./3) self.rInnerGalaxy = self.R_innergal*(Lgal/self.L_gal0)**(1./3) # self._prepare() def _prepare(self, x_min, x_max): from scipy.integrate import quad from numpy import sqrt, log10 lmin = log10(x_min) lmax = log10(x_max) x = 10**(np.arange(100)*(lmax-lmin)/100.+lmin) profile = np.empty(x.size) nu_tilde = lambda u: (1/(u**2*(1+u))) for i in range(x.size): profile[i] = 2*quad(lambda y: (nu_tilde(sqrt(x[i]**2+y**2))), 0, args.x)[0] self._table = x,profile def evaluate_profile(self,r): rho0, rGalaxy, rInner = self.rho0, self.rGalaxy, self.rInnerGalaxy Q=rho0*2/r*np.arctan(np.sqrt((rGalaxy/r)**2 - 1))/Mpc # Q[r