Skip to content

Commit

Permalink
Demo how enable projected_quad
Browse files Browse the repository at this point in the history
  • Loading branch information
hsinfan1996 committed Aug 25, 2023
1 parent d50fc2f commit 2c44f0d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 11 deletions.
67 changes: 60 additions & 7 deletions examples/demo_theory_functionality.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"plot_profile(r3d, kappa, \"$\\\\kappa$\")"
Expand Down Expand Up @@ -437,7 +439,7 @@
"- In CCL, the default Einasto slope depends on cosmology, redshift and halo mass. \n",
"- In NumCosmo, the default value is $\\alpha_{\\rm ein}=0.25$.\n",
"\n",
"**NB: for CCL, setting a user-defined value for the Einasto slope is only available for CCL version >= 2.6.** Earlier versions only allow the default option.\n",
"**NB: for CCL, setting a user-defined value for the Einasto slope is only available for versions >= 2.6.** Earlier versions only allow the default option.\n",
"\n",
"The verbose option allows to print the value of $\\alpha$ that is being used, as follows:"
]
Expand All @@ -459,8 +461,8 @@
" verbose=True,\n",
")\n",
"\n",
"# For CCL < 2.6, the above call will return an error, as alpha_ein could not be set. The call below, not specifying alpha_ein,\n",
"# will use the default value (for both backend)\n",
"# For CCL < 2.6, the above call will return an error, as alpha_ein cannot not be set. The call below, not specifying alpha_ein,\n",
"# will use the default value (for both CCL and NC backends)\n",
"\n",
"# rho = m.compute_3d_density(r3d, mdelta=cluster_mass, cdelta=cluster_concentration,\n",
"# z_cl=z_cl, cosmo=cosmo, halo_profile_model='einasto',\n",
Expand All @@ -469,13 +471,64 @@
"\n",
"plot_profile(r3d, rho, \"$\\\\rho_{\\\\rm 3d}$\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For CCL versions >= 2.8.1.dev73+g86125b08, the surface mass density profile can be calculated with quad_vec numerial integration in addition to the default FFTLog. This option will increase the precision of the profile at large radii and can be enabled by passing `use_projected_quad` keyword argument to `compute_surface_density`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# use quad_vec\n",
"Sigma_quad = m.compute_surface_density(\n",
" r3d,\n",
" mdelta=cluster_mass,\n",
" cdelta=cluster_concentration,\n",
" z_cl=z_cl,\n",
" cosmo=cosmo,\n",
" halo_profile_model=\"einasto\",\n",
" alpha_ein=0.17,\n",
" use_projected_quad=True, # use quad_vec\n",
" verbose=True,\n",
")\n",
"\n",
"plot_profile(r3d, Sigma_quad, \"$\\\\Sigma_{\\\\rm quad}$\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# default behavior\n",
"Sigma_FFTLog = m.compute_surface_density(\n",
" r3d,\n",
" mdelta=cluster_mass,\n",
" cdelta=cluster_concentration,\n",
" z_cl=z_cl,\n",
" cosmo=cosmo,\n",
" halo_profile_model=\"einasto\",\n",
" alpha_ein=0.17,\n",
" use_projected_quad=False, # default\n",
" verbose=True,\n",
")\n",
"\n",
"plot_profile(r3d, Sigma_FFTLog, \"$\\\\Sigma_{\\\\rm FFTLog}$\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "wrk",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "wrk"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -487,7 +540,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
37 changes: 33 additions & 4 deletions examples/demo_theory_functionality_oo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,48 @@
"plot_profile(r3d, rho, \"$\\\\rho_{\\\\rm 3d}$\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For CCL versions >= 2.8.1.dev73+g86125b08, the surface mass density profile can be calculated with quad_vec numerial integration in addition to the default FFTLog. This option will increase the precision of the profile at large radii and can be enabled by calling `set_projected_quad(True)`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# use quad_vec\n",
"moo_ein.set_projected_quad(True)\n",
"\n",
"Sigma_quad = moo_ein.eval_surface_density(r3d, z_cl, verbose=True)\n",
"\n",
"plot_profile(r3d, Sigma_quad, \"$\\\\Sigma_{\\\\rm quad}$\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# revert the effect from the previous cell\n",
"moo_ein.set_projected_quad(False)\n",
"\n",
"# default behavior\n",
"Sigma_FFTLog = moo_ein.eval_surface_density(r3d, z_cl, verbose=True)\n",
"\n",
"plot_profile(r3d, Sigma_FFTLog, \"$\\\\Sigma_{\\\\rm FFTLog}$\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "wrk",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "wrk"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -326,7 +355,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 2c44f0d

Please sign in to comment.