예제 #1
0
def subhalos_read():
    """Read in subhalos and merger tree into global dicts `sh` and `mt`."""
    global sh, mt
    if sh and mt:
        return
    sh = gio_read_dict(fname_subhalos,
                       ['subhalo_mass', 'subhalo_tag', 'fof_halo_tag'])
    mt = gio_read_dict(fname_mt, ['fof_halo_tag', 'fof_halo_mass'])
    M1, M2 = 10**14.0, 10**14.5
    r = (-6, 0)

    fitr = (-3, -1.5)

    x_shmf, y_shmf = plot_subhalo_mass_fn.plotSHMF(M1, M2, r, plotFlag=True, normLogCnts=normLogCnts)
    mask = (fitr[0]<=x_shmf)&(x_shmf<=fitr[1])
    vars_cc = [
        'core_tag', 
        'tree_node_index',
        'infall_mass', 
        'infall_step', 
        'central', 
        'host_core'
    ]
    cc = gio_read_dict('/home/isultan/data/AlphaQ/core_catalog_merg/09_03_2019.AQ.499.coreproperties', vars_cc)
    # least_squares(f, x0, verbose=2)
    # print minimize_scalar(f_zeta0, bounds=(.1, 10), method='bounded')
    # plot_subhalo_mass_fn.plt.legend()
    
    # plot_subhalo_mass_fn.plt.figure(dpi=120)
    # xarr = np.arange(.1, 10, .1)
    # yarr = [f_zeta0(x) for x in xarr]
    # plot_subhalo_mass_fn.plt.figure(dpi=120)
    # plot_subhalo_mass_fn.plt.plot(xarr, yarr)
    # plot_subhalo_mass_fn.plt.xlabel('A')
    # plot_subhalo_mass_fn.plt.ylabel('$|residual|$')

    plot_subhalo_mass_fn.plt.figure(dpi=120)
    xarr = np.arange(.5, 1.5, .01)
    yarr = [f_zeta0(x) for x in xarr]
    '/home/isultan/projects/halomassloss/core_catalog_mevolved/output_LJDS_localhost_dtfactor_0.5_fitting2/m000p-{}.corepropertiesextend.hdf5'
    .format(step), 'coredata')
# cc = h5_read_dict('/home/isultan/projects/halomassloss/core_catalog_mevolved/output_LJDS_localhost_dtfactor_0.5/m000p-{}.corepropertiesextend.hdf5'.format(step), 'coredata')
#cc = h5_read_dict('/home/isultan/projects/halomassloss/core_catalog_mevolved/output_merg_fof_fitting_localhost_dtfactor_0.5_fiducial_A_0.9_zeta_0.005_FIDUCIALPARTICLECUTMASS_PARTICLES100MASS_spline/09_03_2019.AQ.{}.corepropertiesextend.hdf5'.format(step), 'coredata')
#cc = h5_read_dict('/home/isultan/projects/halomassloss/core_catalog_mevolved/output_merg_fof_fitting_localhost_dtfactor_0.5_fiducial_A_0.9_zeta_0.005_FIDUCIALPARTICLECUTMASS_PARTICLES100MASS_spline_zbin_1.5_2/09_03_2019.AQ.{}.corepropertiesextend.hdf5'.format(step), 'coredata')
#cc = h5_read_dict('/home/isultan/projects/halomassloss/core_catalog_mevolved/output_merg_fof_fitting_localhost_dtfactor_0.5_fiducial_A_0.9_zeta_0.005_FIDUCIALPARTICLECUTMASS_PARTICLES100MASS_spline_match_zbin_1.5_2/09_03_2019.AQ.{}.corepropertiesextend.hdf5'.format(step), 'coredata')

#cc_pm = loadpickle('phasemerge_{}.pkl'.format(step))
#_, idx1, idx2 = np.intersect1d(cc['core_tag'], cc_pm['core_tag'], assume_unique=False, return_indices=True)
#cc['phaseSpaceMerged'] = np.zeros_like(cc['central'])
#cc['phaseSpaceMerged'][idx1] = cc_pm['phaseSpaceMerged'][idx2]

# sh = gio_read_dict('/home/isultan/data/AlphaQ/subhalos/m000-{}.subhaloproperties'.format(step), ['fof_halo_tag','subhalo_mean_x','subhalo_mean_y','subhalo_mean_z','subhalo_mean_vx', 'subhalo_mean_vy', 'subhalo_mean_vz', 'subhalo_count', 'subhalo_tag', 'subhalo_mass'])
mt_cores = gio_read_dict(
    '/home/isultan/data/LJDS/MergerTrees_updated/m000p-{}.treenodes'.format(
        step), [
            'fof_halo_tag', 'fof_halo_mass', 'fof_halo_center_x',
            'fof_halo_center_y', 'fof_halo_center_z'
        ])
