-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from ArgonneCPAC/docupdate
Update docs
- Loading branch information
Showing
5 changed files
with
169 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "recorded-display", | ||
"metadata": {}, | ||
"source": [ | ||
"# Overview of Diffmah and DiffmahPop\n", | ||
"\n", | ||
"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.\n", | ||
"\n", | ||
"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}.$" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8dc6f535", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"from matplotlib import pyplot as plt\n", | ||
"import matplotlib.cm as cm" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "plain-arbor", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from diffmah import calc_halo_history\n", | ||
"\n", | ||
"n_halos, n_times = 50, 100\n", | ||
"tarr = np.linspace(0.5, 13.8, n_times)\n", | ||
"colors=cm.coolwarm(np.linspace(1, 0, n_halos)) # red first\n", | ||
"\n", | ||
"tauc = np.linspace(1, 5, n_halos)\n", | ||
"logmp = 12\n", | ||
"early, late = 2, 1\n", | ||
"dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1)\n", | ||
"__=ax.loglog()\n", | ||
"for ih in range(n_halos):\n", | ||
" __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "completed-macro", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"tauc = 2.0\n", | ||
"early = np.linspace(1, 3, n_halos)\n", | ||
"late = 1\n", | ||
"dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)\n", | ||
"\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1)\n", | ||
"__=ax.loglog()\n", | ||
"for ih in range(n_halos):\n", | ||
" __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "constant-thunder", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"tauc = 2.0\n", | ||
"early = 3\n", | ||
"late = np.linspace(0.01, 3, n_halos)\n", | ||
"dmhdt, log_mah = calc_halo_history(tarr, tarr[-1], logmp, tauc, early, late)\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1)\n", | ||
"__=ax.loglog()\n", | ||
"for ih in range(n_halos):\n", | ||
" __=ax.plot(tarr, 10**log_mah[ih, :], color=colors[ih])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "acknowledged-exhibition", | ||
"metadata": {}, | ||
"source": [ | ||
"## Generating Monte Carlo realizations of halo MAHs with DiffmahPop" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "imported-jungle", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from diffmah import mc_halo_population\n", | ||
"\n", | ||
"cosmic_time = np.linspace(0.5, 13.8, 100)\n", | ||
"\n", | ||
"n_halos = 5_000\n", | ||
"logmh = np.zeros(n_halos) + 12\n", | ||
"\n", | ||
"_res = mc_halo_population(cosmic_time, cosmic_time[-1], logmh)\n", | ||
"dmhdt, log_mah, early, late, lgtc, mah_type_arr = _res\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1)\n", | ||
"__=ax.loglog()\n", | ||
"for ih in range(5):\n", | ||
" __=ax.plot(tarr, 10**log_mah[ih, :])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fixed-fluid", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.