def halocat_init(halo_catalog, z_median): """ Initial population of halo catalog using populate_mock function Parameters ---------- halo_catalog: string Path to halo catalog z_median: float Median redshift of survey Returns --------- model: halotools model instance Model based on behroozi 2010 SMHM """ halocat = CachedHaloCatalog(fname=halo_catalog, update_cached_fname=True) """ prim_haloprop_key : String giving the column name of the primary halo property governing stellar mass. """ model = PrebuiltSubhaloModelFactory('behroozi10', redshift=z_median, \ prim_haloprop_key='halo_macc') model.populate_mock(halocat, seed=5) return model
def populate_mock(key,halocat): """ Populates mock halo catalog with galaxies using Behroozi 2010 relation Parameters ---------- key: string Halo mass property used to populate mock (halo_mvir or halo_macc) halocat: hdf5 file Mock halo catalog Returns --------- model: subhalo-based composite model """ model = PrebuiltSubhaloModelFactory('behroozi10',redshift=0.0186,\ prim_haloprop_key=key) model.populate_mock(halocat) return model
def halocat_init(halo_cat, z): """ Initial population of halo catalog using populate_mock function Parameters ---------- halo_cat: string Path to halo catalog z: float Median redshift of survey Returns --------- model: halotools model instance Model based on behroozi 2010 SMHM """ halocat = CachedHaloCatalog(fname=halo_cat, update_cached_fname=True) model = PrebuiltSubhaloModelFactory('behroozi10', redshift=z, \ prim_haloprop_key='halo_macc') model.populate_mock(halocat, seed=5) return model
(eco_buff.logmstar.values >= 8.9)] cvar = 0.125 volume = 151829.26 # Survey volume without buffer [Mpc/h]^3 # BMF eco_nobuff_mstellar = eco_nobuff.logmstar.values eco_nobuff_mgas = eco_nobuff.logmgas.values eco_nobuff_mbary = calc_bary(eco_nobuff_mstellar, eco_nobuff_mgas) maxis, phi, err, bins = diff_bmf(eco_nobuff_mbary, volume, cvar, False) halocat = CachedHaloCatalog(fname=halo_catalog, update_cached_fname=True) z_model = np.median(eco_nobuff.grpcz.values) / (3 * 10**5) model = PrebuiltSubhaloModelFactory('behroozi10', redshift=z_model, prim_haloprop_key='halo_macc') model.populate_mock(halocat) # ensure reproducibility rseed = 12 np.random.seed(rseed) behroozi10_param_vals = [12.35,10.72,0.44,0.57,0.15] nwalkers = 250 ndim = 5 p0 = behroozi10_param_vals + 0.1*np.random.rand(ndim*nwalkers).\ reshape((nwalkers,ndim)) with Pool(processes=20) as pool: sampler = emcee.EnsembleSampler(nwalkers, ndim, lnprob, args=(phi, err)\ ,pool=pool) start = time.time()
prim_haloprop_key='halo_macc') model5 = PrebuiltSubhaloModelFactory('behroozi10', redshift=z_median, prim_haloprop_key='halo_macc') print('Setting up halocats') ###Halocats halocat1 = CachedHaloCatalog(fname=halo_catalog) halocat2 = CachedHaloCatalog(fname=halo_catalog) halocat3 = CachedHaloCatalog(fname=halo_catalog) halocat4 = CachedHaloCatalog(fname=halo_catalog) halocat5 = CachedHaloCatalog(fname=halo_catalog) print('Initial mock population') ###Populate mocks model1.populate_mock(halocat1) model2.populate_mock(halocat2) model3.populate_mock(halocat3) model4.populate_mock(halocat4) model5.populate_mock(halocat5) def gals(Mhalo_value, Mstellar_value, Mlow_slope, Mhigh_slope, Mstellar_scatter): ###Parameter values model1.param_dict['smhm_m1_0'] = Mhalo_value model2.param_dict['smhm_m0_0'] = Mstellar_value model3.param_dict['smhm_beta_0'] = Mlow_slope model4.param_dict['smhm_delta_0'] = Mhigh_slope model5.param_dict['scatter_model_param1'] = Mstellar_scatter