Skip to content
2 changes: 1 addition & 1 deletion clmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
)
from .utils import compute_radial_averages, convert_units, make_bins

__version__ = "1.16.10"
__version__ = "1.17.0"
4 changes: 2 additions & 2 deletions clmm/galaxycluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ def draw_gal_z_from_pdz(self, zcol_out="z", overwrite=False, nobj=1, xmin=None,

if zcol_out in self.galcat.columns and overwrite is False:
raise TypeError(
f"Column {zcol_out} already exists in galcat. \
Set overwrite=True to overwrite or use other column name"
f"Column {zcol_out} already exists in galcat. "
"Set overwrite=True to overwrite or use other column name"
)

zdata = self._get_input_galdata({"pzpdf": "pzpdf", "pzbins": "pzbins"})
Expand Down
361 changes: 187 additions & 174 deletions clmm/theory/func_layer.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clmm/theory/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def compute_magnification_bias_from_magnification(magnification, alpha):
"""
if np.any(np.array(magnification) < 0):
warnings.warn(
"Magnification is negative for certain radii, \
returning nan for magnification bias in this case."
"Magnification is negative for certain radii, "
"returning nan for magnification bias in this case."
)
return np.array(magnification) ** (np.array([alpha]).T - 1)

Expand Down
264 changes: 140 additions & 124 deletions clmm/theory/parent_class.py

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions examples/demo_theory_functionality.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"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",
"os.environ[\"CLMM_MODELING_BACKEND\"] = (\n",
" \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n",
")\n",
"import clmm\n",
"import clmm.theory as m\n",
"from clmm import Cosmology"
Expand Down Expand Up @@ -111,7 +111,9 @@
"\n",
"# source properties\n",
"z_src = 2.0 # all sources in the same plan\n",
"z_distrib_func = clmm.utils.redshift_distributions.chang2013 # sources redshift following a distribution\n",
"z_distrib_func = (\n",
" clmm.utils.redshift_distributions.chang2013\n",
") # sources redshift following a distribution\n",
"alpha = [2, -0.5]"
]
},
Expand Down Expand Up @@ -166,7 +168,7 @@
" cosmo=cosmo,\n",
" delta_mdef=mass_Delta,\n",
" halo_profile_model=density_profile_parametrization,\n",
" r_mis=0.2\n",
" r_mis=0.2,\n",
")"
]
},
Expand Down Expand Up @@ -194,7 +196,7 @@
" cosmo=cosmo,\n",
" delta_mdef=mass_Delta,\n",
" halo_profile_model=density_profile_parametrization,\n",
" r_mis=0.2\n",
" r_mis=0.2,\n",
")"
]
},
Expand Down Expand Up @@ -330,7 +332,7 @@
" delta_mdef=mass_Delta,\n",
" halo_profile_model=density_profile_parametrization,\n",
" z_src_info=\"beta\",\n",
" approx=\"order2\",\n",
" approx=\"type2\",\n",
")"
]
},
Expand Down Expand Up @@ -368,9 +370,9 @@
"metadata": {},
"outputs": [],
"source": [
"plot_profile(r3d, Sigma, \"$\\\\Sigma_{\\\\rm 2d}$\", label='R_off = No miscentering')\n",
"plot_profile(r3d, Sigma_mis, \"$\\\\Sigma_{\\\\rm 2d}$\", label='R_off = 0.2 Mpc')\n",
"plt.axvline(0.2, linestyle=':', color='k')\n",
"plot_profile(r3d, Sigma, \"$\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = No miscentering\")\n",
"plot_profile(r3d, Sigma_mis, \"$\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = 0.2 Mpc\")\n",
"plt.axvline(0.2, linestyle=\":\", color=\"k\")\n",
"plt.legend()"
]
},
Expand All @@ -380,9 +382,9 @@
"metadata": {},
"outputs": [],
"source": [
"plot_profile(r3d, DeltaSigma, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label='No miscentering')\n",
"plot_profile(r3d, DeltaSigma_mis, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label='R_off = 0.2 Mpc')\n",
"plt.axvline(0.2, linestyle=':', color='k')\n",
"plot_profile(r3d, DeltaSigma, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label=\"No miscentering\")\n",
"plot_profile(r3d, DeltaSigma_mis, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = 0.2 Mpc\")\n",
"plt.axvline(0.2, linestyle=\":\", color=\"k\")\n",
"plt.legend()"
]
},
Expand Down
32 changes: 14 additions & 18 deletions examples/demo_theory_functionality_diff_z_types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"import os\n",
"\n",
"## Uncomment the following line if you want to use a specific modeling backend among 'ct' (cluster-toolkit), 'ccl' (CCL) or 'nc' (Numcosmo). Default is 'ccl'\n",
"#os.environ['CLMM_MODELING_BACKEND'] = 'nc'"
"# os.environ['CLMM_MODELING_BACKEND'] = 'nc'"
]
},
{
Expand Down Expand Up @@ -255,14 +255,14 @@
"z_inf = 1000\n",
"\n",
"beta_s_mean_wts = clmm.utils.compute_beta_s_mean_from_weights(\n",
" source_catalog['z'],\n",
" source_catalog[\"z\"],\n",
" cluster_z,\n",
" z_inf,\n",
" cosmo,\n",
" shape_weights=None,\n",
")\n",
"beta_s_square_mean_wts = clmm.utils.compute_beta_s_square_mean_from_weights(\n",
" source_catalog['z'],\n",
" source_catalog[\"z\"],\n",
" cluster_z,\n",
" z_inf,\n",
" cosmo,\n",
Expand Down Expand Up @@ -500,7 +500,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order1\"\n",
" approx=\"type1\",\n",
")"
]
},
Expand All @@ -521,7 +521,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order2\"\n",
" approx=\"type2\",\n",
")"
]
},
Expand Down Expand Up @@ -622,7 +622,7 @@
" cosmo,\n",
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"discrete\"\n",
" z_src_info=\"discrete\",\n",
" )\n",
" )\n",
" for _r in rr\n",
Expand All @@ -639,7 +639,7 @@
" cosmo,\n",
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\"\n",
" z_src_info=\"beta\",\n",
")"
]
},
Expand All @@ -652,9 +652,7 @@
"plot_cases(\n",
" rr,\n",
" base=(gammat_discrete, \"k.-\", dict(label=\"discrete\")),\n",
" others=(\n",
" (gammat_beta, \"b--\", dict(label=\"beta, no approx\")),\n",
" ),\n",
" others=((gammat_beta, \"b--\", dict(label=\"beta, no approx\")),),\n",
" ylabel=\"$\\gamma_t$\",\n",
")"
]
Expand Down Expand Up @@ -694,7 +692,7 @@
" cosmo,\n",
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\"\n",
" z_src_info=\"beta\",\n",
")"
]
},
Expand All @@ -707,9 +705,7 @@
"plot_cases(\n",
" rr,\n",
" base=(kappa_discrete, \"k.-\", dict(label=\"discrete\")),\n",
" others=(\n",
" (kappa_beta, \"b--\", dict(label=\"beta, no approx\")),\n",
" ),\n",
" others=((kappa_beta, \"b--\", dict(label=\"beta, no approx\")),),\n",
" ylabel=\"$\\kappa_t$\",\n",
")"
]
Expand Down Expand Up @@ -750,7 +746,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order1\"\n",
" approx=\"type1\",\n",
")\n",
"\n",
"mu_beta_2 = clmm.theory.compute_magnification(\n",
Expand All @@ -763,7 +759,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order2\"\n",
" approx=\"type2\",\n",
")"
]
},
Expand Down Expand Up @@ -824,7 +820,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order1\"\n",
" approx=\"type1\",\n",
")\n",
"\n",
"mu_bias_beta_2 = clmm.theory.compute_magnification_bias(\n",
Expand All @@ -838,7 +834,7 @@
" delta_mdef=500,\n",
" massdef=\"critical\",\n",
" z_src_info=\"beta\",\n",
" approx=\"order2\"\n",
" approx=\"type2\",\n",
")"
]
},
Expand Down
30 changes: 16 additions & 14 deletions examples/demo_theory_functionality_oo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"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",
"os.environ[\"CLMM_MODELING_BACKEND\"] = (\n",
" \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n",
")\n",
"\n",
"import clmm\n",
"from clmm import Cosmology"
Expand Down Expand Up @@ -106,7 +106,9 @@
"\n",
"# source properties\n",
"z_src = 2.0 # all sources in the same plane\n",
"z_distrib_func = clmm.utils.redshift_distributions.chang2013 # sources redshift following a distribution\n",
"z_distrib_func = (\n",
" clmm.utils.redshift_distributions.chang2013\n",
") # sources redshift following a distribution\n",
"alpha = [2, -0.5]"
]
},
Expand Down Expand Up @@ -148,7 +150,7 @@
"beta_s_square_mean = clmm.utils.compute_beta_s_square_mean_from_distribution(**beta_kwargs)\n",
"\n",
"gt_z = moo.eval_reduced_tangential_shear(\n",
" r3d, z_cl, [beta_s_mean, beta_s_square_mean], z_src_info=\"beta\", approx=\"order2\"\n",
" r3d, z_cl, [beta_s_mean, beta_s_square_mean], z_src_info=\"beta\", approx=\"type2\"\n",
")\n",
"\n",
"mu = moo.eval_magnification(r3d, z_cl, z_src)\n",
Expand Down Expand Up @@ -189,11 +191,11 @@
"metadata": {},
"outputs": [],
"source": [
"plot_profile(r3d, Sigma, \"$\\\\Sigma_{\\\\rm 2d}$\", label='R_off = No miscentering')\n",
"plot_profile(r3d, Sigma_mis, \"$\\\\Sigma_{\\\\rm 2d}$\", label='R_off = 0.2 Mpc')\n",
"plt.axvline(0.2, linestyle=':', color='k')\n",
"plot_profile(r3d, Sigma, \"$\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = No miscentering\")\n",
"plot_profile(r3d, Sigma_mis, \"$\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = 0.2 Mpc\")\n",
"plt.axvline(0.2, linestyle=\":\", color=\"k\")\n",
"plt.legend()\n",
"plt.ylabel('$\\Sigma$ [$M_\\odot$ Mpc$^{-2}$]')"
"plt.ylabel(\"$\\Sigma$ [$M_\\odot$ Mpc$^{-2}$]\")"
]
},
{
Expand All @@ -202,12 +204,12 @@
"metadata": {},
"outputs": [],
"source": [
"plot_profile(r3d, DeltaSigma, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label='No miscentering')\n",
"plot_profile(r3d, DeltaSigma_mis, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label='R_off = 0.2 Mpc')\n",
"plt.axvline(0.2, linestyle=':', color='k')\n",
"plot_profile(r3d, DeltaSigma, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label=\"No miscentering\")\n",
"plot_profile(r3d, DeltaSigma_mis, \"$\\\\Delta\\\\Sigma_{\\\\rm 2d}$\", label=\"R_off = 0.2 Mpc\")\n",
"plt.axvline(0.2, linestyle=\":\", color=\"k\")\n",
"plt.legend()\n",
"plt.ylabel('$\\Delta\\Sigma$ [$M_\\odot$ Mpc$^{-2}$]')\n",
"plt.savefig('miscentering.png')"
"plt.ylabel(\"$\\Delta\\Sigma$ [$M_\\odot$ Mpc$^{-2}$]\")\n",
"plt.savefig(\"miscentering.png\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
"# clmm/theory/func_layer.py: compute_reduced_tangential_shear()\n",
"# clmm/theory/parent_class.py: eval_reduced_tangential_shear()\n",
"\n",
"# The method from Applegate et al. (2014), called 'order1' in CLMM.\n",
"# The method from Applegate et al. (2014), called 'type1' in CLMM.\n",
"# The argument \"profile\" is only used to get the radius values r = profile['radius']\n",
"# The default mass is M200m; use massdef='critical' for M200c.\n",
"\n",
Expand Down Expand Up @@ -477,12 +477,12 @@
"\n",
"\n",
"def model_reduced_tangential_shear_applegate14(logm, catalog, profile):\n",
" return _model_reduced_tangential_shear(logm, catalog, profile, approx=\"order1\")\n",
" return _model_reduced_tangential_shear(logm, catalog, profile, approx=\"type1\")\n",
"\n",
"\n",
"# Similarly, we also consider the method from Schrabback et al. (2018), called 'order2' in CLMM.\n",
"# Similarly, we also consider the method from Schrabback et al. (2018), called 'type2' in CLMM.\n",
"def model_reduced_tangential_shear_schrabback18(logm, catalog, profile):\n",
" return _model_reduced_tangential_shear(logm, catalog, profile, approx=\"order2\")"
" return _model_reduced_tangential_shear(logm, catalog, profile, approx=\"type2\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
" cluster.profile[\"gt\"],\n",
" cluster.profile[\"gt_err\"],\n",
" c=\"k\",\n",
" **errorbar_kwargs\n",
" **errorbar_kwargs,\n",
")\n",
"ax.set_xlabel(\"r [Mpc]\", fontsize=10)\n",
"ax.set_ylabel(r\"$g_t$\", fontsize=10)\n",
Expand Down Expand Up @@ -460,7 +460,7 @@
" z_cluster=cluster_z, # Redshift of the cluster\n",
" z_src=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n",
" z_src_info=\"beta\",\n",
" approx=\"order1\",\n",
" approx=\"type1\",\n",
" cosmo=cosmo,\n",
" delta_mdef=200,\n",
" massdef=\"critical\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
" cluster.profile[\"gt\"],\n",
" cluster.profile[\"gt_err\"],\n",
" c=\"k\",\n",
" **errorbar_kwargs\n",
" **errorbar_kwargs,\n",
")\n",
"ax.set_xlabel(\"R [Mpc]\", fontsize=10)\n",
"ax.set_ylabel(r\"$g_t$\", fontsize=10)\n",
Expand Down Expand Up @@ -406,7 +406,7 @@
" z_cluster=cluster_z, # Redshift of the cluster\n",
" z_src=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n",
" z_src_info=\"beta\",\n",
" approx=\"order1\",\n",
" approx=\"type1\",\n",
" cosmo=cosmo,\n",
" delta_mdef=200,\n",
" massdef=\"critical\",\n",
Expand Down
Loading
Loading