def test_massfn(): from szar import counts import hmf from cluster_toolkit import massfunction zs = np.linspace(0.,3.,20) ms = np.geomspace(1e14,1e17,200) ks = np.geomspace(1e-3,10,101) from enlib import bench with bench.show("init"): hcos = hm.HaloModel(zs,ks,ms=ms,mass_function="tinker") dndM_ct2 = np.zeros((zs.size,ms.size)) for i,z in enumerate(zs): h = hmf.MassFunction(z=z,Mmin=np.log10(ms.min()*hcos.h),Mmax=np.log10(ms.max()*hcos.h)) if i==0: dndM_ct = np.zeros((zs.size,h.dndm.size)) dndM_ct[i,:] = h.dndm.copy() dndM_ct2[i,:] = massfunction.dndM_at_M(ms*hcos.h, hcos.ks_sigma2/hcos.h, hcos.sPzk[i]*hcos.h**3, hcos.om0) fsky = 0.4 hmf = counts.Halo_MF(counts.ClusterCosmology(hcos.params,skipCls=True),np.log10(ms),zs) nz_szar = hmf.N_of_z()*fsky print(nz_szar,nz_szar.shape) # sys.exit() print(hcos.nzm.shape,hcos.bh.shape) bh = hcos.bh nzm = hcos.nzm # ims,ins = np.loadtxt("data/tinker2008Fig5.txt",unpack=True,delimiter=',') # pl = io.Plotter(xyscale='linlin') # pl.add(ims,ins,ls="--") # pl.add(np.log10(ms*hcos.h),np.log10(nzm[0,:]*ms**2./hcos.rho_matter_z(0.))) # pl.done() chis = hcos.results.angular_diameter_distance(hcos.zs) * (1+hcos.zs) nz = np.trapz(nzm,ms,axis=-1)*4.*np.pi*chis**2./hcos.results.h_of_z(hcos.zs)*fsky nz_ct = np.trapz(dndM_ct,h.m,axis=-1)*4.*np.pi*chis**2./hcos.results.h_of_z(hcos.zs)*fsky * hcos.h**3. nz_ct2 = np.trapz(dndM_ct2,ms,axis=-1)*4.*np.pi*chis**2./hcos.results.h_of_z(hcos.zs)*fsky * hcos.h**3. pl = io.Plotter() pl.add(zs,nz,label='hmvec') pl.add(hmf.zarr,nz_szar,ls='--',label='szar') pl.add(zs,nz_ct,ls='-.',label='hmf') pl.add(zs,nz_ct2,ls='-.',label='ct') pl.done() n = np.trapz(nz,zs) print(n) n = np.trapz(nz_szar,hmf.zarr) print(n) n = np.trapz(nz_ct,zs) print(n) n = np.trapz(nz_ct2,zs) print(n)
def setup_class(self): self.wdm = wdm.MassFunctionWDM( alter_model=wdm.Schneider12_vCDM, wdm_mass=3.0, wdm_model=wdm.Viel05, transfer_model="EH", ) self.cdm = hmf.MassFunction(transfer_model="EH")
def hmf_massfunc(self, z=0.0): """ Halo mass function as a `~hmf.MassFunction` instance. """ if not hasattr(self, "_hmf_massfunc"): h = COSMO.h cosmo = COSMO._cosmo self._hmf_massfunc = hmf.MassFunction( Mmin=np.log10(self.M_min*h), Mmax=np.log10(self.M_max*h), dlog10m=self.M_step, hmf_model=self.hmf_model, cosmo_model=cosmo, n=COSMO.ns, sigma_8=COSMO.sigma8) logger.info("Initialized '%s' halo mass function." % self.hmf_model) massfunc = self._hmf_massfunc massfunc.update(z=z) return massfunc
def setup_class(self): self.cdm = hmf.MassFunction() self.cls = wdm.Schneider12(m=self.cdm.m, dndm0=self.cdm.dndm)
def setup_class(self): self.cdm = hmf.MassFunction(transfer_model="EH") self.cls = wdm.Lovell14(m=self.cdm.m, dndm0=self.cdm.dndm,)
def setup_class(self): self.cdm = hmf.MassFunction(transfer_model="EH") self.cls = wdm.Schneider12(m=self.cdm.m, dndm0=self.cdm.dndm,)
def test_incorrect_argument(): with raises(TypeError): hmf.MassFunction(wrong_arg=3)
def setup_class(self): self.wdm = wdm.MassFunctionWDM(alter_model=None, wdm_mass=3.0, wdm_model=wdm.Viel05) self.cdm = hmf.MassFunction()
def hmf_calc(self, Mmin=10, Mmax=16, dlog10m=1e-3, ext='csv', sep=',', return_path=False, print_path=False): """ Creates file with the desired mass function, and extract the information with the MF. Parameters ----------- Mmin: float, optional (default = 10) minimum halo mass to evaluate Mmax: float, optional (default = 15) maximum halo mass to evaluate dlog10m: float, optional (default = 1e-2) hmf_model: string, optional (default = 'warren') Halo Mass Function choice Options: - 'warren': Uses Warren et al. (2006) HMF = 'tinker08': Uses Tinker et al. (2008) HMF ext: string, optional (default = 'csv') extension of output file sep: string, optional (default = ',') delimiter used for reading/writing the file return_path : `bool`, optional If True, it returns the path of the HMF file. This variable is set to ``False`` by default. print_path : `bool` If True, it prints out the path of the HMF file. This variable is set to ``False`` by default. Return -------- hfm_pd : `pandas.DataFrame` DataFrame containing the ``log10 masses`` and ``cumulative number densities`` for haloes of mass larger than `M`. hmf_outfile : `str`, optional If True, it returns the path to the HMF file used in this analysis. This variable is set to ``False`` by default. """ # Cosmological model cosmo_model = self.cosmo_create() # HMF Output file hmf_outfile = os.path.join( self.mass_func_output_dir(create_dir=True), '{0}_H0_{1}_HMF_{2}.{3}'.format(self.cosmo_choice, cosmo_model.H0.value, self.hmf_model, ext)) # Removing file if necessary if os.path.exists(hmf_outfile): os.remove(hmf_outfile) # Halo mass function - Fitting function if (self.hmf_model == 'warren'): hmf_choice_fit = hmf.fitting_functions.Warren if (self.hmf_model == 'tinker08'): hmf_choice_fit = hmf.fitting_functions.Tinker08 # # Calculating HMF mf_func = hmf.MassFunction(Mmin=Mmin, Mmax=Mmax, dlog10m=dlog10m, cosmo_model=cosmo_model, hmf_model=hmf_choice_fit) # HMF - Pandas DataFrame mf_pd = pd.DataFrame({ 'logM': num.log10(mf_func.m), 'ngtm': mf_func.ngtm }) # Saving to output file mf_pd.to_csv(hmf_outfile, sep=sep, index=False, columns=['logM', 'ngtm']) # Output path if print_path: print('>> HMF File: {0}'.format(hmf_outfile)) if not return_path: return mf_pd else: return mf_pd, hmf_outfile
# Constants ##################### luminosity_of_sun = 3.8 * 10**26 # Watt volume = 160**3 # (c Mpc / h)^3 c = 3 * 10**8 c2_line_frequency = c / (158 * 10**-6) # s^(-1) omega_m = 0.308 omega_lambda = 0.692 H0 = 67.8 * 10**3 / (3.086 * 10**22) # s^(-1) #-------------------- ######################################################### # Array definitions ######################################################### redshift = np.arange(6, 10.5, 0.1) halo_mass_function = hmf.MassFunction(Mmin=8, Mmax=13, sigma_8=0.829, n=0.961) star_formation_rate_density_at_z = np.zeros(len(redshift)) star_formation_rate_at_z = np.zeros(len(redshift)) log_luminosity_at_z = np.zeros(len(redshift)) luminosity_at_z = np.zeros(len(redshift)) intensity_at_z = np.zeros(len(redshift)) #------------------------------------------------------------ ############################################################### # Data points from the top panel of figure 1 of Dumitru et al. 2018 ############################################################### data_redshift, data_sfrd = np.loadtxt("sfrd_data_points_dumitru_fig_1.txt", unpack=True) data_sfrd = 10**data_sfrd #---------------------------------------------------------------
def main(argv=None): '''Generate halo mass functions and write them to file (BETA).''' if argv is None: argv = sys.argv else: sys.argv.extend(argv) program_name = os.path.basename(sys.argv[0]) program_version = "v%s" % __version__ program_build_date = str(__updated__) program_version_message = '%%(prog)s %s (%s)\n\nHISTORY\n------%s' % (program_version, program_build_date, HISTORY) program_shortdesc = __import__('__main__').__doc__.split("\n")[1] program_license = '''%s Copyright (c) 2014 Steven Murray Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. USAGE ''' % (program_shortdesc) try: h = hmf.MassFunction() m_attrs = ["dndlog10m", "lnsigma", "n_eff", "sigma", "dndm", "ngtm", "fsigma", "mgtm", "nltm", "dndlnm", "how_big", "mltm", "_sigma_0", "_dlnsdlnm"] k_attrs = ["power", "delta_k", "transfer", "nonlinear_power", "_lnP_0", "_lnP_cdm_0", "_lnT_cdm", "_unnormalised_lnP", "_unnormalised_lnT"] # Setup argument parser parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter) parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]") parser.add_argument('-V', '--version', action='version', version=program_version_message) # HMF specific arguments config = parser.add_argument_group("Config", "Variables of Configuration") config.add_argument("--max-diff-tol", type=float, default=100.0, help="Minimum maximum diff to write out") config.add_argument("--rms-diff-tol", type=float, default=100.0, help="Minimum rms diff to write out") config.add_argument("filename", help="the filename to write to") # config.add_argument("filename", help="filename to write to") config.add_argument("--quantities", nargs="*", default=["dndm"], choices=m_attrs + k_attrs) accuracy_args = parser.add_argument_group("Accuracy Args", "Arguments affecting the accuracy of output") # accuracy_args.add_argument("--M-min", nargs="*", type=float, # help="minimum log10 M [default: %s]" % # np.log10(h.M[0])) # accuracy_args.add_argument("--M-max", nargs="*", type=float, # help="maximum log10 M [default: %s]" % # np.log10(h.M[-1])) # accuracy_args.add_argument("--M-num", nargs="*", type=int, # help="length of M vector [default: %s]" % # len(h.M)) accuracy_args.add_argument("--lnk-min", nargs="*", type=float, help="the maximum wavenumber [default: %s]" % h.transfer.lnk[0]) accuracy_args.add_argument("--lnk-max", nargs="*", type=float, help="the minimum wavenumber [default: %s]" % h.transfer.lnk[0]) accuracy_args.add_argument("--lnk-num", nargs="*", type=int, help="the number of wavenumber [default: %s]" % len(h.transfer.lnk)) accuracy_args.add_argument("--lAccuracyBoost", nargs="*", type=float, help="[CAMB] optional accuracy boost [default: %s]" % h.transfer._camb_options["lAccuracyBoost"]) accuracy_args.add_argument("--AccuracyBoost", nargs="*", type=float, help="[CAMB] optional accuracy boost [default: %s]" % h.transfer._camb_options["AccuracyBoost"]) accuracy_args.add_argument("--transfer--k-per-logint", nargs="*", type=float, help="[CAMB] number of estimated wavenumbers per interval [default: %s]" % h.transfer._camb_options["transfer__k_per_logint"]) accuracy_args.add_argument("--transfer--kmax", nargs='*', type=float, help="[CAMB] maximum wavenumber to estimate [default: %s]" % h.transfer._camb_options["transfer__kmax"]) accuracy_args.add_argument("--mv-scheme", nargs="*", choices=['trapz', 'simps', 'romb']) hmfargs = parser.add_argument_group("HMF", "HMF-specific arguments") hmfargs.add_argument("--mf-fit", choices=hmf.Fits.mf_fits, help="fitting function to use. 'all' uses all of them [default: %s]" % h.mf_fit) hmfargs.add_argument("--delta-h", type=float, help="overdensity of halo w.r.t delta_wrt [default %s]" % h.delta_wrt) hmfargs.add_argument("--delta-wrt", choices=["mean", "crit"], help="what delta_h is with respect to [default: %s]" % h.delta_h) hmfargs.add_argument("--no-cut-fit", action="store_true", help="whether to cut the fitting function at tested boundaries") hmfargs.add_argument("--z2", type=float, help="upper redshift for volume weighting") hmfargs.add_argument("--nz", type=float, help="number of redshift bins for volume weighting") hmfargs.add_argument("--delta-c", type=float, help="critical overdensity for collapse [default: %s]" % h.delta_c) # # Transfer-specific arguments transferargs = parser.add_argument_group("Transfer", "Transfer-specific arguments") transferargs.add_argument("--z", type=float, help="redshift of analysis [default: %s]" % h.transfer.z) transferargs.add_argument("--wdm-mass", type=float, help="warm dark matter mass (0 is CDM)") transferargs.add_argument("--transfer-fit", choices=hmf.transfer.Transfer.fits, help="which fit for the transfer function to use ('all' uses all of them) [default: %s]" % h.transfer.transfer_fit) cambargs = parser.add_argument_group("CAMB", "CAMB-specific arguments") cambargs.add_argument("--Scalar-initial-condition", type=int, choices=[1, 2, 3, 4, 5], help="[CAMB] initial scalar perturbation mode [default: %s]" % h.transfer._camb_options["Scalar_initial_condition"]) cambargs.add_argument("--ThreadNum", type=int, help="number of threads to use (0 is automatic detection) [default: %s]" % h.transfer._camb_options["ThreadNum"]) cambargs.add_argument("--w-perturb", action="store_true", help="[CAMB] whether w should be perturbed or not") # # Cosmo-specific arguments cosmoargs = parser.add_argument_group("Cosmology", "Cosmology arguments") cosmoargs.add_argument("--default", choices=['planck1_base'], help="base cosmology to use [default: %s]" % h.transfer.cosmo.default) cosmoargs.add_argument("--force-flat", action="store_true", help="force cosmology to be flat (changes omega_lambda) [default: %s]" % h.transfer.cosmo.force_flat) cosmoargs.add_argument("--sigma-8", type=float, help="mass variance in top-hat spheres with r=8") cosmoargs.add_argument("--n", type=float, help="spectral index") cosmoargs.add_argument("--w", type=float, help="dark energy equation of state") cosmoargs.add_argument("--cs2-lam", type=float, help="constant comoving sound speed of dark energy") h_group = cosmoargs.add_mutually_exclusive_group() h_group.add_argument("--h", type=float, help="The hubble parameter") h_group.add_argument("--H0", type=float, help="The hubble constant") omegab_group = cosmoargs.add_mutually_exclusive_group() omegab_group.add_argument("--omegab", type=float, help="baryon density") omegab_group.add_argument("--omegab-h2", type=float, help="baryon density by h^2") omegac_group = cosmoargs.add_mutually_exclusive_group() omegac_group.add_argument("--omegac", type=float, help="cdm density") omegac_group.add_argument("--omegac-h2", type=float, help="cdm density by h^2") omegac_group.add_argument("--omegam", type=float, help="total matter density") cosmoargs.add_argument("--omegav", type=float, help="the dark energy density") # Process arguments args = parser.parse_args() # # Process the arguments kwargs = {} for arg in ["omegab", "omegab_h2", "omegac", "omegac_h2", "omegam", "h", "H0", "sigma_8", "n", "w", "cs2_lam", "omegav", "ThreadNum", "transfer__kmax", "transfer__k_per_logint", "AccuracyBoost", "lAccuracyBoost", "Scalar_initial_condition", "z", "z2", "nz", "delta_c", "delta_h", "delta_wrt", 'mf_fit', 'transfer_fit', 'mv_scheme']: if getattr(args, arg) is not None: kwargs[arg] = getattr(args, arg) if args.w_perturb: kwargs['w_perturb'] = True if args.no_cut_fit: kwargs['cut_fit'] = not args.no_cut_fit # if args.M_min is not None and args.M_max is not None and args.M_num is not None: # kwargs["M"] = [] # for mmin in args.M_min: # for mmax in args.M_max: # for mnum in args.M_num: # kwargs["M"].append(np.linspace(mmin, mmax, mnum)) if args.lnk_min is not None and args.lnk_max is not None and args.lnk_num is not None: kwargs["lnk"] = [] for kmin in args.lnk_min: for kmax in args.lnk_max: for knum in args.lnk_num: kwargs["lnk"].append(np.linspace(kmin, kmax, knum)) m_att = [a for a in args.quantities if a in m_attrs] k_att = [a for a in args.quantities if a in k_attrs] # Set up results dictionaries results = {} for quantity in args.quantities: results[quantity] = {} times = {} # Save all the variables into dictionary/list of dicts for use listkwargs = {} for k, v in kwargs.items(): if isinstance(v, (list, tuple)): listkwargs[k] = kwargs.pop(k) # Now we have separated kwargs into listy things and singular items vallist = [v for k, v in listkwargs.iteritems()] final_list = [dict(zip(listkwargs.keys(), v)) for v in itertools.product(*vallist)] # Create a high-res object start = time.time() testbed = hmf.MassFunction(# M=np.linspace(3, 18, 5000), transfer__k_per_logint=20, transfer__kmax=100, lnk=np.linspace(-20, 20, 4097), lAccuracyBoost=2, AccuracyBoost=2, mv_scheme='romb', **kwargs) # Initialise all required quantities for quantity in m_att: getattr(testbed, quantity) for quantity in k_att: getattr(testbed.transfer, quantity) hires_time = time.time() - start print len(final_list) for vals in final_list: # We make a fresh one each time to get the timing right. kwargs.update(vals) h = hmf.MassFunction(**kwargs) if len(final_list) > 1: label = str(vals) elif kwargs: label = str(kwargs) else: label = h.mf_fit label = label.replace("{", "").replace("}", "").replace("'", "") label = label.replace("_", "").replace(": ", "").replace(", ", "_") label = label.replace("mffit", "").replace("transferfit", "").replace("delta_wrt", "").replace("\n", "") # The following lines transform the M and lnk parts while "[" in label: label = re.sub("[\[].*?[\]]", "", label) label = label.replace("array", "") label = label.replace("mvscheme", "") label = label.replace("M()", "M(" + str(np.log10(h.M[0])) + ", " + str(np.log10(h.M[-1])) + ", " + str(np.log10(h.M[1]) - np.log10(h.M[0])) + ")") label = label.replace("lnk()", "lnk(" + str(h.transfer.lnk[0]) + ", " + str(h.transfer.lnk[-1]) + ", " + str(len(h.transfer.lnk)) + ")") start = time.time() print label for att in m_att: results[att][label] = getattr(h, att) for att in k_att: results[att][label] = getattr(h.transfer, att) times[label] = time.time() - start labels = [label for label in times] # Now write out/plot results for quantity in args.quantities: if quantity in m_att: test = getattr(testbed, quantity) elif quantity in k_att: test = getattr(testbed.transfer, quantity) df = pandas.DataFrame(np.zeros((len(labels), 3)), columns=['MaxDiff', "RMSDiff", "Time"], index=labels) df["Time"] = [t for l, t in times.iteritems()] print "============ " + quantity + " ================" for label, res in results[quantity].iteritems(): # Maximum difference df["MaxDiff"][label] = np.max(np.abs(res / test - 1)) # rms difference df["RMSDiff"][label] = np.sqrt(np.mean((res / test - 1) ** 2)) df.sort("Time", inplace=True) print df[np.logical_and(df["MaxDiff"] < args.max_diff_tol, df["RMSDiff"] < args.rms_diff_tol)].to_string() with open(args.filename, 'w') as f: s = df[np.logical_and(df["MaxDiff"] < args.max_diff_tol, df["RMSDiff"] < args.rms_diff_tol)].to_string() f.write(s) return 0 except KeyboardInterrupt: ### handle keyboard interrupt ### return 0 except Exception, e: if DEBUG or TESTRUN: raise(e) traceback.print_exc() indent = len(program_name) * " " sys.stderr.write(program_name + ": " + repr(e) + "\n") sys.stderr.write(indent + " for help use --help\n") return 2
def _prepare_mf(log_mmin, **mf_kwargs): h = hmf.MassFunction(Mmin=log_mmin, **mf_kwargs) icdf = _spline((h.ngtm / h.ngtm[0])[::-1], np.log10(h.m[::-1]), k=3) return icdf, h
########################################### ######################### HOD ############# ########################################### ############ number of lens members A, B, C = 47.0, 0.85, -0.1 Nlens_fcn = lambda logM, z: amax( [A * (10**(logM - 14.0))**B * (1 + z)**C - 1.0, 1]) ###### halo mass function for lens members ###### Mmin = 13.0 ### complete for M200c>1e13 M_sun #M200c is defined by the spherical overdensity mass with respect to 200 times critical density. Mmax = 15.5 dlog10m = 0.01 Mlens_arr = arange(Mmin, Mmax, dlog10m) dndm_arr = lambda zlens: hmf.MassFunction( z=zlens, Mmin=Mmin, Mmax=Mmax, dlog10m=dlog10m).dndm ### generate N lens masses with distribution following the halo mass function dndm_arr Mlens_gen = lambda N, zlens: np.random.choice( Mlens_arr, size=N, p=dndm_arr(zlens) / sum(dndm_arr(zlens))) ############ find the rest LF, assign size ### (1) caculate an array of LF for Mlim_obs ### (2) find Mlim_hmf, which is shifting from M*+4 in rest frame to observation frame ### (3) calculate an array of LM for Mlim_hmf ### (4) cut out N_lim most massive lenses that can make into the observation ### (5) assign a size to the selected lenses based on their mass and redshift def Nlim_fcn(N, z, aMlimOBS=24.5, i=Iband): '''For one halo with N members, at redshift z, find the number of members Nlim that can make into the observed sample, where observation is conduced at aMlimOBS and i band. '''
#ax = new_3Dax(111) #ax.plot(mask[0],mask[1],mask[2],'.',markersize=0.1) #plt.show() mask = np.array(mask).T new_posh = center(mask, posh, out[1]/boxs, 1.0) mask = to_center(mask, new_posh, 1.0) ext = np.max(mask,axis=0)-np.min(mask, axis=0) reg_center = (np.max(mask,axis=0)+np.min(mask, axis=0))/2.0 + new_posh - 0.5 h_info.append([i]+[reg_center[i] for i in range(3)]+[Rtb, out[2]/1e9]+[ext[i] for i in range(3)]) print('reg_center: {}, reg_extent: {}'.format(new_posh, ext)) totxt('halo_info_'+lmodel[indm],h_info,0,0,0) import hmf import hmf.wdm hmf0 = hmf.MassFunction() hmf0.update(n=0.966, sigma_8=0.829,cosmo_params={'Om0':0.315,'H0':67.74},Mmin=4,Mmax=11) hmf1 = hmf.wdm.MassFunctionWDM() hmf1.update(n=0.966, sigma_8=0.829,cosmo_params={'Om0':0.315,'H0':67.74},Mmin=4,Mmax=11,wdm_mass=3) #HMF = 'mVector_PLANCK-z8.8 .txt' #HMF = 'mVector_PLANCK-SMT .txt' #HMF0 = 'mVector_PLANCK-SMT0 .txt' #Redf=retxt('output_25_4.txt',1,0,0)[0] fac0 = 1.0#0.208671*0.3153754*0.1948407 def halom(sn, rep ='./', indm = 0, anaf1 = hmf1, anaf0 = hmf0, mlow = 1e6, fac = fac0, edge = [0.0, 99.5], nbin = 15, boxs = 4.0 ,base = 'snapshot', ext = '.hdf5', post = 'caesar'): ds = yt.load(rep+base+'_'+str(sn).zfill(3)+ext) z = ds['Redshift']#1/Redf[sn]-1
def setup_class(self): self.cdm = hmf.MassFunction() self.cls = wdm.Lovell14(m=self.cdm.m, dndm0=self.cdm.dndm)
def setup_class(self): self.wdm = wdm.TransferWDM(wdm_mass=3.0, wdm_model=wdm.Viel05) self.cdm = hmf.MassFunction()
def test_incorrect_update_arg(): with raises(ValueError): t = hmf.MassFunction() t.update(wrong_arg=3)
data = np.loadtxt('../dat/massfn_tin_0.2000.dat') pl.loglog(data[:,0], data[:,1], label='Martin-Tinker') ''' ## ## Murray et al. hmf python code. ## ## ncosmo = FlatLambdaCDM(H0 = 73.0, Om0=0.25, Tcmb0 = 5.0, Ob0 = None) ## ncosmo = cosmo.Cosmology(cosmo_model = ncosmo) for zee in [3.0, 4.0]: pl.clf() ## Ok0': 0. for lcosmo, cosmo, lstyle in zip(['XXL', 'Planck (2018)'], [{'H0': 73., 'Om0': 0.2500, 'Ob0': 0.05 * 0.25},\ {'H0': 67.36, 'Om0': 0.3153, 'Ob0': 0.02242 / 0.6736 ** 2.}], ['-', '--']): mf = hmf.MassFunction(cosmo_params=cosmo) for label, fitting, color in zip( ['Sheth-Tormen', 'Tinker', 'Jenkins'], [ hmf.fitting_functions.ST, hmf.fitting_functions.Tinker08, hmf.fitting_functions.Jenkins ], ['b', 'r', 'g']): mf.update(z=4.0, Mmin=8., Mmax=np.log10(5.e14), hmf_model=fitting, delta_h=200., n=1.0) print mf.parameter_values ## print mf.parameter_info()
cosmo_model = LambdaCDM(H0=H0, Om0=Om0, Ob0=Ob0, Ode0=Ode0) print "" print "Cosmological model and parameter values:" print cosmo_model print "sigma_8 =", sigma_8, ", n =", n, ", transfer_model =", transfer_model # ----------------------------------------------------- # --- Create mass function. --- mf = hmf.MassFunction(Mmin=logMmin, Mmax=logMmax, z=z, hmf_model=hmf_model, delta_wrt=delta_wrt, delta_h=delta_h, cosmo_model=cosmo_model, sigma_8=sigma_8, n=n, transfer_model=transfer_model) print "" print "Mass function and parameter values:" print mf.parameter_values print "" # ----------------------------- # Different zs: #zmin = np.log10(0.01) #zmax = np.log10(2)