def main():

    if len(sys.argv) > 1:
        sim_name = sys.argv[1]
        snapNum = int(sys.argv[2])
    else:
        sim_name = 'Illustris-1'  # full physics high-res run
        snapNum = 135  # z=0

    # load simulation properties
    d = sim_prop_dict[sim_name]
    basePath_1 = d['basePath']
    m_dm_1 = d['m_dm']

    d = sim_prop_dict[sim_name + '-Dark']
    basePath_2 = d['basePath']
    m_dm_2 = d['m_dm']

    litte_h = d['litte_h']
    Lbox = d['Lbox']

    # load full physics catalog
    fields = ['GroupPos', 'GroupMass', 'Group_R_Mean200']
    halo_table_1 = loadHalos(basePath_1, snapNum, fields=fields)
    host_ids_1 = np.arange(0, len(halo_table_1['GroupMass'])).astype('int')

    coords_1 = halo_table_1['GroupPos'] / 1000.0

    # load DMO catalog
    fields = ['GroupPos', 'GroupMass']
    halo_table_2 = loadHalos(basePath_2, snapNum, fields=fields)
    host_ids_2 = np.arange(0, len(halo_table_2['GroupMass'])).astype('int')

    # build KD tree
    coords_2 = halo_table_2['GroupPos'] / 1000.0
    tree = KDTree(coords_2, boxsize=Lbox)

    # query tree for nearest neighbors
    r_max = 1.0
    result = tree.query(coords_1, k=1, distance_upper_bound=r_max)

    idx = result[1]
    r = result[0]

    no_match = (idx == len(halo_table_2['GroupMass']))
    idx[no_match] = -1

    # save table
    fpath = './data/value_added_catalogs/'
    fname = sim_name + '_' + str(snapNum) + '_host_halo_matches.dat'
    ascii.write([host_ids_1, idx, r],
                fpath + fname,
                names=['host_halo_id', 'dmo_host_halo_id', 'r'],
                overwrite=True)
Beispiel #2
0
def main():

    if len(sys.argv) > 1:
        sim_name = sys.argv[1]
        snapNum = int(sys.argv[2])
    else:
        sim_name = 'Illustris-1'  # full physics high-res run
        snapNum = 135  # z=0

    # load simulation properties
    d = sim_prop_dict[sim_name]
    basePath = d['basePath']
    m_dm = d['m_dm']
    litte_h = d['litte_h']
    Lbox = d['Lbox']

    # scale to get peculiar velocity
    header = loadHeader(basePath, snapNum)
    scale_factor = header['Time']

    # load host halo catalog
    fields = [
        'GroupPos', 'GroupVel', 'GroupMass', 'Group_M_Mean200',
        'Group_R_Mean200', 'GroupFirstSub'
    ]
    halo_table = loadHalos(basePath, snapNum, fields=fields)
    host_ids = np.arange(0, len(halo_table['GroupMass'])).astype('int')

    coords = halo_table['GroupPos'] / 1000.0
    x = coords[:, 0]
    y = coords[:, 1]
    z = coords[:, 2]

    vels = halo_table['GroupVel'] * np.sqrt(scale_factor)
    vx = vels[:, 0]
    vy = vels[:, 1]
    vz = vels[:, 2]

    halo_mass_200m = halo_table['Group_M_Mean200'] * 10**10
    host_halo_radius_200m = halo_table['Group_R_Mean200'] / 1000.0
    host_halo_fof_mass = halo_table['GroupMass'] * 10**10

    central_id = halo_table['GroupFirstSub']

    # save table
    fpath = './data/value_added_catalogs/'
    fname = sim_name + '_' + str(snapNum) + '_host_halo_catalog.dat'
    ascii.write([
        host_ids, central_id, x, y, z, vx, vy, vz, halo_mass_200m,
        host_halo_radius_200m, host_halo_fof_mass
    ],
                fpath + fname,
                names=[
                    'host_halo_id', 'central_id', 'x', 'y', 'z', 'vx', 'vy',
                    'vz', 'host_halo_mass_200m', 'host_halo_radius_200m',
                    'host_halo_fof_mass'
                ],
                overwrite=True)
Beispiel #3
0
import matplotlib.pyplot as plt
import illustris_python.groupcat as gc
import numpy as np

basePath = "/hpcfs/home/ciencias/fisica/docentes/je.forero/Illustris-1/"

subhalo_fields = ['SubhaloMass', 'SubhaloSFRinRad']
subhalos = gc.loadSubhalos(basePath, 135, fields=subhalo_fields)

halo_fields = ['GroupFirstSub', 'Group_M_Crit200', 'GroupNsubs']
halos = gc.loadHalos(basePath, 135, fields=halo_fields)

