Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Paper_v2.0/paper_formating.py #640

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 204 additions & 0 deletions examples/Paper_v2.0/fig_2halo_miscentering_boost_theory.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Figure to show the new 2-halo term and miscentering functionality"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Imports specific to clmm "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\n",
" \"CLMM_MODELING_BACKEND\"\n",
"] = \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n",
"\n",
"import clmm\n",
"from clmm import Cosmology\n",
"import clmm.utils as u"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Make sure we know which version we're using"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"clmm.__version__"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define a cosmology using astropy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cosmo = Cosmology(H0=67.0, Omega_dm0=0.315 - 0.045, Omega_b0=0.045, Omega_k0=0.0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define the galaxy cluster model. Here, we choose parameters that describe the galaxy cluster model, including the mass definition, concentration, and mass distribution. For the mass distribution, we choose a distribution that follows an NFW profile."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"moo = clmm.Modeling(massdef=\"mean\", delta_mdef=200, halo_profile_model=\"nfw\")\n",
"\n",
"mass_cl = 1.e14\n",
"z_cl = 0.4\n",
"\n",
"conc_cl = 5.4# Duffy08 value for this halo mass and redshift (see last commented cell)\n",
"halo_bias = 2.4 # Tkinker10 value for this halo mass and redshift (see last commented cell)\n",
"\n",
"moo.set_cosmo(cosmo)\n",
"moo.set_concentration(conc_cl)\n",
"moo.set_mass(mass_cl)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"r_proj = np.logspace(-2, 2, 100)\n",
"\n",
"DeltaSigma = moo.eval_excess_surface_density(r_proj, z_cl)\n",
"\n",
"# Miscentered DeltaSigma\n",
"DeltaSigma_mis = moo.eval_excess_surface_density(r_proj, z_cl, r_mis=0.2)\n",
"\n",
"# 2halo DeltaSigma\n",
"DeltaSigma_2h = moo.eval_excess_surface_density_2h(r_proj, z_cl, halobias=6)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"r_scale = 0.3\n",
"nfw_boost = u.compute_nfw_boost(r_proj, r_scale, boost0=0.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the predicted profiles"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(7,6))\n",
"\n",
"ax.loglog(r_proj, DeltaSigma,label='1-halo, centered, reference', color='k')\n",
"ax.loglog(r_proj, DeltaSigma/nfw_boost, ls=':', label='1-halo, corrected with NFW boost model', color='grey')\n",
"ax.loglog(r_proj, DeltaSigma_mis , ls ='--', label='1-halo, miscentered, R_mis = 0.2 Mpc')\n",
"ax.loglog(r_proj, DeltaSigma_2h, ls='dashdot', label='2-halo', color='green')\n",
"ax.legend(loc=1, fontsize=13)\n",
"\n",
"ax.set_xlabel('R [Mpc]', fontsize=15)\n",
"ax.set_ylabel(r'$\\Delta\\Sigma$ [M$_\\odot$ Mpc$^{-2}$]', fontsize=15)\n",
"ax.tick_params(axis='x', labelsize=15)\n",
"ax.tick_params(axis='y', labelsize=15)\n",
"ax.set_ylim([8.e10, 1e16])\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig('2h_miscentering_boost.png')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Typical values for halo_bias and concentration to use in the the example, computed using CCL\n",
"\n",
"import pyccl as ccl\n",
"\n",
"cosmo = ccl.Cosmology(Omega_c=0.27, Omega_b=0.045, h=0.67, sigma8=0.83, n_s=0.96)\n",
"\n",
"a = 1./(1+z_cl)\n",
"\n",
"bias = ccl.halos.HaloBiasTinker10(mass_def='200m', mass_def_strict=True)\n",
"conc = ccl.halos.concentration.ConcentrationDuffy08(mass_def='200m')\n",
"\n",
"bias(cosmo, mass_cl, a), conc(cosmo, mass_cl, a)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "wrk",
"language": "python",
"name": "wrk"
},
"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.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading
Loading