Overview of Diffmah and DiffmahPop

Starting from a collection of best-fitting approximations to halo merger trees, you can use the calc_halo_history function to compute the assembly history for every halo in the sample. Here we’ll just demonstrate a few simple cases.

Note that in these examples, we pass in arbitrary values for the early- and late-time indices. However, for real halos (and also for the results returned by the diffmah-provided MAH fitting script), \(0 < \alpha_{\rm late} < \alpha_{\rm early}.\)

[1]:
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.cm as cm
Matplotlib is building the font cache; this may take a moment.
[2]:
from diffmah import calc_halo_history

n_halos, n_times = 50, 100
tarr = np.linspace(0.5, 13.8, n_times)
colors=cm.coolwarm(np.linspace(1, 0, n_halos)) # red first

tauc = np.linspace(1, 5, n_halos)
logmp = 12
early, late = 2, 1
dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)

fig, ax = plt.subplots(1, 1)
__=ax.loglog()
for ih in range(n_halos):
    __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])
_images/diffmah_halo_populations_2_0.png
[3]:
tauc = 2.0
early = np.linspace(1, 3, n_halos)
late = 1
dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)


fig, ax = plt.subplots(1, 1)
__=ax.loglog()
for ih in range(n_halos):
    __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])
_images/diffmah_halo_populations_3_0.png
[4]:
tauc = 2.0
early = 3
late = np.linspace(0.01, 3, n_halos)
dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)

fig, ax = plt.subplots(1, 1)
__=ax.loglog()
for ih in range(n_halos):
    __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])
_images/diffmah_halo_populations_4_0.png

Generating Monte Carlo realizations of halo MAHs with DiffmahPop

[5]:
from diffmah import mc_halo_population

cosmic_time = np.linspace(0.5, 13.8, 100)

n_halos = 5_000
logmh = np.zeros(n_halos) + 12

_res = mc_halo_population(cosmic_time, cosmic_time[-1], logmh)
dmhdt, log_mah, early, late, lgtc, mah_type_arr = _res

fig, ax = plt.subplots(1, 1)
__=ax.loglog()
for ih in range(5):
    __=ax.plot(tarr, 10**log_mah[ih, :])
_images/diffmah_halo_populations_6_0.png
[ ]: