In [7]:
import os
import time
import numpy as np 
from halotools.sim_manager import CachedHaloCatalog
from halotools.empirical_models import PrebuiltHodModelFactory
from halotools.mock_observables import tpcf
from halotools.empirical_models.factories.mock_helpers import three_dim_pos_bundle
import matplotlib.pyplot as plt
from ChangTools.plotting import prettyplot
from ChangTools.plotting import prettycolors
%matplotlib inline
from ccppabc.code import util

Calculate $f_{sat}$ for the Entire MultiDark Volume


In [19]:
# initialize hod model
model = PrebuiltHodModelFactory('zheng07', threshold=-21)
halocat = CachedHaloCatalog(simname='multidark', redshift=0, halo_finder='rockstar')
model.populate_mock(halocat, enforce_PBC=False)

In [20]:
N_sat = len(np.where(model.mock.galaxy_table['gal_type'] == 'satellites')[0])
N_gal = len(model.mock.galaxy_table['gal_type'])

In [21]:
print 'f_sat = ', np.float(N_sat)/np.float(N_gal)


f_sat =  0.19601096285

Note that changing the PBC condition enforce_PBC option does not change the $f_{sat}$ value.

Calculate $f_{sat}$ for MultiDark Subvolumes


In [8]:
sub_model = PrebuiltHodModelFactory('zheng07', threshold=-21)
sub_model.new_haloprop_func_dict = {'sim_subvol': util.mk_id_column}
sub_halocat = CachedHaloCatalog(simname = 'multidark', redshift = 0, halo_finder = 'rockstar')

In [12]:
for rint in range(10): 
    simsubvol = lambda x: util.mask_func(x, rint)
    sub_model.populate_mock(sub_halocat, masking_function=simsubvol, enforce_PBC=False)
    
    sub_N_sat = len(np.where(sub_model.mock.galaxy_table['gal_type'] == 'satellites')[0])
    sub_N_gal = len(sub_model.mock.galaxy_table['gal_type'])
    
    print 'f_sat = ', np.float(sub_N_sat)/np.float(sub_N_gal)


f_sat =  0.193605683837
f_sat =  0.197640117994
f_sat =  0.215766572818
f_sat =  0.197692547552
f_sat =  0.191043908113
f_sat =  0.195686556434
f_sat =  0.180606838979
f_sat =  0.208470290771
f_sat =  0.193892250072
f_sat =  0.193915801615

Consistent with the entire volume $f_{sat}$