Ejemplo n.º 1
0
    x = radius * np.cos(phi) * np.sin(theta)
    y = radius * np.sin(phi) * np.sin(theta)
    z = radius * np.cos(theta)
    xyz = np.vstack((x, y, z)).T

    pos_col_new += xyz
    pos_col_new[comm2] -= xyz[comm2]
    pos_col_new[pos_col_new >= Lbox] -= Lbox
    pos_col_new[pos_col_new <= 0.] += Lbox
    w_col_new = np.ones(pos_col_new.shape[0], dtype=pos_col_new.dtype)

plt.figure(1, figsize=(8, 6))
# random draw
#Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod,  Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(pos_col,w_col,pos_col_new,w_col_new,Lbox)

Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    pos_col, w_col, pos_vmax, w_vmax, Lbox)
plt.plot(bin_centers, np.ones(len(bin_centers)), 'k--')
plt.errorbar(bin_centers * 1.05,
             Rat_hodtrue_mean,
             yerr=Rat_hodtrue_err,
             color='dimgray',
             ls='-',
             label=r'$V_{\rm max}$',
             alpha=1.,
             fmt='o',
             capsize=4)

Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    pos_col, w_col, pos_vpeak, w_vpeak, Lbox)
plt.errorbar(bin_centers,
             Rat_hodtrue_mean,
Ejemplo n.º 2
0
    w_high = np.ones(cum_high, dtype=xyz_high.dtype)

    return xyz_low, xyz_high, w_low, w_high


xyz_col_low, xyz_col_high, w_col_low, w_col_high = get_env_pos(
    sub_id_col, SubhaloGrNr_fp, SubhaloPos_fp, GroupEnv_fp, inds_halo_fp,
    Group_M_Mean200_fp)
xyz_sfg_low, xyz_sfg_high, w_sfg_low, w_sfg_high = get_env_pos(
    sub_id_sfg, SubhaloGrNr_fp, SubhaloPos_fp, GroupEnv_fp, inds_halo_fp,
    Group_M_Mean200_fp)

for i in range(2):
    env_type = env_types[i]
    if i == 0:
        Rat_colsfg_mean, Rat_colsfg_err, Corr_mean_col, Corr_err_col, Corr_mean_sfg, Corr_err_sfg, bin_centers = get_jack_corr(
            xyz_sfg_low, w_sfg_low, xyz_col_low, w_col_low, Lbox)
    else:
        Rat_colsfg_mean, Rat_colsfg_err, Corr_mean_col, Corr_err_col, Corr_mean_sfg, Corr_err_sfg, bin_centers = get_jack_corr(
            xyz_sfg_high, w_sfg_high, xyz_col_high, w_col_high, Lbox)
    plt.errorbar(bin_centers,
                 Rat_colsfg_mean,
                 yerr=Rat_colsfg_err,
                 ls='-',
                 label=' '.join(env_type.split('_')),
                 alpha=1.,
                 fmt='o',
                 capsize=4)

    np.save(
        "../data/rat_colsfg" + env_type + snap_dir + selection + "_mean.npy",
        Rat_colsfg_mean)
Ejemplo n.º 3
0
def plot_ratio(xyz_true, w_true, xyz_hod, w_hod, Lbox, color, label):
    Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
        xyz_true, w_true, xyz_hod, w_hod, Lbox)

    if color == 'black':
        plt.plot(bin_centers,
                 Rat_hodtrue_mean,
                 color=color,
                 ls='-',
                 label=label)
        plt.fill_between(bin_centers,
                         Rat_hodtrue_mean - Rat_hodtrue_err,
                         Rat_hodtrue_mean + Rat_hodtrue_err,
                         color=color,
                         alpha=0.5)
    else:
        plt.errorbar(bin_centers,
                     Rat_hodtrue_mean,
                     yerr=Rat_hodtrue_err,
                     color=color,
                     ls='-',
                     label=label,
                     alpha=0.5,
                     fmt='o',
                     capsize=4)

    mean_val = np.mean(Rat_hodtrue_mean[np.isfinite(Rat_hodtrue_mean)
                                        & (bin_centers > 2.)])

    print('mean_val = ', mean_val)
    x = np.linspace(2, 10, 3)
    plt.plot(bin_centers, np.ones(len(bin_centers)), 'k--')
    plt.plot(x, np.ones(len(x)) * mean_val, color=color, ls='--', lw=1.5)
