<jupyter_start><jupyter_text>I've been given a new task to study how scale dependent bias varias as a function of HOD params and<jupyter_code>from pearce.mocks.kittens import cat_dict
import numpy as np
from scipy.stats import binned_statistic, linregress
from matplotlib import pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5})
cosmo_params = {'simname':'chinchilla', 'Lbox':400.0, 'scale_factors':[0.81120]}
cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!
cat.load(0.81120, tol = 0.01, HOD='redMagic', particles = True)#, hod_kwargs = {'sec_haloprop_key':'halo_log_nfw_conc'})#, hod_kwargs={'split': 0.5})
chain_fname = '/u/ki/swmclau2/des/PearceMCMC/200_walkers_50000_steps_chain_redmagic_bias_z0.23.npy'
chain = np.genfromtxt(chain_fname)<jupyter_output><empty_output><jupyter_text>chain = chain[chain[:,0] >=-1.0]chain = chain[chain[:, -1] <=0.5]<jupyter_code>n_walkers = 200
n_params = chain.shape[1]
n_burn = 30000
chain = chain[n_walkers*n_burn:, :]
print chain.shape
ordered_param_names = param_names = ['logMmin', 'f_c', 'logM0', 'sigma_logM',  'logM1',   'alpha']<jupyter_output><empty_output><jupyter_text>ordered_param_names = ['mean_occupation_satellites_assembias_param1','logMmin',                       'mean_occupation_centrals_assembias_param1','logM1',                       'logM0','sigma_logM', 'alpha',   'f_c']<jupyter_code>rbins = np.logspace(-1,1.5,15)
rbc = (rbins[1:]+rbins[:-1])/2<jupyter_output><empty_output><jupyter_text>biases = []indicies = np.random.choice(chain.shape[0], size = 1000, replace = False)for i, row in enumerate(chain[indicies]):    print i    hod_params = dict(zip(ordered_param_names, row))    cat.populate(hod_params)    bias = cat.calc_bias(rbins, use_corrfunc = False)    biases.append(bias)    plt.plot(rbc, bias, alpha = 0.1, color = 'b') xis = []indicies = np.random.choice(chain.shape[0], size = 100, replace = False)for i, row in enumerate(chain[indicies]):    print i    hod_params = dict(zip(ordered_param_names, row))    hod_params['mean_occupation_centrals_assembias_param1'] = -1.0    hod_params['mean_occupation_satellites_assembias_param1'] = 0.0    cat.populate(hod_params)    xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)    print xi    xis.append(xi)    plt.plot(rbc, bias, alpha = 0.1, color = 'b') for xi in xis:        plt.plot(rbc, xi/xi_mm, alpha = 0.1, color = 'b')plt.xscale('log')plt.xlabel(r'$r$ [Mpc]')plt.ylabel(r'$\xi_{gg}/\xi_{mm}(r)$')plt.ylim([0.0, 2.0])plt.xlim([1e0, 40])plt.title(r"$\mathcal{A}_{cen}$ = %.1f, $\mathcal{A}_{sat}$ = %.1f"%(hod_params['mean_occupation_centrals_assembias_param1'],hod_params['mean_occupation_satellites_assembias_param1']))plt.show() xis = []indicies = np.random.choice(chain.shape[0], size = 100, replace = False)for i, row in enumerate(chain[indicies]):    ab_xis = []    print i    for a_cen, a_sat in [(0.0, 0.0), (1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0)]:        hod_params = dict(zip(ordered_param_names, row))        hod_params['mean_occupation_centrals_assembias_param1'] = a_cen        hod_params['mean_occupation_satellites_assembias_param1'] = a_sat        cat.populate(hod_params)        xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)        ab_xis.append(xi)    xis.append(ab_xis)    plt.plot(rbc, bias, alpha = 0.1, color = 'b') for j, xi in enumerate(xis):    for i, (ab_xi, c) in enumerate(zip(xi, ['b', 'r', 'g', 'm', 'k']) ):        if i > 3:            continue        if j == 0:            if i == 0:                plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'No AB')            if i==1:                plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'Positive AB')            if i == 2:                plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'Negative AB')                        else:            plt.plot(rbc, ab_xi/xi_mm, alpha = 0.05, color = c)plt.xscale('log')plt.xlabel(r'$r$ [Mpc]')plt.ylabel(r'$\xi_{gg}/\xi_{mm}(r)$')plt.ylim([0.0, 2.0])plt.xlim([1e0, 40])plt.legend(loc='best')plt.title(r"Maximal AB Values")plt.show()<jupyter_code>xis = []
indicies = np.random.choice(chain.shape[0], size = 1000, replace = False)
for i, row in enumerate(chain[indicies]):
    print i
    try:
        hod_params = dict(zip(ordered_param_names, row))
        cat.populate(hod_params)
        xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)
        xis.append(xi)
    except MemoryError:
        continue
    #plt.plot(rbc, bias, alpha = 0.1, color = 'b')
for xi in xis:
        plt.plot(rbc, xi, alpha = 0.01, color = 'g')

plt.loglog()
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$\xi_{gg}(r)$')
#plt.ylim([-5, 20])
plt.xlim([1e0, 40])
plt.title(r"Allowed biases from Buzzard Y3 $w(\theta)$")
plt.show()
xi_mm = cat.calc_xi_mm(rbins)
plt.plot(rbc, xi_mm)
plt.plot(rbc, xi)
plt.loglog();
for xi in xis:
        plt.plot(rbc, xi/xi_mm, alpha = 0.01, color = 'b')

plt.xscale('log')
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$\xi_{gg}/\xi_{mm}(r)$')
#plt.ylim([-5, 20])
plt.xlim([1e0, 40])
plt.title(r"Allowed biases from AB chains")
plt.show()
xis = np.array(xis)
xis.shape
plt.hist(np.sqrt(xis[:,-1]/xi_mm[-1]), color = 'g', bins =10, normed = True);
plt.xlabel(r"$b$")
plt.ylabel(r"P($b$)")
plt.title("Posterior histrogram of linear biases AB chain")<jupyter_output><empty_output><jupyter_text>colors = sns.diverging_palette(80, 190,l= 80, n=N)sns.palplot(colors)<jupyter_code>fig = plt.figure(figsize=(10,8))
for label, value, c in zip(varied_param_vals, bias_vals, colors):
    plt.plot(rbc, value, label = r'$\log{M_{min}}= %.1f$'%label, color = c)
    
plt.xscale('log')
plt.legend(loc = 'best')
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$b(r)$')
plt.title(r'Bias as a function of Central Log M Min $\log{M_{min}}$')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1794478527607362, 'fraction_numerical': 0.03169734151329243, 'mean_word_length': 4.424214417744917, 'pattern_counts': {'":': 1, '<': 22, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '343986', 'license': 'MIT', 'n_tokens_mistral': 2531, 'n_tokens_neox': 2388, 'n_words': 434, 'path': 'notebooks/b(r,HOD) from Chains.ipynb', 'repo_name': 'mclaughlin6464/pearce', 'size': '5868'}