# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda env:hodemulator]
#     language: python
#     name: conda-env-hodemulator-py
# ---

# Working out the bugs in my new object that implements assembly bias in a continuous way. 

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.658, 1.0]}

cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!

cat.load(1.0, HOD='redMagic')#, hod_kwargs = {'sec_haloprop_key':'halo_log_nfw_conc'})#, hod_kwargs={'split': 0.5})

cat.model.param_dict

fiducial_point = {'logM0': 12.20, 'logM1': 13.7, 'alpha': 1.02,
                      'logMmin': 12.1, 'f_c': 0.19, 'sigma_logM': 0.46}

rp_bins = np.logspace(-1,1.25,15)
pi_max = 40

hod_params = dict(fiducial_point)

# +
n_pops = 2000
wp_vals = np.zeros((n_pops, rp_bins.shape[0]-1))

for i in xrange(n_pops):
    if i%10==0:
        print i
    cat.populate(hod_params)
    wp_vals[i,:] = cat.calc_wp(rp_bins, pi_max, n_cores = 1)

# -

sns.set_style("darkgrid", {"axes.facecolor": "0.85"})

rbc = (rp_bins[1:]+rp_bins[:-1])/2

print rbc

from scipy.stats import normaltest, skewtest, kurtosistest
for i in xrange(wp_vals.shape[1]):
    plt.hist(np.log10(wp_vals[:,i]), bins = int(np.ceil(np.sqrt(1000)) ));
    stat, p = normaltest(np.log10(wp_vals[:,i]) )
    z, ps = skewtest(np.log10(wp_vals[:,i]))
    z, pk = kurtosistest(np.log10(wp_vals[:,i]))
    plt.title(r"$r = %.2f\; $Mpc$ \;\; p=%.2f,%.2f,%.2f $"%(rbc[i], p, ps, pk) )
    plt.show()

sat, p = normaltest(np.log10(wp_vals))
print p



StarcoderdataJupyterScriptsDedupFiltered