Ejemplo n.º 4
0
phi = np.random.rand(N_gal) * 2 * np.pi
radius = choices(population, weights, k=N_gal)
x = radius * np.cos(phi) * np.sin(theta)
y = radius * np.sin(phi) * np.sin(theta)
z = radius * np.cos(theta)
xyz = np.vstack((x, y, z)).T

pos_col_new += xyz
pos_col_new[comm2] -= xyz[comm2]
pos_col_new[pos_col_new >= Lbox] -= Lbox
pos_col_new[pos_col_new <= 0.] += Lbox

w_col = np.ones(pos_col.shape[0], dtype=pos_col.dtype)
w_col_new = np.ones(pos_col_new.shape[0], dtype=pos_col_new.dtype)

Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    pos_col, w_col, pos_col_new, w_col_new, Lbox)
plt.errorbar(bin_centers,
             Rat_hodtrue_mean,
             yerr=Rat_hodtrue_err,
             color='dodgerblue',
             ls='-',
             label='color-selected',
             alpha=0.5,
             fmt='o',
             capsize=4)

plt.xlabel(r'$r [{\rm Mpc}/h]$')
plt.ylabel(r'$\xi(r)_{\rm HOD}/\xi(r)_{\rm TNG300}$')
plt.xscale('log')
plt.legend()
plt.ylim([0.6, 1.4])
Ejemplo n.º 5
0
def plot_ratio(xyz_true,
               w_true,
               xyz_hod,
               w_hod,
               Lbox,
               color,
               label,
               offset=1.,
               rmin=2.):
    Rat_hodtrue_mean, Rat_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
        xyz_true, w_true, xyz_hod, w_hod, Lbox)

    if color == 'black':
        plt.plot(bin_centers,
                 Rat_hodtrue_mean,
                 color=color,
                 ls='-',
                 label=label)
        plt.fill_between(bin_centers,
                         Rat_hodtrue_mean - Rat_hodtrue_err,
                         Rat_hodtrue_mean + Rat_hodtrue_err,
                         color=color,
                         alpha=.1)
    else:
        plt.errorbar(bin_centers * offset,
                     Rat_hodtrue_mean,
                     yerr=Rat_hodtrue_err,
                     color=color,
                     ls='-',
                     label=label,
                     alpha=1.,
                     fmt='o',
                     capsize=4)

    mean_val = np.mean(Rat_hodtrue_mean[np.isfinite(Rat_hodtrue_mean)
                                        & (bin_centers > rmin)])

    print('mean_val = ', mean_val)
    x = np.linspace(rmin, 10, 3)
    line = np.linspace(0., 20, 3)
    plt.plot(line, np.ones(len(line)), 'k--')
    plt.xlim([0.095, 12])
    plt.plot(x, np.ones(len(x)) * mean_val, color=color, ls='--', lw=1.5)
Ejemplo n.º 6
0
        Group_M_Mean200_dm, hist_norm, bin_edges)
    plt.plot(10.**bin_cents,
             hist_col,
             color='dodgerblue',
             ls='--',
             label='HOD')

    plt.xscale('log')
    plt.yscale('log')
    plt.legend()
    plt.show()

# Correlation function

# get the ratios
Rat_col_hodtrue_mean, Rat_col_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    xyz_col_true, w_col_true, xyz_col_hod, w_col_hod, Lbox)
Rat_all_hodtrue_mean, Rat_all_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    xyz_all_true, w_all_true, xyz_all_hod, w_all_hod, Lbox)
Rat_sfg_hodtrue_mean, Rat_sfg_hodtrue_err, Corr_mean_hod, Corr_err_hod, Corr_mean_true, Corr_err_true, bin_centers = get_jack_corr(
    xyz_sfg_true, w_sfg_true, xyz_sfg_hod, w_sfg_hod, Lbox)

np.save("data/Rat_col_hodtrue_mean.npy", Rat_col_hodtrue_mean)
np.save("data/Rat_col_hodtrue_err.npy", Rat_col_hodtrue_err)
np.save("data/Rat_sfg_hodtrue_mean.npy", Rat_sfg_hodtrue_mean)
np.save("data/Rat_sfg_hodtrue_err.npy", Rat_sfg_hodtrue_err)
np.save("data/Rat_all_hodtrue_mean.npy", Rat_all_hodtrue_mean)
np.save("data/Rat_all_hodtrue_err.npy", Rat_all_hodtrue_err)
np.save("data/bin_centers.npy", bin_centers)

# END HERE