Beispiel #1
0
def calc_wetzel09_disruption(param_fname):
    clusters, central = get_clusters(param_fname, core_host_mass=True)
    fit_mi, fit_rd = get_fit_param(param_fname)
    stepz = dtk.StepZ(sim_name='AlphaQ')
    z = stepz.get_z(401)
    print(z)
    core_t_dyn = wetzel09_disruption_time(0.25, clusters.core_m,
                                          clusters.core_host_mass, z)
    print(core_t_dyn)
    plt.figure()
    lg_min = np.min(np.log10(core_t_dyn))
    lg_max = np.max(np.log10(core_t_dyn))
    print(lg_min, lg_max)
    xbins = np.logspace(lg_min, lg_max, 10)
    print(xbins)
    xbins_cen = dtk.log_bins_avg(xbins)
    h, _ = np.histogram(core_t_dyn, bins=xbins)
    plt.loglog(
        xbins_cen,
        h,
    )

    plt.figure()
    plt.hist2d(np.log10(clusters.core_m),
               np.log10(clusters.core_host_mass),
               bins=100,
               cmap='Blues',
               norm=clr.LogNorm())

    plt.figure()
    h, xbins = np.histogram(np.log10(clusters.core_host_mass /
                                     clusters.core_m),
                            bins=100)
    xbins_cen = dtk.bins_avg(xbins)
    plt.plot(xbins_cen, h, label='All Cores')

    plt.xlabel('log10(Mhost/Msat)')
    plt.ylabel('Counts')

    if fit_mi < 1e3:
        fit_mi = 10**fit_mi
    slct = clusters.core_m > fit_mi
    h, xbins = np.histogram(np.log10(clusters.core_host_mass[slct] /
                                     clusters.core_m[slct]),
                            bins=100)
    xbins_cen = dtk.bins_avg(xbins)
    plt.plot(xbins_cen, h, label='>M_infall')

    slct = (clusters.core_m > fit_mi) & (clusters.core_r < fit_rd)
    h, xbins = np.histogram(np.log10(clusters.core_host_mass[slct] /
                                     clusters.core_m[slct]),
                            bins=100)
    xbins_cen = dtk.bins_avg(xbins)
    plt.plot(xbins_cen, h, label='Fit Cores')

    plt.legend(loc='best')
Beispiel #2
0
#!/usr/bin/env python2.7

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as clr
import h5py
import dtk
import sys

from astropy.cosmology import WMAP7 as cosmo
import time
from scipy.interpolate import interp1d

h = 0.702
stepz = dtk.StepZ(200, 0, 500)
zs = np.linspace(0, 1.5, 1000)
z_to_dl = interp1d(zs, cosmo.luminosity_distance(zs))
step2nan_str_z = {}

param = dtk.Param(sys.argv[1])
output = param.get_string('output')
output_mod = output.replace('.hdf5', '_mod.hdf5')

hfile = h5py.File(output_mod, 'a')

redshift = hfile['galaxyProperties/redshiftHubble'].value
dl = z_to_dl(redshift)
print "done getting the luminosity distance..."
adjust = -2.5 * np.log10(1 + redshift) + 5 * np.log10(dl) + 25.0
Beispiel #3
0
fof_cat = Catalog(fof_loc)
sod_cat = Catalog(sod_loc)
core_cat = Catalog(core_loc)
zmr_sdss = np.load(zmr_loc)
zmr_sdss = npzfile_to_dic(zmr_sdss)
print zmr_sdss.keys()

step1 = param.get_int("step")
steps = param.get_int_list("steps")

z_in = param.get_float("z_in")
z_out = param.get_float("z_out")
num_steps = param.get_int("num_steps")

stepz = dtk.StepZ(z_in, z_out, num_steps)

n2merger = N2Merger(n2lib_loc)

fof_cat.add_steps(steps)
sod_cat.add_steps(steps)
core_cat.add_steps(steps)

fof_cat.add_data_name("fof_halo_tag")
fof_cat.add_data_name("fof_halo_mass")
fof_cat.add_data_name("fof_halo_center_x")
fof_cat.add_data_name("fof_halo_center_y")
fof_cat.add_data_name("fof_halo_center_z")

sod_cat.add_data_name("fof_halo_tag")
sod_cat.add_data_name("sod_halo_mass")
Beispiel #4
0
    plt.figure()
    plt.plot(cat['sod_halo_radius'], R200c_col/1000.0/0.7*a, '.', alpha=0.3)
    plt.yscale('log')
    plt.xscale('log')
    plt.title('radius')
    plot_1to1()

    plt.figure()
    plt.plot(cat['sod_halo_radius'], (R200c_col/1000.0/0.7*a)/cat['sod_halo_radius'], '.', alpha=0.3)
    plt.xscale('log')
    plt.show()

if __name__ == "__main__":
    cosmology.setCosmology('WMAP7')
    param = dtk.Param(sys.argv[1])
    steps = param.get_int_list("steps")
    sod_location = param.get_string("sod_location")
    sod_output   = param.get_string("sod_output")
    input_h = param.get_float("input_h")
    output_h = param.get_float("output_h")
    write_catalog = param.get_bool("write_catalog")
    h_scaling = input_h/output_h
    stepz = dtk.StepZ(sim_name = 'AlphaQ')
    print(colossus.__file__)
    for step in steps:
        redshift = stepz.get_z(step)
        convert_halo_m200c_to_m200m(sod_location, sod_output, step,
                                    redshift, h_scaling,
                                    write_catalog=write_catalog)
        check_halo_conversion(sod_location, step, redshift)