Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
858 changes: 858 additions & 0 deletions examples/Paper_v2.0/Example4_Fit_Halo_mass_to_HSC_data_paper2.ipynb

Large diffs are not rendered by default.

767 changes: 767 additions & 0 deletions examples/Paper_v2.0/Example5_Fit_Halo_mass_to_DES_data_paper2.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7c213181-875a-408b-a95f-19dac19a324e",
"metadata": {},
"source": [
"# To make a plot that compares the contribution to excess surface density profiles for weak lensing when the lens is triaxial"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "43f767fb-627e-4c15-aede-d7a7b051f9bb",
"metadata": {},
"outputs": [],
"source": [
"import clmm\n",
"from clmm import Cosmology\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
"cosmo = Cosmology(H0=70.0, Omega_dm0=0.2248, Omega_b0=0.3 - 0.2248, Omega_k0=0.0)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "583e00e3-2f75-4a10-a773-ee816be0514a",
"metadata": {},
"outputs": [],
"source": [
"r=np.linspace(0.1, 5, 100)\n",
"\n",
"# A sample Mass, concentration for a halo:\n",
"mdelta_fit = 2.0E14 # in M_sun/h\n",
"cdelta_fit = 3.89 \n",
"\n",
"# Ellipticities:\n",
"ell_1_0 = 0.0 # q = 1.0, ellipticity is (1-q)/(1+q)\n",
"ell_0_7 = 0.176 # q = 0.7, ellipticity is (1-q)/(1+q)\n",
"ell_0_3 = 0.497 # q = 0.3, ellipticity is (1-q)/(1+q)\n",
"\n",
"z_cl = 0.47\n",
"\n",
"mdef = 'critical'\n",
"\n",
"'''\n",
"A Spherical Halo: (Axis ratio, q = 1.0 )\n",
"'''\n",
"ds_model_e_0 = clmm.compute_excess_surface_density_triaxial(ell=ell_1_0, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='mono')\n",
"ds_const_model_e_0 = clmm.compute_excess_surface_density_triaxial(ell=ell_1_0, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_const')\n",
"ds_4theta_model_e_0 = clmm.compute_excess_surface_density_triaxial(ell=ell_1_0, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_4theta')\n",
"\n",
"'''\n",
"An Elliptical Halo: (Axis ratio, q = 0.7)\n",
"'''\n",
"ds_model = clmm.compute_excess_surface_density_triaxial(ell=ell_0_7, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, z_cl=z_cl, \n",
" cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='mono')\n",
"ds_const_model = clmm.compute_excess_surface_density_triaxial(ell=ell_0_7, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_const')\n",
"ds_4theta_model = clmm.compute_excess_surface_density_triaxial(ell=ell_0_7, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_4theta')\n",
"\n",
"\n",
"'''\n",
"An Elliptical Halo: (Axis ratio, q = 0.3)\n",
"'''\n",
"ds_model_0_3 = clmm.compute_excess_surface_density_triaxial(ell=ell_0_3, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='mono')\n",
"ds_const_model_0_3 = clmm.compute_excess_surface_density_triaxial(ell=ell_0_3, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_const')\n",
"ds_4theta_model_0_3 = clmm.compute_excess_surface_density_triaxial(ell=ell_0_3, r_proj=r, mdelta=mdelta_fit, cdelta=cdelta_fit, \n",
" z_cl=z_cl, cosmo=cosmo, halo_profile_model='nfw', \n",
" delta_mdef=200, massdef=mdef, term='quad_4theta')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b87d23bd-7432-42cc-aee4-addbdd6f90c0",
"metadata": {},
"outputs": [],
"source": [
"fig,ax = plt.subplots(1,2, figsize=[10,5])\n",
"\n",
"sns.lineplot(x=r, y=ds_model_e_0/1E12, ax=ax[0], markers = True, ms=20.0, color='black', ls='dashdot', label='Spherical NFW')\n",
"sns.lineplot(x=r, y=ds_model/1E12, ax=ax[0], color='darkorange', label='Elliptical NFW (q = 2/3)', ls='solid')\n",
"sns.lineplot(x=r, y=ds_model_0_3/1E12, ax=ax[0], color='darkorange', label='Elliptical NFW (q = 1/3)', ls='solid', alpha=0.4)\n",
"ax[0].set_yscale('log')\n",
"ax[0].set_xscale('log')\n",
"ax[0].set_xlabel('r [Mpc]', fontsize=18)\n",
"ax[0].set_ylabel(r'Monopole $\\Delta\\Sigma \\,[M_{\\odot} h/\\rm{pc}^{2}]$', fontsize=18)\n",
"ax[0].tick_params(axis='both', which='both', labelsize=12)\n",
"ax[0].legend(fontsize=11)\n",
"plt.tight_layout()\n",
"axin1 = ax[0].inset_axes(\n",
" [0.18, 7, 1, 20], transform=ax[0].transData)\n",
"\n",
"sns.lineplot(x=r,y=(1-ds_model/ds_model_e_0)*100, ax=axin1, color='crimson', label='q=2/3')\n",
"sns.lineplot(x=r,y=(1-ds_model_0_3/ds_model_e_0)*100, ax=axin1, color='crimson', alpha=0.4, label='q=1/3')\n",
"axin1.set_xscale('log')\n",
"axin1.set_ylabel('Difference (%)', fontsize=10)\n",
"axin1.legend()\n",
"#axin1.set_xlabel('r', fontsize=15)\n",
"\n",
"sns.lineplot(x=r, y=ds_const_model_e_0/1E12, ax=ax[1], color='black', ls='dashdot', label='Spherical NFW')\n",
"sns.lineplot(x=r, y=ds_const_model/1E12, ax=ax[1], color='crimson', label=r'Elliptical NFW (q = 2/3) | $4\\theta$')\n",
"sns.lineplot(x=r, y=ds_4theta_model/1E12, ax=ax[1], color='darkorange', label='Elliptical NFW (q = 2/3) | const', ls='dashed')\n",
"\n",
"sns.lineplot(x=r, y=ds_const_model_0_3/1E12, ax=ax[1], color='crimson', label=r'Elliptical NFW (q = 1/3) | $4\\theta$', alpha=0.4)\n",
"sns.lineplot(x=r, y=ds_4theta_model_0_3/1E12, ax=ax[1], color='darkorange', label='Elliptical NFW (q = 1/3) | const', ls='dashed', alpha=0.4)\n",
"#ax[1].set_yscale('log')\n",
"ax[1].set_xscale('log')\n",
"ax[1].set_xlabel('r [Mpc]', fontsize=18)\n",
"ax[1].set_ylabel(r'Quadrupole $\\Delta\\Sigma \\,[M_{\\odot} h/\\rm{pc}^{2}]$', fontsize=18)\n",
"ax[1].tick_params(axis='both', which='both', labelsize=12)\n",
"ax[1].legend(fontsize=11)\n",
"plt.tight_layout()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base3",
"language": "python",
"name": "base3"
},
"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.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
191 changes: 191 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,191 @@
{
"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 matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from paper_formating import add_grid, prep_plot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Imports specific to clmm "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"CLMM_MODELING_BACKEND\"] = (\n",
" \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n",
")\n",
"\n",
"import clmm\n",
"import clmm.utils as u\n",
"from clmm import Cosmology"
]
},
{
"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.0e14\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 = (\n",
" 2.4 # Tkinker10 value for this halo mass and redshift (see last commented cell)\n",
")\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",
"\n",
"# boost model\n",
"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 = prep_plot(figsize=(9, 9))\n",
"ax = plt.axes()\n",
"\n",
"ax.loglog(r_proj, DeltaSigma, label=\"1-halo (reference)\", color=\"k\")\n",
"ax.loglog(r_proj, DeltaSigma_mis, ls=\"--\", label=r\"1-halo ($R_{\\rm mis} = 0.2$Mpc)\")\n",
"ax.loglog(r_proj, DeltaSigma / nfw_boost, ls=\":\", label=\"1-halo (boost correction)\")\n",
"ax.loglog(r_proj, DeltaSigma_2h, ls=\"dashdot\", label=\"2-halo\")\n",
"ax.legend(loc=1, fontsize=6.5)\n",
"\n",
"ax.set_xlabel(\"R [Mpc]\")\n",
"ax.set_ylabel(r\"$\\Delta\\Sigma$ [M$_\\odot$ Mpc$^{-2}$]\")\n",
"ax.set_ylim(8.0e10, 1e15)\n",
"ax.set_xlim(1e-2, 1e2)\n",
"\n",
"add_grid(ax)\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig(\"2h_miscentering_boost.png\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "clmm",
"language": "python",
"name": "clmm"
},
"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.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading
Loading