def __init__(self, redshift=0.0, cosmo_single_epoch=None, **kws): """ Initialization method """ self._redshift = redshift if cosmo_single_epoch is None: cosmo_single_epoch = cosmology.SingleEpoch(redshift) elif cosmo_single_epoch._redshift != redshift: cosmo_single_epoch.set_redshift(redshift) self.cosmo = cosmo_single_epoch return None
def __init__(self, redshift=0.0, cosmo_dict=None, halo_dict=None, **kws): # Hard coded, but we shouldn't expect halos outside of this range. self.redshift = redshift self.cosmo = cosmology.SingleEpoch(self.redshift, cosmo_dict) self.delta_c = self.cosmo.delta_c() mass_min = 1.0e9 mass_max = 1.0e16 mass_limit_not_set = True while mass_limit_not_set: if 0.1 * (1.0 + 0.05) < self.cosmo.nu_m(mass_min): #print "Min mass", mass_min,"too high..." mass_min = mass_min / 1.05 #print "\tSetting to",mass_min,"..." continue elif 0.1 * (1.0 - 0.05) > self.cosmo.nu_m(mass_min): #print "Min mass", mass_min,"too low..." mass_min = mass_min * 1.05 #print "\tSetting to",mass_min,"..." continue if 50.0 * (1.0 - 0.05) > self.cosmo.nu_m(mass_max): #print "Max mass", mass_max,"too low..." mass_max = mass_max * 1.05 #print "\tSetting to",mass_max,"..." continue elif 50.0 * (1.0 + 0.05) < self.cosmo.nu_m(mass_max): #print "Max mass", mass_max,"too high..." mass_max = mass_max / 1.05 #print "\tSetting to",mass_max,"..." continue mass_limit_not_set = False #print "Mass Limits:",mass_min*(0.95),"-",mass_max*(1.05) self.ln_mass_max = numpy.log(mass_max * (0.95)) self.ln_mass_min = numpy.log(mass_min * (1.05)) self._ln_mass_array = numpy.linspace( self.ln_mass_min, self.ln_mass_max, defaults.default_precision["mass_npoints"]) if halo_dict is None: halo_dict = defaults.default_halo_dict self.halo_dict = halo_dict self.stq = halo_dict["stq"] self.st_little_a = halo_dict["st_little_a"] self.c0 = halo_dict["c0"] / (1.0 + redshift) self._initialize_splines() self._normalize()
def __init__(self, redshift=0.0, cosmo_single_epoch=None, halo_dict=None, **kws): delta_list = [200, 300, 400, 600, 800, 1200, 1600, 2400, 3200] alpha_list = [0.368, 0.363, 0.385, 0.389, 0.393, 0.365, 0.379, 0.355, 0.327] beta_list = [0.589, 0.585, 0.544, 0.543, 0.564, 0.632, 0.637, 0.673, 0.702] gamma_list = [0.864, 0.922, 0.987, 1.09, 1.20, 1.34, 1.50, 1.68, 1.81] phi_list = [-0.729, -0.789, -0.910, -1.05, -1.20, -1.26, -1.45, -1.50, -1.49] eta_list = [-0.243, -0.261, -0.261, -0.273, -0.278, -0.301, -0.301, -0.319, -0.336] self._alpha0_spline = InterpolatedUnivariateSpline( numpy.log(delta_list), alpha_list) self._beta0_spline = InterpolatedUnivariateSpline( numpy.log(delta_list), beta_list) self._gamma0_spline = InterpolatedUnivariateSpline( numpy.log(delta_list), gamma_list) self._phi0_spline = InterpolatedUnivariateSpline( numpy.log(delta_list), phi_list) self._eta0_spline = InterpolatedUnivariateSpline( numpy.log(delta_list), eta_list) self._k_min = 0.001 self._k_max = 100.0 self._redshift = redshift #self.cosmo = cosmology.SingleEpoch(self._redshift, cosmo_dict) if cosmo_single_epoch is None: cosmo_single_epoch = cosmology.SingleEpoch(self._redshift) self.cosmo = cosmo_single_epoch self.cosmo.set_redshift(self._redshift) self.delta_c = self.cosmo.delta_c() if halo_dict is None: halo_dict = defaults.default_halo_dict self.halo_dict = halo_dict self.delta_v = self.halo_dict['delta_v'] if self.delta_v == -1: self.delta_v = self.cosmo.delta_v() self._set_mass_limits() self._initialize_splines() self._normalize()
def cosmology_unit_test(): import cosmology print "\n****************************" print "* *" print "* Testing Cosmology Module *" print "* *" print "****************************\n" print "Testing Single Epoch" print "****************************" ### Create single epoch cosmologies at the redshift specified ### outputs to stdout cosmo = cosmology.SingleEpoch(redshift=0.0) cosmo.write() cosmo.set_redshift(redshift=0.5) cosmo.write() cosmo.set_redshift(redshift=1.0) cosmo.write() cosmo.set_redshift(redshift=2.0) cosmo.write() cosmo.set_redshift(redshift=3.0) cosmo.write() ### Compute example multi epoch cosmologies from redshift z=0.0 to z=5.0 ### output are the computed comoving distnace as a funciton of redshift and ### several other cosmological variables (Omega_m(z), Omega_L(z), etc.) print "\nTesting Multi Epoch" print "****************************" cosmo = cosmology.MultiEpoch(z_min=0.0, z_max=5.0) z = 0.0 print( "Multi Epoch: (z, chi [Mpc/h], growth, omega_m(z), omega_l(z), " "detla_c, delta_v, sigma_8)") for z in [0.0, 0.5, 1.0, 2.0, 3.0]: print(z, cosmo.comoving_distance(z), cosmo.growth_factor(z), cosmo.omega_m(z), cosmo.omega_l(z), cosmo.delta_c(z), cosmo.delta_v(z), cosmo.sigma_r(8.0, z)) print ""
def set_cosmology(self, cosmo_dict, redshift=None): """ Reset the internal cosmology to the values in cosmo_dict and re-initialize the internal splines. Optimaly reset the internal redshift value. Args: cosmo_dict: dictionary of floats defining a cosmology. (see defaults.py for details) redshift: float redshift to compute halo model. """ if redshift==None: redshift = self._redshift self.cosmo_dict = cosmo_dict self._redshift = redshift self.cosmo = cosmology.SingleEpoch(redshift, cosmo_dict) self.delta_v = self.cosmo.delta_v() self.rho_bar = self.cosmo.rho_bar() self._h = self.cosmo.h self.c0 = self.halo_dict["c0"]/(1.0 + redshift) self.mass = mass_function.MassFunction( self._redshift, self.cosmo_dict, self.halo_dict) self._calculate_n_bar() self._initialize_halo_splines() self._initialized_h_m = False self._initialized_h_g = False self._initialized_pp_mm = False self._initialized_pp_gm = False self._initialized_pp_gg = False if self.use_camb: self.camb = camb.CambWrapper(cosmo_dict) self.camb.set_redshift(redshift) self.camb.run() self.camb.normalize(self.cosmo.sigma_8*self.cosmo._growth)
def setUp(self): cosmo_multi = cosmology.MultiEpoch(0.0, 5.0, cosmo_dict=c_dict) lens_dist = kernel.dNdzMagLim(z_min=0.0, z_max=2.0, a=2, z0=0.3, b=2) source_dist = kernel.dNdzGaussian(z_min=0.0, z_max=2.0, z0=1.0, sigma_z=0.2) lens_window = kernel.WindowFunctionGalaxy( lens_dist, cosmo_multi_epoch=cosmo_multi) source_window = kernel.WindowFunctionConvergence( source_dist, cosmo_multi_epoch=cosmo_multi) kern = kernel.Kernel(0.001*0.001*deg_to_rad, 1.0*100.0*deg_to_rad, window_function_a=lens_window, window_function_b=source_window, cosmo_multi_epoch=cosmo_multi) zheng = hod.HODZheng(hod_dict) cosmo_single = cosmology.SingleEpoch(0.0, cosmo_dict=c_dict) h = halo.Halo(input_hod=zheng, cosmo_single_epoch=cosmo_single) self.corr = correlation.Correlation(0.001, 1.0, input_kernel=kern, input_halo=h, power_spec='power_mm') self.theta_array = numpy.logspace(-3, 0, 4)*deg_to_rad
def __init__(self, redshift=0.0, cosmo_single_epoch=None, halo_dict=None, **kws): self._redshift = redshift #self.cosmo = cosmology.SingleEpoch(self._redshift, cosmo_dict) if cosmo_single_epoch is None: cosmo_single_epoch = cosmology.SingleEpoch(self._redshift) self.cosmo = cosmo_single_epoch self.cosmo.set_redshift(self._redshift) self.delta_c = self.cosmo.delta_c() if halo_dict is None: halo_dict = defaults.default_halo_dict self.halo_dict = halo_dict self.delta_v = self.halo_dict['delta_v'] if self.delta_v == -1: self.delta_v = self.cosmo.delta_v() self.stq = halo_dict["stq"] self.st_little_a = halo_dict["st_little_a"] self.c0 = halo_dict["c0"]/(1.0 + redshift) self._set_mass_limits() self._initialize_splines() self._normalize()
def __init__(self, redshift=0.0, input_hod=None, cosmo_dict=None, halo_dict=None, use_camb=False, **kws): # Hard coded, but we shouldn't expect halos outside of this range. self._k_min = 0.001 self._k_max = 100.0 ln_mass_min = numpy.log(1.0e9) ln_mass_max = numpy.log(5.0e16) self._ln_k_max = numpy.log(self._k_max) self._ln_k_min = numpy.log(self._k_min) self._ln_k_array = numpy.linspace( self._ln_k_min, self._ln_k_max, defaults.default_precision["halo_npoints"]) if cosmo_dict is None: cosmo_dict = defaults.default_cosmo_dict self.cosmo_dict = cosmo_dict if halo_dict is None: halo_dict = defaults.default_halo_dict self.halo_dict = halo_dict if redshift is None: redshift = 0.0 self._redshift = redshift self.c0 = halo_dict["c0"]/(1.0 + self._redshift) self.beta = halo_dict["beta"] # If we hard-code to an NFW profile, then we can use an analytic # form for the halo profile Fourier transform. # self.alpha = -1.0*halo_dict.dpalpha self.alpha = -1.0 self.cosmo = cosmology.SingleEpoch(self._redshift, cosmo_dict) self.delta_v = self.cosmo.delta_v() self.rho_bar = self.cosmo.rho_bar() self._h = self.cosmo._h self.mass = mass_function.MassFunction( self._redshift, cosmo_dict, halo_dict) if input_hod is None: input_hod = hod.HODZheng() self.local_hod = input_hod self.use_camb = use_camb if self.use_camb: self.camb = camb.CambWrapper(cosmo_dict) self.camb.set_redshift(redshift) self.camb.run() self.camb.normalize(self.cosmo.sigma_8*self.cosmo._growth) self._calculate_n_bar() self._initialize_halo_splines() self._initialized_h_m = False self._initialized_h_g = False self._initialized_pp_mm = False self._initialized_pp_gm = False self._initialized_pp_gg = False
#p_z=p_z/max_pz cosmo_dict = { "omega_m0": 0.3 - 4.15e-5 / 0.7**2, "omega_b0": 0.046, "omega_l0": 0.7, "omega_r0": 4.15e-5 / 0.7**2, "cmb_temp": 2.726, "h": 0.7, "sigma_8": 0.800, "n_scalar": 0.960, "w0": -1.0, "wa": 0.0 } cosmo_single_low = cosmology.SingleEpoch(redshift=0.1, cosmo_dict=cosmo_dict, with_bao=False) cosmo_single = cosmology.SingleEpoch(redshift=3.0, cosmo_dict=cosmo_dict, with_bao=False) cosmo_multi = cosmology.MultiEpoch(z_min=0.0, z_max=5.0, cosmo_dict=cosmo_dict, with_bao=False) halo_dict = { "stq": 0.3, "st_little_a": 0.707, "c0": 9., "beta": -0.13, "alpha": -1, "delta_v": -1
def setUp(self): cosmo = cosmology.SingleEpoch(0.0, cosmo_dict=c_dict) zheng = hod.HODZheng(hod_dict) self.h = halo.Halo(input_hod=zheng, cosmo_single_epoch=cosmo) self.k_array = numpy.logspace(-3, 2, 4)
def setUp(self): cosmo = cosmology.SingleEpoch(0.0, c_dict) self.mass = mass_function.MassFunction(cosmo_single_epoch=cosmo, halo_dict=h_dict) self.mass_array = numpy.logspace(9, 16, 4)
def setUp(self): self.cosmo = cosmology.SingleEpoch(redshift=0.0, cosmo_dict=c_dict)