sh = gio_read_dict(
    '/home/isultan/data/LJDS/subhalos/m000p-{}.subhaloproperties'.format(step),
    [
        'fof_halo_tag', 'subhalo_mean_x', 'subhalo_mean_y', 'subhalo_mean_z',
        'subhalo_mean_vx', 'subhalo_mean_vy', 'subhalo_mean_vz',
        'subhalo_count', 'subhalo_tag', 'subhalo_mass'
    ])
mt = gio_read_dict(
    '/home/isultan/data/LJDS/subhalos/m000p-{}.haloproperties'.format(step), [
        'fof_halo_tag', 'fof_halo_mass', 'fof_halo_center_x',
        'fof_halo_center_y', 'fof_halo_center_z'
    ])
예제 #4
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import subhalo_mass_loss_model as SHMLM
import genericio as gio
from tqdm import tqdm
from itk import hist, h5_read_dict, gio_read_dict, loadpickle, plt_latex, periodic_bcs, many_to_one
from cc_generate_fitting import m_evolved_col, A_arr, zeta_arr
from scipy import spatial #KD Tree for subhalo-core matching
from scipy.stats import norm # Gaussian fitting
import itertools as it

step = 499
z = SHMLM.step2z[step]
cc = h5_read_dict('/home/isultan/projects/halomassloss/core_catalog_mevolved/output_merg_fof_fitting_localhost_mergedcoretag/09_03_2019.AQ.{}.corepropertiesextend.hdf5'.format(step), 'coredata')
sh = gio_read_dict('/home/isultan/data/AlphaQ/subhalos/m000-{}.subhaloproperties'.format(step), ['fof_halo_tag','subhalo_mean_x','subhalo_mean_y','subhalo_mean_z','subhalo_mean_vx', 'subhalo_mean_vy', 'subhalo_mean_vz', 'subhalo_count', 'subhalo_tag', 'subhalo_mass'])
mt = gio_read_dict('/home/isultan/data/AlphaQ/updated_tree_nodes/09_03_2019.AQ.{}.treenodes'.format(step), ['fof_halo_tag', 'fof_halo_mass', 'fof_halo_center_x', 'fof_halo_center_y', 'fof_halo_center_z'])

M1, M2 = 10**9., 10**15.5

# Subhalo-core matching: to look at the subhalo mass:core evolved mass ratio
def generate_cores_kdtree(M1, M2, s1=False, disrupt=None):
    idx_filteredsatcores, M, X, Y, Z, nHalo = SHMLM.core_mask(cc, M1, M2, s1=s1, disrupt=disrupt)
    cc_filtered = { k:cc[k][idx_filteredsatcores].copy() for k in cc.keys() }
    cc_filtered['M'] = M
    cc_filtered['x'] = SHMLM.periodic_bcs(cc_filtered['x'], X, SHMLM.BOXSIZE)
    cc_filtered['y'] = SHMLM.periodic_bcs(cc_filtered['y'], Y, SHMLM.BOXSIZE)
    cc_filtered['z'] = SHMLM.periodic_bcs(cc_filtered['z'], Z, SHMLM.BOXSIZE)
    return spatial.cKDTree( np.vstack((cc_filtered['x'], cc_filtered['y'], cc_filtered['z'])).T ), cc_filtered, nHalo

def shmass(A, zeta, realFlag=False, plotFlag=False, mergedCoreTagFlag=False):
예제 #5
0
countStep = np.array([], dtype=np.int32)
msh_prog = np.array([], dtype=np.float32)
msh_desc = np.array([], dtype=np.float32)
M_host = np.array([], dtype=np.float32)

countHaloMatches = np.array([], dtype=np.int32)
count2Subhalo = np.array([], dtype=np.int32)

mt = None
sh = None
cc = None
sh_indices, cc_filtered_indices, cc_filtered = None, None, None
for s, s_next in tqdm(zip(steps[:-1], steps[1:]), total=len(steps) - 1):
    #readin
    if not mt:
        mt = gio_read_dict(fname_mt(s), cols_mt)
        sh = gio_read_dict(fname_sh(s), cols_sh)
        cc = gio_read_dict(fname_cc(s), cols_cc)
        sh_indices, cc_filtered_indices, cc_filtered = sh_cores_match(
            cc, sh, mt, z=SHMLM.step2z[s])

    mt_next = gio_read_dict(fname_mt(s_next), cols_mt)
    sh_next = gio_read_dict(fname_sh(s_next), cols_sh)
    cc_next = gio_read_dict(fname_cc(s_next), cols_cc)
    sh_indices_next, cc_filtered_indices_next, cc_filtered_next = sh_cores_match(
        cc_next, sh_next, mt_next, z=SHMLM.step2z[s_next])

    _, matchcoresidx, matchcoresidx_next = np.intersect1d(
        cc_filtered['core_tag'][cc_filtered_indices],
        cc_filtered_next['core_tag'][cc_filtered_indices_next],
        assume_unique=False,