for k in subhalos.keys():
    print(k)

for k in halos.keys():
    print(k)

mass_msun = halos['Group_M_Crit200'] * 1e10 / 0.704
n_in_halo = halos['GroupNsubs']

fig = plt.figure(1, figsize=(11, 10))
plt.plot(mass_msun, n_in_halo, '.')

ax = plt.axes()
ax.set_xlim([1E9, 1E15])
ax.set_ylim([1, 1E5])

plt.xscale('log')
plt.yscale('log')
plt.xlabel('Total Mass [$M_\odot$]')
def main():

    if len(sys.argv) > 1:
        sim_name = sys.argv[1]
        snapNum = int(sys.argv[2])
    else:
        sim_name = 'Illustris-1'  # full physics high-res run
        snapNum = 135  # z=0

    # get simulation properties
    d = sim_prop_dict[sim_name]
    basePath = d['basePath']
    m_dm = d['m_dm']
    litte_h = d['litte_h']
    Lbox = d['Lbox']

    # make galaxy selection
    min_mstar = litte_h * 10.0**8.0
    min_ndark = 1000
    mask, gal_ids = galaxy_selection(min_mstar, min_ndark, basePath, snapNum)

    # number of galaxies in selection
    Ngals = len(gal_ids)
    print("number of galaxies in selection: {0}".format(Ngals))

    fields = [
        'SubhaloGrNr', 'SubhaloMassInRadType', 'SubhaloMassType', 'SubhaloPos',
        'SubhaloVel', 'SubhaloLenType', 'SubhaloStellarPhotometrics'
    ]

    galaxy_table = loadSubhalos(basePath, snapNum, fields=fields)

    # FoF host halo ID
    host_halo_ids = galaxy_table['SubhaloGrNr'][gal_ids]

    x = galaxy_table['SubhaloPos'][:, 0][gal_ids]
    y = galaxy_table['SubhaloPos'][:, 1][gal_ids]
    z = galaxy_table['SubhaloPos'][:, 2][gal_ids]

    vx = galaxy_table['SubhaloVel'][:, 0][gal_ids]
    vy = galaxy_table['SubhaloVel'][:, 1][gal_ids]
    vz = galaxy_table['SubhaloVel'][:, 2][gal_ids]

    ndark = galaxy_table['SubhaloLenType'][:, 1][gal_ids]
    nstar = galaxy_table['SubhaloLenType'][:, 4][gal_ids]

    gmag = galaxy_table['SubhaloStellarPhotometrics'][:, 4][gal_ids]
    rmag = galaxy_table['SubhaloStellarPhotometrics'][:, 5][gal_ids]
    imag = galaxy_table['SubhaloStellarPhotometrics'][:, 6][gal_ids]

    mstar_in_twice_halfrad = galaxy_table['SubhaloMassInRadType'][:,
                                                                  4][gal_ids]
    mstar_in_twice_halfrad = mstar_in_twice_halfrad * 10**10

    mstar_all = galaxy_table['SubhaloMassType'][:, 4][gal_ids]
    mstar_all = mstar_all * 10**10

    # central galaxy ID of group
    fields = [
        'GroupFirstSub', 'Group_M_Mean200', 'Group_R_Mean200', 'GroupMass'
    ]
    host_halo_table = loadHalos(basePath, snapNum, fields=fields)
    central_id = host_halo_table['GroupFirstSub'][host_halo_ids]

    # host halo properties
    host_halo_mass_200m = host_halo_table['Group_M_Mean200'][host_halo_ids]
    host_halo_radius_200m = host_halo_table['Group_R_Mean200'][host_halo_ids]
    host_halo_fof_mass = host_halo_table['GroupMass'][host_halo_ids]

    # save table
    fpath = './data/value_added_catalogs/'
    fname = sim_name + '_' + str(snapNum) + '_vagc.dat'
    ascii.write([
        gal_ids, host_halo_ids, central_id, x, y, z, vx, vy, vz, ndark, nstar,
        mstar_in_twice_halfrad, mstar_all, gmag, rmag, imag,
        host_halo_mass_200m, host_halo_radius_200m, host_halo_fof_mass
    ],
                fpath + fname,
                names=[
                    'gal_id', 'host_halo_id', 'central_id', 'x', 'y', 'z',
                    'vx', 'vy', 'vz', 'npart_dm', 'npart_stellar',
                    'stellar_mass_in_twice_halfrad', 'stellar_mass_all',
                    'gmag', 'rmag', 'imag', 'host_halo_mass_200m',
                    'host_halo_radius_200m', 'host_halo_fof_mass'
                ],
                overwrite=True)