From 09d54d09351b82aaffd6460dcc617f553acf5434 Mon Sep 17 00:00:00 2001 From: Michel Aguena Date: Thu, 25 May 2023 14:44:06 +0200 Subject: [PATCH 1/4] Issue/589/python3.8 (#597) * update python version to 3.8 * update README * Update version to 1.8.1 --- README.md | 2 +- clmm/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65b269ba3..52921cf83 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ link to this repository: https://github.com/LSSTDESC/CLMM. Please follow the gui ## Requirements -CLMM requires Python version 3.6 or later. CLMM has the following dependencies: +CLMM requires Python version 3.8 or later. CLMM has the following dependencies: - [NumPy](https://www.numpy.org/) (v1.17 or later) - [SciPy](https://scipy.org/) (v1.3 or later) diff --git a/clmm/__init__.py b/clmm/__init__.py index 6855e28e7..93b2fd3c9 100644 --- a/clmm/__init__.py +++ b/clmm/__init__.py @@ -26,4 +26,4 @@ ) from . import support -__version__ = '1.8.0' +__version__ = "1.8.1" diff --git a/setup.py b/setup.py index e6c12344a..37a2745a0 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import sys version = sys.version_info -required_py_version = 3.6 +required_py_version = 3.8 if version[0] < int(required_py_version) or ( version[0] == int(required_py_version) and version[1] < required_py_version - int(required_py_version) From c6cf806cd9b542f7286187ed0ecb6432f959a767 Mon Sep 17 00:00:00 2001 From: Hsin Fan <57552401+hsinfan1996@users.noreply.github.com> Date: Tue, 13 Jun 2023 23:04:23 +0800 Subject: [PATCH 2/4] Issue/592/ccl v2.7 (#593) * Use CCL 2.7.1dev9 * add check for CCL versions * Update README, INSTALL and CONTRIBUTING * Check UnlockInstance directly * Update version to 1.8.2 --------- Co-authored-by: m-aguena Co-authored-by: m-aguena Co-authored-by: m-aguena --- CONTRIBUTING.md | 3 ++ INSTALL.md | 5 ++- README.md | 3 +- clmm/__init__.py | 2 +- clmm/theory/_ccl_supported_versions.py | 5 +++ clmm/theory/ccl.py | 16 ++++++-- tests/test_theory_be.py | 51 ++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 clmm/theory/_ccl_supported_versions.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 63941f90b..8c10de134 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,6 +49,9 @@ NOTE: Code is not complete without unit tests and documentation. Please ensure t To test this, first install the code by running `python setup.py install --user` (required after any change whatsoever to the `.py` files in `clmm/` directory). To run all of the unit tests, run `pytest` in the root package directory. To test the docs, in the root package directory after installing, run `./update_docs`. This script both deletes the old compiled documentation files and rebuilds them. You can view the compiled docs by running `open docs/_build/html/index.html`. +NOTE2: If the changes you are making affect which CCL versions are compatible with the code, +please update `clmm/theory/_ccl_supported_versions.py`, `README.md` and `INSTALL.md` accordingly. + ## Adding documentation If you are adding documentation either in the form of example jupyter notebooks or new python modules, your documentation will need to compile for our online documentation hosted by the LSST-DESC website: http://lsstdesc.org/CLMM/ diff --git a/INSTALL.md b/INSTALL.md index 62608d4d6..56d21be17 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -17,7 +17,10 @@ To create a specific conda environment for CLMM, we recommend you to check the b [Access to the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori). ### Theory backend installation -First, choose and install a theory backend for CLMM. This can be CCL (v2.1.0 or later) or NumCosmo (v0.15 or later), or cluster_toolkit and they are installable as follows. +First, choose and install a theory backend for CLMM. +This can be CCL (versions between 2.6.0 and 2.7.1.dev9+g1a351df6), +NumCosmo (v0.15 or later), +or cluster_toolkit and they are installable as follows. To install CCL as the theory/cosmology backend, run diff --git a/README.md b/README.md index 52921cf83..04228a536 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,10 @@ CLMM requires Python version 3.8 or later. CLMM has the following dependencies: For the theoretical predictions of the signal, CLMM relies on existing libraries and **at least one of the following must be installed as well**: - [cluster-toolkit](https://cluster-toolkit.readthedocs.io/en/latest/) -- [CCL](https://ccl.readthedocs.io/en/latest/) (v2.6 or later) +- [CCL](https://ccl.readthedocs.io/en/latest/) (versions between 2.6.0 and 2.7.1.dev9+g1a351df6) - [NumCosmo](https://numcosmo.github.io/) (v0.15 or later) + (See the [INSTALL documentation](INSTALL.md) for more detailed installation instructions.) For developers, you will also need to install: diff --git a/clmm/__init__.py b/clmm/__init__.py index 93b2fd3c9..f2e5e440d 100644 --- a/clmm/__init__.py +++ b/clmm/__init__.py @@ -26,4 +26,4 @@ ) from . import support -__version__ = "1.8.1" +__version__ = "1.8.2" diff --git a/clmm/theory/_ccl_supported_versions.py b/clmm/theory/_ccl_supported_versions.py new file mode 100644 index 000000000..52ab799ff --- /dev/null +++ b/clmm/theory/_ccl_supported_versions.py @@ -0,0 +1,5 @@ +"""@file _ccl_supported_versions.py +Versions of CCL supported by the current CLMM version +""" +VMIN = '2.6.0' +VMAX = '2.7.1.dev9+g1a351df6' diff --git a/clmm/theory/ccl.py b/clmm/theory/ccl.py index 8827b5b79..654af72b2 100644 --- a/clmm/theory/ccl.py +++ b/clmm/theory/ccl.py @@ -10,6 +10,17 @@ from ..cosmology.ccl import CCLCosmology from .parent_class import CLMModeling +# Check which versions of ccl are currently supported +from . import _ccl_supported_versions + +if parse(ccl.__version__) < parse(_ccl_supported_versions.VMIN) or parse(ccl.__version__) > parse( + _ccl_supported_versions.VMAX +): + raise EnvironmentError( + f"Current CCL version ({ccl.__version__}) not supported by CLMM. " + f"It must be between {_ccl_supported_versions.VMIN} and {_ccl_supported_versions.VMAX}." + ) + class CCLCLMModeling(CLMModeling): r"""Object with functions for halo mass modeling @@ -89,9 +100,6 @@ def _update_halo_density_profile(self): """updates halo density profile with set internal properties""" # prepare mdef object self.mdef = ccl.halos.MassDef(self.delta_mdef, self.mdef_dict[self.massdef]) - # adjust it for ccl version > 2.6.1 - if parse(ccl.__version__) >= parse("2.6.2dev7"): - ccl.UnlockInstance.Funlock(type(self.mdef), "_concentration_init", True) # setting concentration (also updates hdpm) self.cdelta = self.cdelta if self.hdpm else 4.0 # ccl always needs an input concentration @@ -107,6 +115,8 @@ def _set_concentration(self, cdelta): """set concentration. Also sets/updates hdpm""" # pylint: disable=protected-access self.conc = ccl.halos.ConcentrationConstant(c=cdelta, mdef=self.mdef) + if hasattr(ccl, 'UnlockInstance'): + ccl.UnlockInstance.Funlock(type(self.mdef), "_concentration_init", True) self.mdef._concentration_init(self.conc) self.hdpm = self.hdpm_dict[self.halo_profile_model]( self.conc, **self.hdpm_opts[self.halo_profile_model] diff --git a/tests/test_theory_be.py b/tests/test_theory_be.py index 863a6b5c0..c126b537b 100644 --- a/tests/test_theory_be.py +++ b/tests/test_theory_be.py @@ -1,5 +1,6 @@ """Tests for backend of theory.py""" import importlib +import pytest from numpy.testing import assert_raises @@ -48,3 +49,53 @@ def nie(): # restore original code that will be monkeypatched here clmm.theory.Modeling = Modeling_safe clmm.theory.__backends = backends_safe + + +def get_ccl_versions_from_md(filename): + lines = [l for l in open(filename).readlines() if "CCL" and "versions between" in l] + if len(lines) != 1: + raise SyntaxError(f"Number of lines with CCL version (={len(lines)}) is not 1.") + vmin = lines[0].split("versions between ")[1].split(" and ")[0] + vmax = lines[0].split(" and ")[1].split(")")[0] + return vmin, vmax + + +def test_documented_ccl_versions_consistency(): + from clmm.theory import _ccl_supported_versions + + # Compare to readme + vmin, vmax = get_ccl_versions_from_md("README.md") + assert vmin == _ccl_supported_versions.VMIN + assert vmax == _ccl_supported_versions.VMAX + + # Compare to install + vmin, vmax = get_ccl_versions_from_md("INSTALL.md") + assert vmin == _ccl_supported_versions.VMIN + assert vmax == _ccl_supported_versions.VMAX + + +def test_clmm_versioning_error(): + import os + + try: + import clmm + + avail = clmm.theory.backend_is_available("ccl") + except ValueError: + pytest.skip(f"CCL backend not available'.") + + if avail: + from clmm.theory import _ccl_supported_versions + + vmin_safe = _ccl_supported_versions.VMIN + vmax_safe = _ccl_supported_versions.VMAX + + _ccl_supported_versions.VMIN = "999" + _ccl_supported_versions.VMAX = "999" + + os.environ["CLMM_MODELING_BACKEND"] = "ccl" + + assert_raises(EnvironmentError, importlib.reload, clmm.theory.ccl) + + _ccl_supported_versions.VMIN = vmin_safe + _ccl_supported_versions.VMAX = vmax_safe From 8e97b4a19773e0241547aeaaf8ce5c11d9288e59 Mon Sep 17 00:00:00 2001 From: Hsin Fan <57552401+hsinfan1996@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:35:36 +0800 Subject: [PATCH 3/4] Issue/592/ccl v3 (#595) * Update for CCL v3 * Fix docs compiling * Remove warning filter * Update generate_einasto_hernquist_benchmarks_fromNC.ipynb * Remove concentration from MassDef * Fix profile name validation * Add virial massdef properly * Add use_projected_quad * Remove virial massdef from CT backend * Use --override-channels in build_check.yml * Update version to 1.9.0 --------- Co-authored-by: m-aguena --- .github/workflows/build_check.yml | 6 +- INSTALL.md | 2 +- README.md | 2 +- clmm/__init__.py | 2 +- clmm/cosmology/ccl.py | 2 +- clmm/theory/_ccl_supported_versions.py | 4 +- clmm/theory/ccl.py | 32 +-- clmm/theory/cluster_toolkit.py | 11 +- clmm/theory/func_layer.py | 29 ++- clmm/theory/generic.py | 14 +- clmm/theory/numcosmo.py | 4 +- clmm/theory/parent_class.py | 43 +++- docs/conf.py | 2 +- examples/Paper_v1.0/gt_and_use_case.ipynb | 1 + .../Paper_v1.0/mass_bias_from_models.ipynb | 34 +-- examples/Paper_v1.0/validation_tests.ipynb | 74 ++++--- examples/demo_boost_factors.ipynb | 4 +- examples/demo_mass_conversion.ipynb | 3 - examples/demo_mock_cluster.ipynb | 3 - examples/demo_mock_ensemble_realistic.ipynb | 16 +- examples/demo_theory_functionality.ipynb | 74 ++++++- ...mo_theory_functionality_diff_z_types.ipynb | 3 - examples/demo_theory_functionality_oo.ipynb | 52 +++-- .../other_compare_NFW_critical_massdef.ipynb | 28 +-- setup.py | 2 +- ..._einasto_hernquist_benchmarks_fromNC.ipynb | 16 +- .../data/numcosmo/radial_profiles_einasto.txt | 200 +++++++++--------- tests/test_theory.py | 23 ++ tests/test_theory_parent.py | 26 +++ 29 files changed, 444 insertions(+), 268 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index cd2c2d4fe..a87a0a0bc 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v2 - name: Install prereq using conda run: | @@ -33,10 +33,10 @@ jobs: pip install . - name: Install CCL from source run: | - conda install -c conda-forge cmake swig + conda install -c conda-forge cmake swig --override-channels git clone https://github.com/LSSTDESC/CCL cd CCL - git checkout 1a351df + git checkout v3.0.0 pip install . - name: Analysing the code with pylint run: | diff --git a/INSTALL.md b/INSTALL.md index 56d21be17..16df96a02 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,7 +18,7 @@ To create a specific conda environment for CLMM, we recommend you to check the b ### Theory backend installation First, choose and install a theory backend for CLMM. -This can be CCL (versions between 2.6.0 and 2.7.1.dev9+g1a351df6), +This can be CCL (versions between 2.7.1.dev10+gf81b59a4 and 3), NumCosmo (v0.15 or later), or cluster_toolkit and they are installable as follows. diff --git a/README.md b/README.md index 04228a536..e05debf93 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ CLMM requires Python version 3.8 or later. CLMM has the following dependencies: For the theoretical predictions of the signal, CLMM relies on existing libraries and **at least one of the following must be installed as well**: - [cluster-toolkit](https://cluster-toolkit.readthedocs.io/en/latest/) -- [CCL](https://ccl.readthedocs.io/en/latest/) (versions between 2.6.0 and 2.7.1.dev9+g1a351df6) +- [CCL](https://ccl.readthedocs.io/en/latest/) (versions between 2.7.1.dev10+gf81b59a4 and 3) - [NumCosmo](https://numcosmo.github.io/) (v0.15 or later) diff --git a/clmm/__init__.py b/clmm/__init__.py index f2e5e440d..4071ee026 100644 --- a/clmm/__init__.py +++ b/clmm/__init__.py @@ -26,4 +26,4 @@ ) from . import support -__version__ = "1.8.2" +__version__ = "1.9.0" diff --git a/clmm/cosmology/ccl.py b/clmm/cosmology/ccl.py index 1998bcd13..def7c9927 100644 --- a/clmm/cosmology/ccl.py +++ b/clmm/cosmology/ccl.py @@ -113,7 +113,7 @@ def _eval_sigma_crit_core(self, z_len, z_src): a_len = self.get_a_from_z(z_len) a_src = self.get_a_from_z(z_src) - return self.be_cosmo.sigma_critical(a_len, a_src) * self.cor_factor + return self.be_cosmo.sigma_critical(a_lens=a_len, a_source=a_src) * self.cor_factor def _eval_linear_matter_powerspectrum(self, k_vals, redshift): return ccl.linear_matter_power(self.be_cosmo, k_vals, self.get_a_from_z(redshift)) diff --git a/clmm/theory/_ccl_supported_versions.py b/clmm/theory/_ccl_supported_versions.py index 52ab799ff..9d6c62bf2 100644 --- a/clmm/theory/_ccl_supported_versions.py +++ b/clmm/theory/_ccl_supported_versions.py @@ -1,5 +1,5 @@ """@file _ccl_supported_versions.py Versions of CCL supported by the current CLMM version """ -VMIN = '2.6.0' -VMAX = '2.7.1.dev9+g1a351df6' +VMIN = "2.7.1.dev10+gf81b59a4" +VMAX = "3" diff --git a/clmm/theory/ccl.py b/clmm/theory/ccl.py index 654af72b2..e95271031 100644 --- a/clmm/theory/ccl.py +++ b/clmm/theory/ccl.py @@ -30,11 +30,11 @@ class CCLCLMModeling(CLMModeling): backend: str Name of the backend being used massdef : str - Profile mass definition (`mean`, `critical`, `virial` - letter case independent) + Profile mass definition ("mean", "critical", "virial" - letter case independent) delta_mdef : int Mass overdensity definition. halo_profile_model : str - Profile model parameterization (`nfw`, `einasto`, `hernquist` - letter case independent) + Profile model parameterization ("nfw", "einasto", "hernquist" - letter case independent) cosmo: Cosmology Cosmology object hdpm: Object @@ -94,12 +94,22 @@ def __init__( self.set_halo_density_profile(halo_profile_model, massdef, delta_mdef) self.set_cosmo(None) + def _set_projected_quad(self, use_projected_quad): + if hasattr(self.hdpm, "projected_quad"): + self.hdpm_opts["einasto"]["projected_quad"] = use_projected_quad + self._update_halo_density_profile() + else: + raise NotImplementedError("projected_quad is not available on this version of CCL.") + # Functions implemented by child class def _update_halo_density_profile(self): """updates halo density profile with set internal properties""" # prepare mdef object - self.mdef = ccl.halos.MassDef(self.delta_mdef, self.mdef_dict[self.massdef]) + if self.massdef == "virial": + self.mdef = ccl.halos.MassDef("vir", self.mdef_dict[self.massdef]) + else: + self.mdef = ccl.halos.MassDef(self.delta_mdef, self.mdef_dict[self.massdef]) # setting concentration (also updates hdpm) self.cdelta = self.cdelta if self.hdpm else 4.0 # ccl always needs an input concentration @@ -113,13 +123,9 @@ def _get_mass(self): def _set_concentration(self, cdelta): """set concentration. Also sets/updates hdpm""" - # pylint: disable=protected-access - self.conc = ccl.halos.ConcentrationConstant(c=cdelta, mdef=self.mdef) - if hasattr(ccl, 'UnlockInstance'): - ccl.UnlockInstance.Funlock(type(self.mdef), "_concentration_init", True) - self.mdef._concentration_init(self.conc) + self.conc = ccl.halos.ConcentrationConstant(c=cdelta, mass_def=self.mdef) self.hdpm = self.hdpm_dict[self.halo_profile_model]( - self.conc, **self.hdpm_opts[self.halo_profile_model] + concentration=self.conc, mass_def=self.mdef, **self.hdpm_opts[self.halo_profile_model] ) self.hdpm.update_precision_fftlog(padding_lo_fftlog=1e-4, padding_hi_fftlog=1e3) @@ -140,7 +146,7 @@ def _get_einasto_alpha(self, z_cl=None): a_cl = 1 # a_cl does not matter in this case else: a_cl = self.cosmo.get_a_from_z(z_cl) - return self.hdpm._get_alpha(self.cosmo.be_cosmo, self.__mdelta_cor, a_cl, self.mdef) + return self.hdpm._get_alpha(self.cosmo.be_cosmo, self.__mdelta_cor, a_cl) def _eval_3d_density(self, r3d, z_cl): """eval 3d density""" @@ -188,7 +194,6 @@ def _call_ccl_profile_lens(self, ccl_hdpm_func, radius, z_lens, ndim=2): radius / a_lens, self.__mdelta_cor, a_lens, - self.mdef, ) * self.cor_factor / a_lens**ndim @@ -203,9 +208,8 @@ def _call_ccl_profile_lens_src(self, ccl_hdpm_func, radius, z_lens, z_src): self.cosmo.be_cosmo, radius / a_lens, self.__mdelta_cor, - a_lens, - a_src, - self.mdef, + a_lens=a_lens, + a_source=a_src, ) diff --git a/clmm/theory/cluster_toolkit.py b/clmm/theory/cluster_toolkit.py index 2dd3a7d69..6b9e33400 100644 --- a/clmm/theory/cluster_toolkit.py +++ b/clmm/theory/cluster_toolkit.py @@ -25,7 +25,7 @@ def _assert_correct_type_ct(arg): Returns ------- - scale_factor : array_like + scale_factor : numpy.ndarray Scale factor """ if np.isscalar(arg): @@ -41,11 +41,11 @@ class CTCLMModeling(CLMModeling): backend: str Name of the backend being used massdef : str - Profile mass definition (`mean`, `critical`, `virial` - letter case independent) + Profile mass definition ("mean", "critical" - letter case independent) delta_mdef : int Mass overdensity definition. halo_profile_model : str - Profile model parameterization (`nfw`, `einasto`, `hernquist` - letter case independent) + Profile model parameterization ("nfw" - letter case independent) cosmo: Cosmology Cosmology object hdpm: Object @@ -85,7 +85,6 @@ def __init__( self.mdef_dict = { "mean": self.cosmo.get_E2Omega_m, "critical": self.cosmo.get_E2, - "virial": self.cosmo.get_E2, } self.set_halo_density_profile(halo_profile_model, massdef, delta_mdef) @@ -145,7 +144,7 @@ def _eval_surface_density(self, r_proj, z_cl): ) # pc**-2 to Mpc**-2 def _eval_mean_surface_density(self, r_proj, z_cl): - r"""Computes the mean value of surface density inside radius r_proj + r"""Computes the mean value of surface density inside radius `r_proj` Parameters ---------- @@ -156,7 +155,7 @@ def _eval_mean_surface_density(self, r_proj, z_cl): Returns ------- - array_like, float + numpy.ndarray, float Excess surface density in units of :math:`M_\odot\ Mpc^{-2}`. Note diff --git a/clmm/theory/func_layer.py b/clmm/theory/func_layer.py index c3695453b..0eb2d50c5 100644 --- a/clmm/theory/func_layer.py +++ b/clmm/theory/func_layer.py @@ -5,7 +5,7 @@ # pylint: disable=invalid-name # Thin functonal layer on top of the class implementation of CLMModeling . # The functions expect a global instance of the actual CLMModeling named -# `_modeling_object'. +# "_modeling_object". import numpy as np @@ -109,6 +109,7 @@ def compute_surface_density( massdef="mean", alpha_ein=None, verbose=False, + use_projected_quad=False, validate_input=True, ): r"""Computes the surface mass density @@ -154,6 +155,10 @@ def compute_surface_density( verbose : boolean, optional If True, the Einasto slope (alpha_ein) is printed out. Only available for the NC and CCL backends. + use_projected_quad : bool + Only available for Einasto profile with CCL as the backend. If True, CCL will use + quad_vec instead of default FFTLog to calculate the surface density profile. + Default: False validate_input : bool, optional If True (default), the types of the arguments are checked before proceeding. @@ -176,6 +181,8 @@ def compute_surface_density( _modeling_object.set_mass(mdelta) if halo_profile_model == "einasto" or alpha_ein is not None: _modeling_object.set_einasto_alpha(alpha_ein) + if halo_profile_model == "einasto" and _modeling_object.backend=="ccl": + _modeling_object.set_projected_quad(use_projected_quad) sigma = _modeling_object.eval_surface_density(r_proj, z_cl, verbose=verbose) @@ -358,7 +365,7 @@ def compute_excess_surface_density_2h( .. math:: \Delta\Sigma_{\text{2h}}(R) = \frac{\rho_m(z)b(M)}{(1 + z)^3D_A(z)^2} - \int\frac{ldl}{(2\pi)} P_{\rm mm}(k_l, z)J_2(l\theta) + \int\frac{ldl}{(2\pi)} P_{\text{mm}}(k_l, z)J_2(l\theta) where @@ -424,13 +431,13 @@ def compute_surface_density_2h( r"""Computes the 2-halo term surface density from eq.(13) of Oguri & Hamana (2011) .. math:: - \Sigma_{\rm 2h}(R) = \frac{\rho_m(z)b(M)}{(1 + z)^3D_A(z)^2} \int\frac{ldl}{(2\pi)} - P_{\rm mm}(k_l, z)J_0(l\theta) + \Sigma_{\text{2h}}(R) = \frac{\rho_\text{m}(z)b(M)}{(1 + z)^3D_A(z)^2} + \int\frac{ldl}{(2\pi)}P_{\text{mm}}(k_l, z)J_0(l\theta) where .. math:: - k_l = \frac{l}{D_A(z)(1 +z)} + k_l = \frac{l}{D_A(z)(1 + z)} and :math:`b(M)` is the halo bias @@ -481,14 +488,14 @@ def compute_critical_surface_density_eff(cosmo, z_cluster, pzbins, pzpdf, valida r"""Computes the 'effective critical surface density' .. math:: - \langle \Sigma_{\rm crit}^{-1}\rangle^{-1} = \left(\int \frac{1}{\Sigma_{\rm crit}(z)} - p(z) dz\right)^{-1} + \langle \Sigma_{\text{crit}}^{-1}\rangle^{-1} = + \left(\int \frac{1}{\Sigma_{\text{crit}}(z)}p(z) \mathrm{d}z\right)^{-1} where :math:`p(z)` is the source photoz probability density function. This comes from the maximum likelihood estimator for evaluating a :math:`\Delta\Sigma` profile. - For the standard :math:`\Sigma_{\rm crit}(z)` definition, use the `eval_sigma_crit` method of + For the standard :math:`\Sigma_{\text{crit}}(z)` definition, use the `eval_sigma_crit` method of the CLMM cosmology object. Parameters @@ -841,9 +848,9 @@ def compute_reduced_tangential_shear( massdef : str, optional Profile mass definition, with the following supported options (letter case independent): - * `mean` (default); - * `critical` - not in cluster_toolkit; - * `virial` - not in cluster_toolkit; + * 'mean' (default); + * 'critical' - not in cluster_toolkit; + * 'virial' - not in cluster_toolkit; alpha_ein : float, None, optional If `halo_profile_model=='einasto'`, set the value of the Einasto slope. diff --git a/clmm/theory/generic.py b/clmm/theory/generic.py index 4e6a68c4a..e28754d7c 100644 --- a/clmm/theory/generic.py +++ b/clmm/theory/generic.py @@ -85,7 +85,7 @@ def compute_rdelta(mdelta, redshift, cosmo, massdef="mean", delta_mdef=200): cosmo : clmm.Cosmology Cosmology object massdef : str, None - Profile mass definition (`mean`, `critical`, `virial`). + Profile mass definition ("mean", "critical", "virial"). delta_mdef : int, None Mass overdensity definition. @@ -151,11 +151,11 @@ def compute_profile_mass_in_radius( cdelta : float Concentration of the profile. massdef : str, None - Profile mass definition (`mean`, `critical`, `virial`). + Profile mass definition ("mean", "critical", "virial"). delta_mdef : int, None Mass overdensity definition. halo_profile_model : str - Profile model parameterization (`nfw`, `einasto`, `hernquist`). + Profile model parameterization ("nfw", "einasto", "hernquist"). alpha : float, None Einasto slope, required when `halo_profile_model='einasto'`. @@ -209,19 +209,19 @@ def convert_profile_mass_concentration( cosmo : clmm.Cosmology Cosmology object massdef : str, None - Input profile mass definition (`mean`, `critical`, `virial`). + Input profile mass definition ("mean", "critical", "virial"). delta_mdef : int, None Input mass overdensity definition. halo_profile_model : str, None - Input profile model parameterization (`nfw`, `einasto`, `hernquist`). + Input profile model parameterization ("nfw", "einasto", "hernquist"). massdef2 : str, None - Profile mass definition to convert to (`mean`, `critical`, `virial`). + Profile mass definition to convert to ("mean", "critical", "virial"). If None, `massdef2=massdef`. delta_mdef2 : int, None Mass overdensity definition to convert to. If None, `delta_mdef2=delta_mdef`. halo_profile_model2 : str, None - Profile model parameterization to convert to (`nfw`, `einasto`, `hernquist`). + Profile model parameterization to convert to ("nfw", "einasto", "hernquist"). If None, `halo_profile_model2=halo_profile_model`. alpha : float, None Input Einasto slope when `halo_profile_model='einasto'`. diff --git a/clmm/theory/numcosmo.py b/clmm/theory/numcosmo.py index 556c22bd5..8902abee4 100644 --- a/clmm/theory/numcosmo.py +++ b/clmm/theory/numcosmo.py @@ -23,11 +23,11 @@ class NumCosmoCLMModeling(CLMModeling): backend: str Name of the backend being used massdef : str - Profile mass definition (`mean`, `critical`, `virial` - letter case independent) + Profile mass definition ("mean", "critical", "virial" - letter case independent) delta_mdef : int Mass overdensity definition. halo_profile_model : str - Profile model parameterization (`nfw`, `einasto`, `hernquist` - letter case independent) + Profile model parameterization ("nfw", "einasto", "hernquist" - letter case independent) cosmo: Cosmology Cosmology object hdpm: Object diff --git a/clmm/theory/parent_class.py b/clmm/theory/parent_class.py index 404b1577d..d27b8f7c6 100644 --- a/clmm/theory/parent_class.py +++ b/clmm/theory/parent_class.py @@ -45,11 +45,11 @@ class CLMModeling: cdelta: float Concentration of the profile massdef : str - Profile mass definition (`mean`, `critical`, `virial` - letter case independent) + Profile mass definition ("mean", "critical", "virial" - letter case independent) delta_mdef : int Mass overdensity definition. halo_profile_model : str - Profile model parameterization (`nfw`, `einasto`, `hernquist` - letter case independent) + Profile model parameterization ("nfw", "einasto", "hernquist" - letter case independent) cosmo: Cosmology Cosmology object hdpm: Object @@ -181,6 +181,10 @@ def _get_einasto_alpha(self, z_cl=None): if defined""" raise NotImplementedError + def _set_projected_quad(self, use_projected_quad): + """Implemented for the CCL backend only""" + raise NotImplementedError + def _eval_3d_density(self, r3d, z_cl): raise NotImplementedError @@ -376,17 +380,20 @@ def set_halo_density_profile(self, halo_profile_model="nfw", massdef="mean", del Parameters ---------- halo_profile_model: str - Halo mass profile, current options are 'nfw' (letter case independent) + Halo mass profile, supported options are 'nfw', 'einasto', 'hernquist' + (letter case independent) massdef: str - Mass definition, current options are 'mean' (letter case independent) + Mass definition, supported options are 'mean', 'critical', 'virial' + (letter case independent) delta_mdef: int Overdensity number """ # make case independent + validate_argument(locals(), "massdef", str) + validate_argument(locals(), "halo_profile_model", str) massdef, halo_profile_model = massdef.lower(), halo_profile_model.lower() + if self.validate_input: - validate_argument(locals(), "massdef", str) - validate_argument(locals(), "halo_profile_model", str) validate_argument(locals(), "delta_mdef", int, argmin=0) if massdef not in self.mdef_dict: raise ValueError( @@ -441,6 +448,22 @@ def get_einasto_alpha(self, z_cl=None): raise ValueError(f"Wrong profile model. Current profile = {self.halo_profile_model}") return self._get_einasto_alpha(z_cl) + def set_projected_quad(self, use_projected_quad): + r"""Control the use of quad_vec to calculate the surface density profile for + CCL Einasto profile. + + Parameters + ---------- + use_projected_quad : bool + Only available for Einasto profile with CCL as the backend. If True, CCL will use + quad_vec instead of default FFTLog to calculate the surface density profile. + """ + if self.halo_profile_model != "einasto" or self.backend != "ccl": + raise NotImplementedError("This option is only available for the CCL Einasto profile.") + if self.validate_input: + validate_argument(locals(), "use_projected_quad", bool) + self._set_projected_quad(use_projected_quad) + def eval_3d_density(self, r3d, z_cl, verbose=False): r"""Retrieve the 3d density :math:`\rho(r)`. @@ -476,8 +499,8 @@ def eval_critical_surface_density_eff(self, z_len, pzbins, pzpdf): This comes from the maximum likelihood estimator for evaluating a :math:`\Delta\Sigma` profile. - For the standard :math:`\Sigma_{\rm crit}(z)` definition, use the `eval_sigma_crit` method - of the CLMM cosmology object. + For the standard :math:`\Sigma_{\text{crit}}(z)` definition, use the `eval_sigma_crit` + method of the CLMM cosmology object. Parameters ---------- @@ -1691,13 +1714,13 @@ def convert_mass_concentration( z_cl: float Redshift of the cluster massdef : str, None - Profile mass definition to convert to (`mean`, `critical`, `virial`). + Profile mass definition to convert to ("mean", "critical", "virial"). If None, same value of current model is used. delta_mdef : int, None Mass overdensity definition to convert to. If None, same value of current model is used. halo_profile_model : str, None - Profile model parameterization to convert to (`nfw`, `einasto`, `hernquist`). + Profile model parameterization to convert to ("nfw", "einasto", "hernquist"). If None, same value of current model is used. alpha : float, None Einasto slope to convert to when `halo_profile_model='einasto'`. diff --git a/docs/conf.py b/docs/conf.py index a91ddf9e8..bfafb1750 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,7 @@ # Fix for ccl sys.modules["pyccl"].Cosmology = MagicMock -sys.modules["pyccl"].__version__ = "2.6" +sys.modules["pyccl"].__version__ = "3" # Fix for numcosmo sys.modules["gi.repository"].NumCosmo.Distance = MagicMock diff --git a/examples/Paper_v1.0/gt_and_use_case.ipynb b/examples/Paper_v1.0/gt_and_use_case.ipynb index a27f93b03..31c94f3ea 100644 --- a/examples/Paper_v1.0/gt_and_use_case.ipynb +++ b/examples/Paper_v1.0/gt_and_use_case.ipynb @@ -100,6 +100,7 @@ " photoz_sigma_unscaled=0.05, # Photo-z errors to source redshifts\n", " field_size=field_size,\n", " ngal_density=20, # number of gal/arcmin2 for z in [0, infty]\n", + " pzpdf_type='individual_bins',\n", ")[\"ra\", \"dec\", \"e1\", \"e2\", \"z\", \"ztrue\", \"pzbins\", \"pzpdf\", \"id\"]\n", "print(f'Catalog table with the columns: {\", \".join(mock_galaxies.colnames)}')\n", "\n", diff --git a/examples/Paper_v1.0/mass_bias_from_models.ipynb b/examples/Paper_v1.0/mass_bias_from_models.ipynb index 4786f7ccb..00f5b00b6 100644 --- a/examples/Paper_v1.0/mass_bias_from_models.ipynb +++ b/examples/Paper_v1.0/mass_bias_from_models.ipynb @@ -150,20 +150,22 @@ "# CCL\n", "MDEF = \"matter\"\n", "mdef = ccl.halos.MassDef(Delta, MDEF)\n", - "conc = ccl.halos.ConcentrationConstant(cvir)\n", - "mdef.concentration = conc\n", + "conc = ccl.halos.ConcentrationConstant(cvir, mass_def=mdef)\n", + "\n", "ccl_nfw_num = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=False, cumul2d_analytic=False\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=False, cumul2d_analytic=False\n", ")\n", "ccl_nfw_ana = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=True, cumul2d_analytic=True\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=True, cumul2d_analytic=True\n", ")\n", "# ccl_nfw_num.update_precision_fftlog (n_per_decade = 1200)\n", - "ccl_ein = ccl.halos.HaloProfileEinasto(conc, truncated=False)\n", - "ccl_her = ccl.halos.HaloProfileHernquist(conc, truncated=False)\n", + "ccl_ein = ccl.halos.HaloProfileEinasto(mass_def=mdef, concentration=conc, truncated=False)\n", + "ccl_her = ccl.halos.HaloProfileHernquist(mass_def=mdef, concentration=conc, truncated=False)\n", "\n", "\n", - "alpha = ccl_ein._get_alpha(cosmo_ccl, Mvir, a, mdef)" + "alpha = ccl_ein._get_alpha(cosmo_ccl, Mvir, a)" ] }, { @@ -239,8 +241,8 @@ "\n", "\n", "# CCL\n", - "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", - "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_nfw_ana = ccl_BarSigma_nfw_ana - ccl_Sigma_nfw_ana" ] }, @@ -262,8 +264,8 @@ "source": [ "def model_ref_nfw(r, logm, bias):\n", " m = 10.0**logm\n", - " tmp_Sigma = ccl_nfw_ana.projected(cosmo_ccl, r / a, m, a, mdef) / a**2\n", - " tmp_BarSigma = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, m, a, mdef) / a**2\n", + " tmp_Sigma = ccl_nfw_ana.projected(cosmo_ccl, r / a, m, a) / a**2\n", + " tmp_BarSigma = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, m, a) / a**2\n", " model = (tmp_BarSigma - tmp_Sigma) * (1 + bias)\n", " return model\n", "\n", @@ -346,8 +348,8 @@ "# CCL numerical\n", "def model_num_ccl(r, logm):\n", " m = 10.0**logm\n", - " tmp_Sigma = ccl_nfw_num.projected(cosmo_ccl, r / a, m, a, mdef) / a**2\n", - " tmp_BarSigma = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, m, a, mdef) / a**2\n", + " tmp_Sigma = ccl_nfw_num.projected(cosmo_ccl, r / a, m, a) / a**2\n", + " tmp_BarSigma = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, m, a) / a**2\n", " model = tmp_BarSigma - tmp_Sigma\n", " return model" ] @@ -543,9 +545,9 @@ ], "metadata": { "kernelspec": { - "display_name": "mydesc3", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "mydesc3" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -557,7 +559,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/examples/Paper_v1.0/validation_tests.ipynb b/examples/Paper_v1.0/validation_tests.ipynb index 74a6735cd..6d8ddb9c3 100644 --- a/examples/Paper_v1.0/validation_tests.ipynb +++ b/examples/Paper_v1.0/validation_tests.ipynb @@ -2,7 +2,9 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true + }, "source": [ "# Validation tests for the CLMM backends\n", "\n", @@ -161,28 +163,34 @@ "\n", "# CCL\n", "MDEF = \"matter\"\n", - "conc = ccl.halos.ConcentrationConstant(cvir)\n", - "mdef = ccl.halos.MassDef(Delta, \"matter\", c_m_relation=conc)\n", + "mdef = ccl.halos.MassDef(Delta, MDEF)\n", + "conc = ccl.halos.ConcentrationConstant(cvir, mass_def=mdef)\n", "# mdef.concentration = conc\n", "\n", "ccl_nfw_num_opt = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=False, cumul2d_analytic=False, fourier_analytic=False\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=False, cumul2d_analytic=False, fourier_analytic=False\n", ")\n", "ccl_nfw_num = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=False, cumul2d_analytic=False\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=False, cumul2d_analytic=False\n", ")\n", "ccl_nfw_ana = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=True, cumul2d_analytic=True\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=True, cumul2d_analytic=True\n", ")\n", "\n", "# ccl_nfw_num.update_precision_fftlog (n_per_decade = 10000)\n", "# ccl_nfw_num.update_precision_fftlog (plaw_fourier = -2)\n", "\n", - "ccl_ein = ccl.halos.HaloProfileEinasto(conc, truncated=False)\n", - "ccl_her = ccl.halos.HaloProfileHernquist(conc, truncated=False)\n", + "ccl_ein = ccl.halos.HaloProfileEinasto(mass_def=mdef, concentration=conc,\n", + " truncated=False)\n", + "ccl_ein_quad = ccl.halos.HaloProfileEinasto(mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_quad=True)\n", + "ccl_her = ccl.halos.HaloProfileHernquist(mass_def=mdef, concentration=conc, truncated=False)\n", "\n", "\n", - "alpha = ccl_ein._get_alpha(cosmo_ccl, Mvir, a, mdef)\n", + "alpha = ccl_ein._get_alpha(cosmo_ccl, Mvir, a)\n", "\n", "# Colossus\n", "col_nfw = profile_nfw.NFWProfile(M=(Mvir * cosmo_col.h), c=cvir, z=z, mdef=\"200m\")\n", @@ -277,10 +285,11 @@ "nc_Sigma_her = smd.sigma_array(nc_her, cosmo, r, 1.0, 1.0, z)\n", "\n", "# CCL\n", - "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", - "ccl_Sigma_nfw_num = ccl_nfw_num.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", - "ccl_Sigma_ein = ccl_ein.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", - "ccl_Sigma_her = ccl_her.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_Sigma_nfw_num = ccl_nfw_num.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_Sigma_ein = ccl_ein.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_Sigma_ein_quad = ccl_ein.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_Sigma_her = ccl_her.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", "\n", "\n", "# CCL numerical NFW, using optimised setup\n", @@ -288,15 +297,15 @@ "# better by first evaluating the profile on a wider range and then\n", "# interpolating to the desired radii\n", "rtmp = np.geomspace(1.0e-4, 100, 1000)\n", - "tmp = ccl_nfw_num_opt.projected(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_nfw_num_opt.projected(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_Sigma_nfw_num_opt = np.exp(ptf(np.log(r)))\n", "\n", - "tmp = ccl_ein.projected(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_ein.projected(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_Sigma_ein_opt = np.exp(ptf(np.log(r)))\n", "\n", - "tmp = ccl_her.projected(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_her.projected(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_Sigma_her_opt = np.exp(ptf(np.log(r)))\n", "\n", @@ -335,15 +344,15 @@ "nc_DeltaSigma_her = np.array(smd.sigma_excess_array(nc_her, cosmo, r, 1.0, 1.0, z))\n", "\n", "# CCL\n", - "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_nfw_ana = ccl_BarSigma_nfw_ana - ccl_Sigma_nfw_ana\n", "\n", "# CCL numerical NFW, using default setup\n", - "ccl_BarSigma_nfw_num = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_nfw_num = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_nfw_num = ccl_BarSigma_nfw_num - ccl_Sigma_nfw_num\n", - "ccl_BarSigma_ein = ccl_ein.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_ein = ccl_ein.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_ein = ccl_BarSigma_ein - ccl_Sigma_ein\n", - "ccl_BarSigma_her = ccl_her.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_her = ccl_her.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_her = ccl_BarSigma_her - ccl_Sigma_her\n", "\n", "\n", @@ -353,17 +362,17 @@ "# interpolating to the desired radii\n", "\n", "rtmp = np.geomspace(1.0e-4, 100, 1000) # extended radial range\n", - "tmp = ccl_nfw_num_opt.cumul2d(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2 # CCL estimation\n", + "tmp = ccl_nfw_num_opt.cumul2d(cosmo_ccl, rtmp / a, Mvir, a) / a**2 # CCL estimation\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100) # interpolation\n", "ccl_BarSigma_nfw_num_opt = np.exp(ptf(np.log(r))) # evaluation on the desired radius array\n", "ccl_DeltaSigma_nfw_num_opt = ccl_BarSigma_nfw_num_opt - ccl_Sigma_nfw_num_opt\n", "\n", - "tmp = ccl_ein.cumul2d(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_ein.cumul2d(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_BarSigma_ein_opt = np.exp(ptf(np.log(r)))\n", "ccl_DeltaSigma_ein_opt = ccl_BarSigma_ein_opt - ccl_Sigma_ein_opt\n", "\n", - "tmp = ccl_her.cumul2d(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_her.cumul2d(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_BarSigma_her_opt = np.exp(ptf(np.log(r)))\n", "ccl_DeltaSigma_her_opt = ccl_BarSigma_her_opt - ccl_Sigma_her_opt\n", @@ -662,6 +671,14 @@ ")\n", "axs[0].plot(\n", " r,\n", + " np.abs(ccl_Sigma_ein_quad / nc_Sigma_ein - 1.0),\n", + " label=\"CCL - EIN (quad)\",\n", + " linestyle=\":\",\n", + " color=\"darkorange\",\n", + " lw=0.5,\n", + ")\n", + "axs[0].plot(\n", + " r,\n", " np.abs(ccl_Sigma_ein_opt / nc_Sigma_ein - 1.0),\n", " label=\"CCL - EIN (opt)\",\n", " linestyle=\"--\",\n", @@ -857,6 +874,13 @@ ")\n", "axs[1].plot(\n", " r,\n", + " np.abs(ccl_Sigma_ein_quad / col_Sigma_ein - 1.0),\n", + " label=\"EIN - CCL (quad)\",\n", + " color=\"cadetblue\",\n", + " linestyle=\"--\",\n", + ")\n", + "axs[1].plot(\n", + " r,\n", " np.abs(ct_Sigma_ein / col_Sigma_ein - 1.0),\n", " label=\"EIN - CT\",\n", " color=\"cadetblue\",\n", @@ -991,7 +1015,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1005,7 +1029,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.8" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/examples/demo_boost_factors.ipynb b/examples/demo_boost_factors.ipynb index 11a763a67..fda156a82 100644 --- a/examples/demo_boost_factors.ipynb +++ b/examples/demo_boost_factors.ipynb @@ -246,10 +246,10 @@ "metadata": {}, "outputs": [], "source": [ - "nfw_boost = u.compute_nfw_boost(cl.DeltaSigma_profile[\"radius\"], rs=1000, b0=0.1)\n", + "nfw_boost = u.compute_nfw_boost(cl.DeltaSigma_profile[\"radius\"], rscale=1000, boost0=0.1)\n", "\n", "powerlaw_boost = u.compute_powerlaw_boost(\n", - " cl.DeltaSigma_profile[\"radius\"], rs=1000, b0=0.1, alpha=-1.0\n", + " cl.DeltaSigma_profile[\"radius\"], rscale=1000, boost0=0.1, alpha=-1.0\n", ")" ] }, diff --git a/examples/demo_mass_conversion.ipynb b/examples/demo_mass_conversion.ipynb index 71308a80c..3cb6e9aa8 100644 --- a/examples/demo_mass_conversion.ipynb +++ b/examples/demo_mass_conversion.ipynb @@ -21,9 +21,6 @@ "os.environ[\n", " \"CLMM_MODELING_BACKEND\"\n", "] = \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n", - "import warnings\n", - "\n", - "warnings.filterwarnings(\"ignore\", message=\".*(!).*\")\n", "import clmm\n", "import numpy as np\n", "import matplotlib.pyplot as plt" diff --git a/examples/demo_mock_cluster.ipynb b/examples/demo_mock_cluster.ipynb index 098284eb0..55a4e2bf6 100644 --- a/examples/demo_mock_cluster.ipynb +++ b/examples/demo_mock_cluster.ipynb @@ -24,9 +24,6 @@ "metadata": {}, "outputs": [], "source": [ - "import warnings\n", - "\n", - "warnings.filterwarnings(\"ignore\", message=\".*(!).*\")\n", "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", diff --git a/examples/demo_mock_ensemble_realistic.ipynb b/examples/demo_mock_ensemble_realistic.ipynb index ddd35401c..bb0f9147f 100644 --- a/examples/demo_mock_ensemble_realistic.ipynb +++ b/examples/demo_mock_ensemble_realistic.ipynb @@ -133,7 +133,7 @@ " n_s=0.96,\n", " Neff=3.04,\n", " m_nu=1.0e-05,\n", - " m_nu_type=\"single\",\n", + " mass_split=\"single\",\n", ")\n", "hmd_200c = ccl.halos.MassDef(200, \"critical\")\n", "\n", @@ -141,8 +141,8 @@ "# For a different multiplicty function, the user must change this function below\n", "def tinker08_ccl(logm, z):\n", " mass = 10 ** (logm)\n", - " hmf_200c = ccl.halos.MassFuncTinker08(cosmo, mass_def=hmd_200c)\n", - " nm = hmf_200c.get_mass_function(cosmo, mass, 1.0 / (1 + z))\n", + " hmf_200c = ccl.halos.MassFuncTinker08(mass_def=hmd_200c)\n", + " nm = hmf_200c(cosmo, mass, 1.0 / (1 + z))\n", " return nm # dn/dlog10M\n", "\n", "\n", @@ -633,12 +633,12 @@ "cluster_z = ran_z[indices]\n", "\n", "# Concentration CCL object to compute the theoretical concentration\n", - "conc_obj = ccl.halos.ConcentrationDuffy08(hmd_200c)\n", + "conc_obj = ccl.halos.ConcentrationDuffy08(mass_def=hmd_200c)\n", "conc_list = []\n", "for number in range(0, len(cluster_m)):\n", " a = 1.0 / (1.0 + (cluster_z[number]))\n", " # mean value of the concentration for that cluster\n", - " lnc_mean = np.log(conc_obj.get_concentration(cosmo, M=(cluster_m[number]), a=a))\n", + " lnc_mean = np.log(conc_obj(cosmo, M=(cluster_m[number]), a=a))\n", " # random draw of actual concentration from normal distribution around lnc_mean, with a 0.14 scatter\n", " lnc = np.random.normal(lnc_mean, 0.14)\n", " conc_list.append(np.exp(lnc))\n", @@ -1179,9 +1179,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3.11", "language": "python", - "name": "python3" + "name": "python3.11" }, "language_info": { "codemirror_mode": { @@ -1193,7 +1193,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/examples/demo_theory_functionality.ipynb b/examples/demo_theory_functionality.ipynb index c800d5811..5bb640cce 100644 --- a/examples/demo_theory_functionality.ipynb +++ b/examples/demo_theory_functionality.ipynb @@ -47,9 +47,6 @@ "metadata": {}, "outputs": [], "source": [ - "import warnings\n", - "\n", - "warnings.filterwarnings(\"ignore\", message=\".*(!).*\")\n", "import os\n", "\n", "os.environ[\n", @@ -351,7 +348,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "plot_profile(r3d, kappa, \"$\\\\kappa$\")" @@ -437,10 +436,10 @@ "## Side note regarding the Einasto profile (CCL and NC backends only)\n", "\n", "The Einasto profile is supported by both the CCL and NumCosmo backends. The value of the slope of the Einasto profile can be defined by the user, using the `alpha_ein` keyword. If `alpha_ein` is not provided, both backend revert to a default value for the Einasto slope:\n", - "- In CCL, the default Einasto slope depends on cosmology, redshift and halo mass. \n", + "- 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:" ] @@ -462,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 can 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", @@ -472,13 +471,66 @@ "\n", "plot_profile(r3d, rho, \"$\\\\rho_{\\\\rm 3d}$\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Side note regarding the Einasto profile (CCL backend only)\n", + "\n", + "For CCL versions >= 2.8.1.dev73+g86125b08, the surface mass density profile can be calculated with the 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": { @@ -490,7 +542,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/examples/demo_theory_functionality_diff_z_types.ipynb b/examples/demo_theory_functionality_diff_z_types.ipynb index fd50854f8..61f3e275e 100644 --- a/examples/demo_theory_functionality_diff_z_types.ipynb +++ b/examples/demo_theory_functionality_diff_z_types.ipynb @@ -28,9 +28,6 @@ "metadata": {}, "outputs": [], "source": [ - "import warnings\n", - "\n", - "warnings.filterwarnings(\"ignore\", message=\".*(!).*\")\n", "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", diff --git a/examples/demo_theory_functionality_oo.ipynb b/examples/demo_theory_functionality_oo.ipynb index 27ad45bd9..3e8083c3a 100644 --- a/examples/demo_theory_functionality_oo.ipynb +++ b/examples/demo_theory_functionality_oo.ipynb @@ -16,17 +16,6 @@ "This notebook goes through the steps to generate model data for galaxy cluster weak lensing observables. In particular, we define a galaxy cluster model that follows and NFW distribution and generate various profiles for the model (mass density, convergence, shear, etc.), which we plot. Note, a full pipeline to measure a galaxy cluster weak lensing mass requires fitting the observed (or mock) data to a model. In this notebook we use the OO interface to theory." ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import warnings\n", - "\n", - "warnings.filterwarnings(\"ignore\", message=\".*(!).*\")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -285,7 +274,7 @@ "## Side note regarding the Einasto profile (CCL and NC backends only)\n", "\n", "The Einasto profile is supported by both the CCL and NumCosmo backends. The value of the slope of the Einasto profile $\\alpha_{\\rm ein}$ can be defined by the user, using the `set_einasto_alpha` method. If $\\alpha_{\\rm ein}$ is not provided, both backend revert to a default value for the Einasto slope:\n", - "- In CCL, the default Einasto slope depends on cosmology, redshift and halo mass. \n", + "- In CCL, the default Einasto slope depends on cosmology, redshift and halo mass.\n", "- In NumCosmo, the default value is $\\alpha=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", @@ -313,19 +302,50 @@ "plot_profile(r3d, rho, \"$\\\\rho_{\\\\rm 3d}$\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Side note regarding the Einasto profile (CCL backend only)\n", + "\n", + "For CCL versions >= 2.8.1.dev73+g86125b08, the surface mass density profile can be calculated with the 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": [] + "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": [ + "# 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": { @@ -337,7 +357,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/examples/other_compare_NFW_critical_massdef.ipynb b/examples/other_compare_NFW_critical_massdef.ipynb index 0ce2798d5..79224581b 100644 --- a/examples/other_compare_NFW_critical_massdef.ipynb +++ b/examples/other_compare_NFW_critical_massdef.ipynb @@ -163,18 +163,22 @@ "\n", "# CCL\n", "MDEF = \"critical\"\n", - "conc = ccl.halos.ConcentrationConstant(cvir)\n", - "mdef = ccl.halos.MassDef(Delta, \"critical\", c_m_relation=conc)\n", + "mdef = ccl.halos.MassDef(Delta, MDEF)\n", + "conc = ccl.halos.ConcentrationConstant(cvir, mass_def=mdef)\n", + "\n", "# mdef.concentration = conc\n", "\n", "ccl_nfw_num_opt = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=False, cumul2d_analytic=False, fourier_analytic=False\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=False, cumul2d_analytic=False, fourier_analytic=False\n", ")\n", "ccl_nfw_num = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=False, cumul2d_analytic=False\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=False, cumul2d_analytic=False\n", ")\n", "ccl_nfw_ana = ccl.halos.HaloProfileNFW(\n", - " conc, truncated=False, projected_analytic=True, cumul2d_analytic=True\n", + " mass_def=mdef, concentration=conc,\n", + " truncated=False, projected_analytic=True, cumul2d_analytic=True\n", ")\n", "\n", "# Colossus\n", @@ -243,15 +247,15 @@ "nc_Sigma_nfw_num = smd.sigma_array(nc_nfw, cosmo, r, 1.0, 1.0, z)\n", "\n", "# CCL\n", - "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", - "ccl_Sigma_nfw_num = ccl_nfw_num.projected(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_Sigma_nfw_ana = ccl_nfw_ana.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", + "ccl_Sigma_nfw_num = ccl_nfw_num.projected(cosmo_ccl, r / a, Mvir, a) / a**2\n", "\n", "# CCL numerical NFW, using optimised setup\n", "# When using fourier_analytic=False in CCL profile definition, CCL performs\n", "# better by first evaluating the profile on a wider range and then\n", "# interpolating to the desired radii\n", "rtmp = np.geomspace(1.0e-4, 100, 1000)\n", - "tmp = ccl_nfw_num_opt.projected(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2\n", + "tmp = ccl_nfw_num_opt.projected(cosmo_ccl, rtmp / a, Mvir, a) / a**2\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100)\n", "ccl_Sigma_nfw_num_opt = np.exp(ptf(np.log(r)))\n", "\n", @@ -292,11 +296,11 @@ "nc_DeltaSigma_nfw_num = np.array(smd.sigma_excess_array(nc_nfw, cosmo, r, 1.0, 1.0, z))\n", "\n", "# CCL\n", - "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_nfw_ana = ccl_nfw_ana.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_nfw_ana = ccl_BarSigma_nfw_ana - ccl_Sigma_nfw_ana\n", "\n", "# CCL numerical NFW, using default setup\n", - "ccl_BarSigma_nfw_num = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, Mvir, a, mdef) / a**2\n", + "ccl_BarSigma_nfw_num = ccl_nfw_num.cumul2d(cosmo_ccl, r / a, Mvir, a) / a**2\n", "ccl_DeltaSigma_nfw_num = ccl_BarSigma_nfw_num - ccl_Sigma_nfw_num\n", "\n", "# CCL numerical NFW, using optimised setup\n", @@ -304,7 +308,7 @@ "# better by first evaluating the profile on a wider range and then\n", "# interpolating to the desired radii\n", "rtmp = np.geomspace(1.0e-4, 100, 1000) # extended radial range\n", - "tmp = ccl_nfw_num_opt.cumul2d(cosmo_ccl, rtmp / a, Mvir, a, mdef) / a**2 # CCL estimation\n", + "tmp = ccl_nfw_num_opt.cumul2d(cosmo_ccl, rtmp / a, Mvir, a) / a**2 # CCL estimation\n", "ptf = interp1d(np.log(rtmp), np.log(tmp), bounds_error=False, fill_value=-100) # interpolation\n", "ccl_BarSigma_nfw_num_opt = np.exp(ptf(np.log(r))) # evaluation on the desired radius array\n", "ccl_DeltaSigma_nfw_num_opt = ccl_BarSigma_nfw_num_opt - ccl_Sigma_nfw_num_opt\n", @@ -716,7 +720,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.12" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/setup.py b/setup.py index 37a2745a0..6d1a6c9a3 100644 --- a/setup.py +++ b/setup.py @@ -41,5 +41,5 @@ def get_version(rel_path): "Programming Language :: Python", ], install_requires=["astropy>=4.0", "numpy", "scipy", "healpy"], - python_requires=">" + str(required_py_version), + python_requires=">=" + str(required_py_version), ) diff --git a/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb b/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb index d7c41f1ea..aeaf5e279 100644 --- a/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb +++ b/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb @@ -116,16 +116,16 @@ "metadata": {}, "outputs": [], "source": [ + "mdef = ccl.halos.MassDef(mass_Delta, 'matter')\n", + "conc = ccl.halos.ConcentrationConstant(c=cluster_concentration, mass_def=mdef)\n", "ccl_ein = ccl.halos.HaloProfileEinasto(\n", - " ccl.halos.ConcentrationConstant(cluster_concentration), truncated=False\n", + " mass_def=mdef,\n", + " concentration=conc\n", ")\n", "alpha_einasto = ccl_ein._get_alpha(\n", " cosmo_ccl.be_cosmo,\n", " cluster_mass,\n", - " 1 / (1 + z_cluster),\n", - " ccl.halos.massdef.MassDef(\n", - " mass_Delta, \"matter\", ccl.halos.ConcentrationConstant(cluster_concentration)\n", - " ),\n", + " 1 / (1 + z_cluster)\n", ")\n", "print(alpha_einasto)" ] @@ -667,9 +667,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3.11", "language": "python", - "name": "python3" + "name": "python3.11" }, "language_info": { "codemirror_mode": { @@ -681,7 +681,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/tests/data/numcosmo/radial_profiles_einasto.txt b/tests/data/numcosmo/radial_profiles_einasto.txt index fc4278950..6a51529a6 100644 --- a/tests/data/numcosmo/radial_profiles_einasto.txt +++ b/tests/data/numcosmo/radial_profiles_einasto.txt @@ -1,101 +1,101 @@ # r3d rho Sigma DeltaSigma gammat kappa gt mu -1.000000000000000021e-02 2.623669635761697600e+16 3.189196070450592500e+15 1.276027514275365000e+14 4.687611461572240013e-02 1.171582264943169527e+00 -2.731990665308467459e-01 3.670653746217076474e+01 -1.072267222010323158e-02 2.529093035647578800e+16 3.163569518777162000e+15 1.349153969309525000e+14 4.956248622548301702e-02 1.162168101376863882e+00 -3.056241381916684485e-01 4.194269668572388809e+01 -1.149756995397735633e-02 2.435596729001030400e+16 3.136611589052279000e+15 1.425186873425165000e+14 5.235562907547475914e-02 1.152264843105008874e+00 -3.438458150143563485e-01 4.891537361813954021e+01 -1.232846739442065853e-02 2.343257807453348000e+16 3.108282567296658000e+15 1.504117209231940000e+14 5.525521190307310093e-02 1.141857900810179904e+00 -3.895109936598458167e-01 5.858050446802359090e+01 -1.321941148466028795e-02 2.252152478078229600e+16 3.078544381651209000e+15 1.585924159268260000e+14 5.826046995853354643e-02 1.130933288423813465e+00 -4.449630087190075689e-01 7.273127343561974101e+01 -1.417474162926805545e-02 2.162355818454726400e+16 3.047360932014807000e+15 1.670568495043020000e+14 6.136996214499520347e-02 1.119477744221855531e+00 -5.136518315163234316e-01 9.515961926913431057e+01 -1.519911082952933937e-02 2.073941526177878000e+16 3.014698448768282500e+15 1.757996073026140000e+14 6.458169944710116794e-02 1.107478862605516090e+00 -6.008781436787062891e-01 1.354846488476142667e+02 -1.629750834620644420e-02 1.986981663917872800e+16 2.980525862127245000e+15 1.848134481612495000e+14 6.789302175394992811e-02 1.094925229786629428e+00 -7.152263092389454791e-01 2.272036962235203532e+02 -1.747528400007683849e-02 1.901546401236826400e+16 2.944815185225114000e+15 1.940890326809820000e+14 7.130049814619464355e-02 1.081806564516939240e+00 -8.715742870663030217e-01 6.216767638485522411e+02 -1.873817422860384052e-02 1.817703754478220800e+16 2.907541904333967500e+15 2.036152523729590000e+14 7.480004781216917364e-02 1.068113861439532464e+00 -1.098161904659774590e+00 -1.046518771919829305e+03 -2.009233002565046985e-02 1.735519326146843600e+16 2.868685386511499000e+15 2.133785650990380000e+14 7.838669591541733150e-02 1.053839540841921663e+00 -1.455931731393632633e+00 -3.080925494466385430e+02 -2.154434690031884619e-02 1.655056045294933200e+16 2.828229300832023500e+15 2.233633106312910000e+14 8.205468951855299231e-02 1.038977603399361627e+00 -2.105175340767534209e+00 -1.918016860705505735e+02 -2.310129700083160542e-02 1.576373910521795400e+16 2.786162038713962000e+15 2.335514940323845000e+14 8.579741800593103374e-02 1.023523784586248375e+00 -3.647262526629580837e+00 -1.468897168460559328e+02 -2.477076355991711387e-02 1.499529737277655800e+16 2.742477134074154000e+15 2.439224672885610000e+14 8.960729612841962510e-02 1.007475709023901045e+00 -1.198646119611277783e+01 -1.254141599770154301e+02 -2.656087782946686682e-02 1.424576911236377400e+16 2.697173674733401000e+15 2.544533472946065000e+14 9.347591755425260773e-02 9.908330416143988906e-01 1.019704831442042980e+01 -1.155573197559476739e+02 -2.848035868435801893e-02 1.351565149563965400e+16 2.650256718901206500e+15 2.651184282870765000e+14 9.739383902064741028e-02 9.735976405403109490e-01 3.688830885336158438e+00 -1.137853798902582696e+02 -3.053855508833415444e-02 1.280540271958951800e+16 2.601737698511904000e+15 2.758894914310720000e+14 1.013506940635251069e-01 9.557737054341537419e-01 2.291638832926190084e+00 -1.202501483586175794e+02 -3.274549162877728181e-02 1.211543983374818200e+16 2.551634801771808000e+15 2.867357647997460000e+14 1.053351783155919569e-01 9.373679179108166393e-01 1.681808664217849358e+00 -1.394170843782524116e+02 -3.511191734215130672e-02 1.144613670351966200e+16 2.499973330206412500e+15 2.976236299489570000e+14 1.093349417136780938e-01 9.183895727323304614e-01 1.339717795559099311e+00 -1.888978092893256360e+02 -3.764935806792467365e-02 1.079782212885638800e+16 2.446786024608291500e+15 3.085171449074060000e+14 1.133367806242624731e-01 8.988506975480062833e-01 1.120489987343740612e+00 -3.825489646135808925e+02 -4.037017258596553582e-02 1.017077813735063200e+16 2.392113369191024000e+15 3.193776360065815000e+14 1.173264878982242937e-01 8.787661646283448924e-01 9.677701570567965872e-01 1.072802437031067029e+03 -4.328761281083057244e-02 9.565238470364550000e+15 2.336003849332720500e+15 3.301640524447680000e+14 1.212889831233878168e-01 8.581537855496332856e-01 8.550738106996020882e-01 1.848657396931597248e+02 -4.641588833612779463e-02 8.981387280171946000e+15 2.278514160340049500e+15 3.408331345659110000e+14 1.252083744434038803e-01 8.370343878854452635e-01 7.683116261079082632e-01 9.190624271938843037e+01 -4.977023564332111460e-02 8.419358055193029000e+15 2.219709357814459250e+15 3.513391824352247500e+14 1.290678735417433998e-01 8.154318704451384292e-01 6.992966437544075875e-01 5.744855413954382328e+01 -5.336699231206309957e-02 7.879232789266045000e+15 2.159662951456050000e+15 3.616348841453910000e+14 1.328500999280538553e-01 7.933732377336214503e-01 6.429472081490914537e-01 3.992738034607557296e+01 -5.722367659350217212e-02 7.361041409511860000e+15 2.098456940744797500e+15 3.716709423943595000e+14 1.365369437578742018e-01 7.708886130591987573e-01 5.959413260989665506e-01 2.954236750249809162e+01 -6.135907273413172824e-02 6.864761475707217000e+15 2.036181772232043000e+15 3.813966780864880000e+14 1.401097875713976093e-01 7.480112228441838651e-01 5.560159827465706028e-01 2.279587211770191146e+01 -6.579332246575682330e-02 6.390318162193128000e+15 1.972936218671335500e+15 3.907602305142245000e+14 1.435495798321637095e-01 7.247773522224352227e-01 5.215761892828700841e-01 1.813531791444600572e+01 -7.054802310718645553e-02 5.937584531213114000e+15 1.908827169789055500e+15 3.997089205847575000e+14 1.468369683619094590e-01 7.012262681769058092e-01 4.914654560356487845e-01 1.477003479361916760e+01 -7.564633275546291113e-02 5.506382104212469000e+15 1.843969345744390000e+15 4.081896246625880000e+14 1.499524376752821020e-01 6.774001142763715899e-01 4.648248319707924403e-01 1.225716221993067023e+01 -8.111308307896872294e-02 5.096481735052291000e+15 1.778484921963848750e+15 4.161491862276242500e+14 1.528764602064531797e-01 6.533437728547338841e-01 4.410030694252910499e-01 1.033065025776648049e+01 -8.697490026177834288e-02 4.707604786319980000e+15 1.712503057395270750e+15 4.235348609795870000e+14 1.555896598225606775e-01 6.291046917105300729e-01 4.194975141101778271e-01 8.821828293365328477e+00 -9.326033468832199691e-02 4.339424606979386500e+15 1.646159327667765000e+15 4.302947920805705000e+14 1.580729864086965475e-01 6.047326758727120666e-01 3.999141258582569192e-01 7.619094727368562303e+00 -1.000000000000000056e-01 3.991568306529020500e+15 1.579595061233158750e+15 4.363785131377497500e+14 1.603079006435073062e-01 5.802796437257364826e-01 3.819397802539639120e-01 6.645995208528413301e+00 -1.072267222010323123e-01 3.663618817662859000e+15 1.512956594439413500e+15 4.417374660658702500e+14 1.622765642410277098e-01 5.557993533535218189e-01 3.653226654804435647e-01 5.848619097758430030e+00 -1.149756995397735598e-01 3.355117236196166500e+15 1.446394434162134500e+15 4.463255355077505000e+14 1.639620362752620686e-01 5.313470949239713637e-01 3.498581455473172563e-01 5.188013718407724184e+00 -1.232846739442065853e-01 3.065565423773752500e+15 1.380062333993083000e+15 4.500995931789487500e+14 1.653484731505037719e-01 5.069793513178171285e-01 3.353783935672294270e-01 4.635440187086221187e+00 -1.321941148466029281e-01 2.794428855669627500e+15 1.314116289538742500e+15 4.530200462113840000e+14 1.664213300407097196e-01 4.827534290417549445e-01 3.217446753342405596e-01 4.169307991455362128e+00 -1.417474162926805614e-01 2.541139692867054000e+15 1.248713464170242000e+15 4.550513802342692500e+14 1.671675603955752043e-01 4.587270635922062745e-01 3.088415273540143224e-01 3.773137846648428440e+00 -1.519911082952933867e-01 2.305100054631145500e+15 1.184011062259152500e+15 4.561626803414510000e+14 1.675758073229645373e-01 4.349580055275049650e-01 2.965723060626808683e-01 3.434174380416248340e+00 -1.629750834620644351e-01 2.085685465007930000e+15 1.120165148362134875e+15 4.563281437245378750e+14 1.676365919096879098e-01 4.115035866838663847e-01 2.848557580241964371e-01 3.142420780087923138e+00 -1.747528400007683780e-01 1.882248444160040500e+15 1.057329429231785750e+15 4.555275190457765000e+14 1.673424746294103760e-01 3.884202727351990236e-01 2.736233187091154373e-01 2.889954083050963796e+00 -1.873817422860384052e-01 1.694122213234424750e+15 9.956540105025533750e+14 4.537465954312163750e+14 1.666882349790579088e-01 3.657632064495556223e-01 2.628170372234962526e-01 2.670431315312202791e+00 -2.009233002565046777e-01 1.520624479603877250e+15 9.352841518516792500e+14 4.509775415571950000e+14 1.656709960455428343e-01 3.435857503853704253e-01 2.523878726624316227e-01 2.478727632786016155e+00 -2.154434690031884481e-01 1.361061267880110500e+15 8.763590355677532500e+14 4.472192179598447500e+14 1.642903392357058512e-01 3.219390345131137310e-01 2.422943475558073101e-01 2.310667608528735428e+00 -2.310129700083160265e-01 1.214730761104602750e+15 8.190105594100537500e+14 4.424774599325580000e+14 1.625484082014574116e-01 3.008715127604031370e-01 2.325014802976419215e-01 2.162823136526633494e+00 -2.477076355991711387e-01 1.080927116020872625e+15 7.633621749181153750e+14 4.367652324964996250e+14 1.604499657697061876e-01 2.804285362536993453e-01 2.229798899116379463e-01 2.032359636926105662e+00 -2.656087782946686682e-01 9.589442163468533750e+14 7.095277875484503750e+14 4.301027347900838750e+14 1.580024322908509804e-01 2.606519492728089360e-01 2.137050772439945123e-01 1.916917823700251100e+00 -2.848035868435802032e-01 8.480793285175710000e+14 6.576107458676077500e+14 4.225173994519532500e+14 1.552158854121120646e-01 2.415797179211013057e-01 2.046568229776915548e-01 1.814521916969636273e+00 -3.053855508833415722e-01 7.476366254655651250e+14 6.077029296875623750e+14 4.140437994436648750e+14 1.521030258479365849e-01 2.232455951431550623e-01 1.958186846406994308e-01 1.723507736396344248e+00 -3.274549162877728459e-01 6.569305456469673750e+14 5.598839529435315000e+14 4.047234600020205000e+14 1.486791082988540569e-01 2.056788278941533432e-01 1.871775718941078304e-01 1.642465897408021069e+00 -3.511191734215131088e-01 5.752889566908533750e+14 5.142204973761986250e+14 3.946045741823401250e+14 1.449618369535248530e-01 1.889039123615536275e-01 1.787233832869169481e-01 1.570196590404960180e+00 -3.764935806792467643e-01 5.020560957220625625e+14 4.707657909025689375e+14 3.837416215685269375e+14 1.409712254181658964e-01 1.729404023395364753e-01 1.704486905380663275e-01 1.505673320564595796e+00 -4.037017258596555802e-01 4.365952615446967500e+14 4.295592474851565000e+14 3.721948825783897500e+14 1.367294182918761813e-01 1.578027769314410134e-01 1.623484553816270659e-01 1.448013641470657697e+00 -4.328761281083059465e-01 3.782912374245944375e+14 3.906262693189145000e+14 3.600298641901335000e+14 1.322604802016649761e-01 1.435003678812052930e-01 1.544197746757709211e-01 1.396455378325573093e+00 -4.641588833612779741e-01 3.265524271127570000e+14 3.539782190434258125e+14 3.473166429427329375e+14 1.275901544472347049e-01 1.300373493652437207e-01 1.466616461685342210e-01 1.350337200692012019e+00 -4.977023564332111460e-01 2.808126909365107188e+14 3.196125639448540000e+14 3.341291354954236250e+14 1.227455950338993407e-01 1.174127909664394870e-01 1.390747495290654279e-01 1.309082663480098274e+00 -5.336699231206309957e-01 2.405328731709928438e+14 2.875131950400774375e+14 3.205443001196825625e+14 1.177550733328795313e-01 1.056207748928115336e-01 1.316612349965609330e-01 1.272187035714403391e+00 -5.722367659350217073e-01 2.052020164035863750e+14 2.576509133117131562e+14 3.066412820470658750e+14 1.126476641164995823e-01 9.465057460069059569e-02 1.244245160555723789e-01 1.239206379468057007e+00 -6.135907273413172547e-01 1.743382631267819375e+14 2.299840836866273438e+14 2.925005157622573750e+14 1.074529157767879911e-01 8.448689504009991580e-02 1.173690635280359995e-01 1.209748468305232860e+00 -6.579332246575682053e-01 1.474894492469614062e+14 2.044594244530950000e+14 2.782028187961469375e+14 1.022005174215309953e-01 7.511016265484417309e-02 1.105002058568314433e-01 1.183465194080822513e+00 -7.054802310718645275e-01 1.242333984845648125e+14 1.810129455604338750e+14 2.638284684825885000e+14 9.691995971186782854e-02 6.649687007602664290e-02 1.038239258177540980e-01 1.160046223914949381e+00 -7.564633275546290836e-01 1.041779306747426094e+14 1.595710004885613125e+14 2.494562880655539375e+14 9.164019913484498792e-02 5.861996253658451062e-02 9.734665649143468824e-02 1.139213678635155214e+00 -8.111308307896872849e-01 8.696060067245946875e+13 1.400514376619359531e+14 2.351627579897086250e+14 8.638933152734597221e-02 5.144926085442447228e-02 9.107507691698470131e-02 1.120717668697500002e+00 -8.697490026177834288e-01 7.224818784589743750e+13 1.223648297621861250e+14 2.210211727835942500e+14 8.119428234890976870e-02 4.495191303240016201e-02 8.501591014826499759e-02 1.104332549896486437e+00 -9.326033468832198858e-01 5.973595894146687500e+13 1.064157576949703438e+14 2.071008581556610938e+14 7.608051907432651639e-02 3.909286593605450916e-02 7.917572508027981293e-02 1.089853785592691970e+00 -1.000000000000000000e+00 4.914672937013000781e+13 9.210412454805496875e+13 1.934664647651047812e+14 7.107179175347000388e-02 3.383534798892814943e-02 7.356074516443347755e-02 1.077095321617599355e+00 -1.072267222010323096e+00 4.022974965998771094e+13 7.932647376552967188e+13 1.801773438260535625e+14 6.618990363340919447e-02 2.914135341670708035e-02 6.817666389061775856e-02 1.065887394059237936e+00 -1.149756995397735571e+00 3.275944492184633203e+13 6.797729374732314062e+13 1.672870188273947500e+14 6.145451708953687114e-02 2.497212150457207500e-02 6.302847174418002574e-02 1.056074709134620981e+00 -1.232846739442065909e+00 2.653403567693038281e+13 5.795027529188967188e+13 1.548427716161748750e+14 5.688300156927166007e-02 2.128859853102722799e-02 5.812030133080552108e-02 1.047514929974726394e+00 -1.321941148466028615e+00 2.137406830977950391e+13 4.913950910324830469e+13 1.428853403679043750e+14 5.249032263850536562e-02 1.805187768378414478e-02 5.345529101343090422e-02 1.040077427328846671e+00 -1.417474162926804837e+00 1.712088276152780273e+13 4.144059959958542188e+13 1.314487347444124219e+14 4.828897407803903197e-02 1.522360822820957582e-02 4.903547087594014448e-02 1.033642246966846479e+00 -1.519911082952933201e+00 1.363504391108575195e+13 3.475168030362002344e+13 1.205601627909436562e+14 4.428895102851883314e-02 1.276636852087417902e-02 4.486167166141086932e-02 1.028099256367812409e+00 -1.629750834620645072e+00 1.079476145950517773e+13 2.897431547579106641e+13 1.102400764325394531e+14 4.049776670397524370e-02 1.064399723329306595e-02 4.093346236412814809e-02 1.023347435236769520e+00 -1.747528400007684724e+00 8.494321102523551758e+12 2.401427813035747656e+13 1.005023270758046250e+14 3.692050955364883230e-02 8.821879163724280146e-03 3.724911676066690325e-02 1.019294279310170026e+00 -1.873817422860384996e+00 6.642547423180946289e+12 1.978219746430519531e+13 9.135442429483400000e+13 3.355993829278707680e-02 7.267183076488980056e-03 3.380560984856897933e-02 1.015855290235420094e+00 -2.009233002565047776e+00 5.161316341575615234e+12 1.619407283317151758e+13 8.279788309381920312e+13 3.041660947294813622e-02 5.949050516000773357e-03 3.059864234196151694e-02 1.012953528124527658e+00 -2.154434690031884259e+00 3.984132206205844238e+12 1.317165417434258594e+13 7.482864960806734375e+13 2.748903386741975707e-02 4.838735558972434569e-03 2.762269277317589908e-02 1.010519206573620377e+00 -2.310129700083160209e+00 3.054781784682008789e+12 1.064269209948910742e+13 6.743759468851720312e+13 2.477385779430285248e-02 3.909696688310086710e-03 2.487109623689487750e-02 1.008489313459995929e+00 -2.477076355991711498e+00 2.326074591466259766e+12 8.541064423491459961e+12 6.061105861298566406e+13 2.226606322149770473e-02 3.137643274747247378e-03 2.233614608002949461e-02 1.006807244589160488e+00 -2.656087782946686904e+00 1.758676251437396484e+12 6.806788274633195312e+12 5.433143189908921875e+13 1.995918113399251098e-02 2.500540025642463294e-03 2.000921497692399742e-02 1.005422440548503937e+00 -2.848035868435801810e+00 1.320039006982927979e+12 5.385929360666869141e+12 4.857775461719150781e+13 1.784551169731677170e-02 1.978573652984112925e-03 1.788089035586679088e-02 1.004290020498433744e+00 -3.053855508833415389e+00 9.834310893597186279e+11 4.230421110872598145e+12 4.332632227008807031e+13 1.591634683334965800e-02 1.554086433462605532e-03 1.594112071278359216e-02 1.003370409279422004e+00 -3.274549162877728570e+00 7.270645370993237305e+11 3.297807853941642090e+12 3.855128397856275781e+13 1.416218996961528948e-02 1.211481862362396916e-03 1.417936801678739735e-02 1.002628956953652395e+00 -3.511191734215131088e+00 5.333191878052713013e+11 2.550926777997327637e+12 3.422521969637703906e+13 1.257296808483578110e-02 9.371078184754055721e-04 1.258476136310279422e-02 1.002035552047367606e+00 -3.764935806792467421e+00 3.880590147995317993e+11 1.957543427049501465e+12 3.031968519982909375e+13 1.113823191615837503e-02 7.191226601703537037e-04 1.114624743526494710e-02 1.001564231391590232e+00 -4.037017258596553582e+00 2.800357345210944824e+11 1.489955077460279541e+12 2.680571572883429297e+13 9.847340976615867603e-03 5.473495218711523381e-04 9.852733865786431067e-03 1.001192790631022067e+00 -4.328761281083057355e+00 2.003736708074031067e+11 1.124575317746316162e+12 2.365428177031789844e+13 8.689630991598921300e-03 4.131237053977252524e-04 8.693222367835366782e-03 1.000902400017976923e+00 -4.641588833612781961e+00 1.421292145788439636e+11 8.415121051816102295e+11 2.083669141603131641e+13 7.654561708922078857e-03 3.091376749459215454e-04 7.656928754074339774e-03 1.000677230429404485e+00 -4.977023564332113459e+00 9.991783993620965576e+10 6.241500467017153320e+11 1.832493607251046484e+13 6.731843898746959175e-03 2.292876039057282968e-04 6.733387781097457947e-03 1.000504094340355810e+00 -5.336699231206313065e+00 6.960150162074356079e+10 4.587460095964287720e+11 1.609197861108992188e+13 5.911545208298864956e-03 1.685248185072199024e-04 5.912541618302007140e-03 1.000372106014532081e+00 -5.722367659350219959e+00 4.802931090207953644e+10 3.340453831172721558e+11 1.411198490065055078e+13 5.184175217678613917e-03 1.227148277813625032e-04 5.184811470925347436e-03 1.000272364431505689e+00 -6.135907273413176100e+00 3.282463131656645966e+10 2.409245697842807617e+11 1.236050052646198242e+13 4.540750359251991518e-03 8.850598925654834894e-05 4.541152278426760502e-03 1.000197661621423650e+00 -6.579332246575682497e+00 2.221211554049404144e+10 1.720635883401535034e+11 1.081457629039860938e+13 3.972840021377477965e-03 6.320923646231778206e-05 3.973091157435935591e-03 1.000142218158481144e+00 -7.054802310718645053e+00 1.487868417444875717e+10 1.216511235381154327e+11 9.452846918003083984e+12 3.472595462213267422e-03 4.468972609373927062e-05 3.472750658488987872e-03 1.000101446664641847e+00 -7.564633275546290392e+00 9.862992725533103943e+09 8.512294593103854370e+10 8.255568625909895508e+12 3.032763610476524752e-03 3.127074397104431320e-05 3.032858450216622051e-03 1.000071743311933048e+00 -8.111308307896871739e+00 6.468514352125196457e+09 5.893342500269370270e+10 7.204620928717798828e+12 2.646687729215589386e-03 2.164976816108991152e-05 2.646745030631884443e-03 1.000050306554167712e+00 -8.697490026177835176e+00 4.195956857482413292e+09 4.035890115512548828e+10 6.283478365301539062e+12 2.308297029194971914e-03 1.482623576017978247e-05 2.308331253058342782e-03 1.000034981710555382e+00 -9.326033468832198636e+00 2.691311430106618881e+09 2.733094044697739792e+10 5.477158018204686523e+12 2.012087389632728502e-03 1.004028739674590807e-05 2.012107591771223562e-03 1.000024129551870811e+00 -1.000000000000000000e+01 1.706380886010607719e+09 1.829696972141786957e+10 4.772148324015714844e+12 1.753095205998152868e-03 6.721570187055526932e-06 1.753106989629829625e-03 1.000016516710793280e+00 +1.000000000000000021e-02 2.623669635761697600e+16 3.189196070449786000e+15 1.276027519456265000e+14 4.687611480604780834e-02 1.171582264942873097e+00 -2.731990676405569030e-01 3.670653748634952507e+01 +1.072267222010323158e-02 2.529093035647578800e+16 3.163569518776327000e+15 1.349153973752620000e+14 4.956248638870444645e-02 1.162168101376557017e+00 -3.056241391987419842e-01 4.194269671436146751e+01 +1.149756995397735633e-02 2.435596729001030400e+16 3.136611589051413000e+15 1.425186876894140000e+14 5.235562920291093880e-02 1.152264843104690684e+00 -3.438458158520137364e-01 4.891537365029977025e+01 +1.232846739442065853e-02 2.343257807453348000e+16 3.108282567295773500e+15 1.504117213282735000e+14 5.525521205188300283e-02 1.141857900809854831e+00 -3.895109947097419867e-01 5.858050452477413472e+01 +1.321941148466028795e-02 2.252152478078229600e+16 3.078544381650331500e+15 1.585924163410500000e+14 5.826047011070276810e-02 1.130933288423491057e+00 -4.449630098822922042e-01 7.273127352985996197e+01 +1.417474162926805545e-02 2.162355818454726400e+16 3.047360932013831500e+15 1.670568499448330000e+14 6.136996230682856268e-02 1.119477744221497151e+00 -5.136518328723679305e-01 9.515961944978003828e+01 +1.519911082952933937e-02 2.073941526177878000e+16 3.014698448767717000e+15 1.757996075290930000e+14 6.458169953030043486e-02 1.107478862605308478e+00 -6.008781444539676997e-01 1.354846490456935157e+02 +1.629750834620644420e-02 1.986981663917872800e+16 2.980525862123967500e+15 1.848134473910700000e+14 6.789302147101698715e-02 1.094925229785425280e+00 -7.152263062674328875e-01 2.272036942521080789e+02 +1.747528400007683849e-02 1.901546401236826400e+16 2.944815185224397500e+15 1.940890313922970000e+14 7.130049767278365258e-02 1.081806564516676117e+00 -8.715742812821479779e-01 6.216767377742245344e+02 +1.873817422860384052e-02 1.817703754478220800e+16 2.907541904332989000e+15 2.036152522110910000e+14 7.480004775270537865e-02 1.068113861439172974e+00 -1.098161903792567395e+00 -1.046518781608876452e+03 +2.009233002565046985e-02 1.735519326146843600e+16 2.868685386510629000e+15 2.133785658009000000e+14 7.838669617325318140e-02 1.053839540841602140e+00 -1.455931736191250714e+00 -3.080925456064942409e+02 +2.154434690031884619e-02 1.655056045294933200e+16 2.828229300831121500e+15 2.233633111834975000e+14 8.205468972141143069e-02 1.038977603399030336e+00 -2.105175345989904745e+00 -1.918016848448959877e+02 +2.310129700083160542e-02 1.576373910521795400e+16 2.786162038713121500e+15 2.335514944841785000e+14 8.579741817190196518e-02 1.023523784585939733e+00 -3.647262533732920975e+00 -1.468897162312466662e+02 +2.477076355991711387e-02 1.499529737277655800e+16 2.742477134073272500e+15 2.439224678149670000e+14 8.960729632179999238e-02 1.007475709023577082e+00 -1.198646122249969181e+01 -1.254141594318358415e+02 +2.656087782946686682e-02 1.424576911236377400e+16 2.697173674732507500e+15 2.544533478360235000e+14 9.347591775314742502e-02 9.908330416140705976e-01 1.019704833575204894e+01 -1.155573192594950171e+02 +2.848035868435801893e-02 1.351565149563965400e+16 2.650256718900311000e+15 2.651184288019625000e+14 9.739383920979580167e-02 9.735976405399819900e-01 3.688830892454275645e+00 -1.137853794134626355e+02 +3.053855508833415444e-02 1.280540271958951800e+16 2.601737698511011000e+15 2.758894915975570000e+14 1.013506941246849896e-01 9.557737054338257821e-01 2.291638834292075710e+00 -1.202501481797724097e+02 +3.274549162877728181e-02 1.211543983374818200e+16 2.551634801770914000e+15 2.867357639430720000e+14 1.053351780008844191e-01 9.373679179104882353e-01 1.681808659184329091e+00 -1.394170856677245354e+02 +3.511191734215130672e-02 1.144613670351966200e+16 2.499973330205520000e+15 2.976236286600430000e+14 1.093349412401829757e-01 9.183895727320025015e-01 1.339717789751822652e+00 -1.888978129857583212e+02 +3.764935806792467365e-02 1.079782212885638800e+16 2.446786024607400500e+15 3.085171445179060000e+14 1.133367804811758472e-01 8.988506975476789895e-01 1.120489985925507304e+00 -3.825489693697762732e+02 +4.037017258596553582e-02 1.017077813735063200e+16 2.392113369190124000e+15 3.193776361822970000e+14 1.173264879627750890e-01 8.787661646280142680e-01 9.677701575866055617e-01 1.072802454371603972e+03 +4.328761281083057244e-02 9.565238470364550000e+15 2.336003849331842000e+15 3.301640524644425000e+14 1.212889831306154381e-01 8.581537855493105438e-01 8.550738107486117734e-01 1.848657397499489718e+02 +4.641588833612779463e-02 8.981387280171946000e+15 2.278514160339202500e+15 3.408331345289345000e+14 1.252083744298202184e-01 8.370343878851340680e-01 7.683116260230885564e-01 9.190624268979938449e+01 +4.977023564332111460e-02 8.419358055193029000e+15 2.219709357812838500e+15 3.513391824389640000e+14 1.290678735431170510e-01 8.154318704445431276e-01 6.992966437595953266e-01 5.744855413998884330e+01 +5.336699231206309957e-02 7.879232789266045000e+15 2.159662951459143750e+15 3.616348841395462500e+14 1.328500999259067117e-01 7.933732377347579856e-01 6.429472081422364926e-01 3.992738034591483398e+01 +5.722367659350217212e-02 7.361041409511860000e+15 2.098456940717942000e+15 3.716709424211035000e+14 1.365369437676988706e-01 7.708886130493332045e-01 5.959413261161857767e-01 2.954236750089418351e+01 +6.135907273413172824e-02 6.864761475707217000e+15 2.036181772229288000e+15 3.813966780869615000e+14 1.401097875715715535e-01 7.480112228431717858e-01 5.560159827450278369e-01 2.279587211746218856e+01 +6.579332246575682330e-02 6.390318162193128000e+15 1.972936218669771750e+15 3.907602305465762500e+14 1.435495798440484527e-01 7.247773522218607933e-01 5.215761893249629688e-01 1.813531791546422056e+01 +7.054802310718645553e-02 5.937584531213114000e+15 1.908827169788433250e+15 3.997089206001302500e+14 1.468369683675568027e-01 7.012262681766772143e-01 4.914654560541749651e-01 1.477003479395117047e+01 +7.564633275546291113e-02 5.506382104212469000e+15 1.843969345743449750e+15 4.081896246708172500e+14 1.499524376783051838e-01 6.774001142760261995e-01 4.648248319796656203e-01 1.225716222003340228e+01 +8.111308307896872294e-02 5.096481735052291000e+15 1.778484921962930250e+15 4.161491862301420000e+14 1.528764602073780787e-01 6.533437728543964873e-01 4.410030694275302032e-01 1.033065025777169588e+01 +8.697490026177834288e-02 4.707604786319980000e+15 1.712503057394387000e+15 4.235348609793115000e+14 1.555896598224594529e-01 6.291046917102053326e-01 4.194975141095378390e-01 8.821828293344129435e+00 +9.326033468832199691e-02 4.339424606979386500e+15 1.646159327665952250e+15 4.302947920801250000e+14 1.580729864085329006e-01 6.047326758720461548e-01 3.999141258571691782e-01 7.619094727335000705e+00 +1.000000000000000056e-01 3.991568306529020500e+15 1.579595061232396750e+15 4.363785131360595000e+14 1.603079006428863584e-01 5.802796437254564843e-01 3.819397802522291330e-01 6.645995208509238417e+00 +1.072267222010323123e-01 3.663618817662859000e+15 1.512956594438495000e+15 4.417374660645157500e+14 1.622765642405301356e-01 5.557993533531844221e-01 3.653226654790456829e-01 5.848619097742652428e+00 +1.149756995397735598e-01 3.355117236196166500e+15 1.446394434161245500e+15 4.463255355066025000e+14 1.639620362748403504e-01 5.313470949236448471e-01 3.498581455461736711e-01 5.188013718395764862e+00 +1.232846739442065853e-01 3.065565423773752500e+15 1.380062333992191750e+15 4.500995931779765000e+14 1.653484731501466132e-01 5.069793513174897237e-01 3.353783935662818516e-01 4.635440187076746987e+00 +1.321941148466029281e-01 2.794428855669627500e+15 1.314116289537873500e+15 4.530200462104492500e+14 1.664213300403663276e-01 4.827534290414356999e-01 3.217446753333784160e-01 4.169307991447633199e+00 +1.417474162926805614e-01 2.541139692867054000e+15 1.248713464169336750e+15 4.550513802332182500e+14 1.671675603951891242e-01 4.587270635918737627e-01 3.088415273531114336e-01 3.773137846641466009e+00 +1.519911082952933867e-01 2.305100054631145500e+15 1.184011062258251750e+15 4.561626803406732500e+14 1.675758073226788214e-01 4.349580055271740631e-01 2.965723060620016893e-01 3.434174380410707883e+00 +1.629750834620644351e-01 2.085685465007930000e+15 1.120165148361241500e+15 4.563281437204610000e+14 1.676365919081902189e-01 4.115035866835382028e-01 2.848557580214927665e-01 3.142420780079149711e+00 +1.747528400007683780e-01 1.882248444160040500e+15 1.057329429230896000e+15 4.555275190454782500e+14 1.673424746293008247e-01 3.884202727348721740e-01 2.736233187087900309e-01 2.889954083047318267e+00 +1.873817422860384052e-01 1.694122213234424750e+15 9.956540105016617500e+14 4.537465954415742500e+14 1.666882349828629761e-01 3.657632064492281065e-01 2.628170372293601176e-01 2.670431315318285925e+00 +2.009233002565046777e-01 1.520624479603877250e+15 9.352841518507868750e+14 4.509775415381218750e+14 1.656709960385361335e-01 3.435857503850426320e-01 2.523878726516314286e-01 2.478727632769107014e+00 +2.154434690031884481e-01 1.361061267880110500e+15 8.763590355668608750e+14 4.472192180713363750e+14 1.642903392766633663e-01 3.219390345127858821e-01 2.422943476160940024e-01 2.310667608598216738e+00 +2.310129700083160265e-01 1.214730761104602750e+15 8.190105594091615000e+14 4.424774600698740000e+14 1.625484082519017826e-01 3.008715127600753436e-01 2.325014803696862364e-01 2.162823136601202290e+00 +2.477076355991711387e-01 1.080927116020872625e+15 7.633621749172230000e+14 4.367652326269220000e+14 1.604499658176181121e-01 2.804285362533715520e-01 2.229798899781203492e-01 2.032359636987663531e+00 +2.656087782946686682e-01 9.589442163468533750e+14 7.095277875475581250e+14 4.301027349125041250e+14 1.580024323358232563e-01 2.606519492724811426e-01 2.137050773047265151e-01 1.916917823750690308e+00 +2.848035868435802032e-01 8.480793285175710000e+14 6.576107458667155000e+14 4.225173995689320000e+14 1.552158854550853562e-01 2.415797179207735401e-01 2.046568230342647454e-01 1.814521917011921781e+00 +3.053855508833415722e-01 7.476366254655651250e+14 6.077029296866702500e+14 4.140437995502017500e+14 1.521030258870739449e-01 2.232455951428273244e-01 1.958186846910025536e-01 1.723507736430197612e+00 +3.274549162877728459e-01 6.569305456469673750e+14 5.598839529426392500e+14 4.047234601027251250e+14 1.486791083358488808e-01 2.056788278938255499e-01 1.871775719406047478e-01 1.642465897436292677e+00 +3.511191734215131088e-01 5.752889566908533750e+14 5.142204973753063125e+14 3.946045741682043125e+14 1.449618369483319236e-01 1.889039123612258064e-01 1.787233832804424327e-01 1.570196590399937087e+00 +3.764935806792467643e-01 5.020560957220625625e+14 4.707657909016767500e+14 3.837416215659887500e+14 1.409712254172334756e-01 1.729404023392087375e-01 1.704486905368713667e-01 1.505673320562770812e+00 +4.037017258596555802e-01 4.365952615446967500e+14 4.295592474842642500e+14 3.721948825721952500e+14 1.367294182896005572e-01 1.578027769311132478e-01 1.623484553788619167e-01 1.448013641468195445e+00 +4.328761281083059465e-01 3.782912374245944375e+14 3.906262693180221875e+14 3.600298641838914375e+14 1.322604801993718937e-01 1.435003678808774996e-01 1.544197746730345266e-01 1.396455378323295582e+00 +4.641588833612779741e-01 3.265524271127570000e+14 3.539782190425332500e+14 3.473166429358512500e+14 1.275901544447066438e-01 1.300373493649158441e-01 1.466616461655729509e-01 1.350337200689795569e+00 +4.977023564332111460e-01 2.808126909365107188e+14 3.196125639439655000e+14 3.341291354878803750e+14 1.227455950311282656e-01 1.174127909661130814e-01 1.390747495258742861e-01 1.309082663477945108e+00 +5.336699231206309957e-01 2.405328731709928438e+14 2.875131950391641250e+14 3.205443001114738750e+14 1.177550733298639851e-01 1.056207748924760242e-01 1.316612349931398640e-01 1.272187035712282643e+00 +5.722367659350217073e-01 2.052020164035863750e+14 2.576509133107320625e+14 3.066412820381643125e+14 1.126476641132295037e-01 9.465057460033017567e-02 1.244245160519109189e-01 1.239206379465923380e+00 +6.135907273413172547e-01 1.743382631267819375e+14 2.299840836866617188e+14 2.925005157515585000e+14 1.074529157728576489e-01 8.448689504011254459e-02 1.173690635237445851e-01 1.209748468304030711e+00 +6.579332246575682053e-01 1.474894492469614062e+14 2.044594244531041875e+14 2.782028187847165625e+14 1.022005174173319375e-01 7.511016265484754539e-02 1.105002058522917552e-01 1.183465194079629246e+00 +7.054802310718645275e-01 1.242333984845648125e+14 1.810129455604445000e+14 2.638284684691093125e+14 9.691995970691612283e-02 6.649687007603054256e-02 1.038239258124501047e-01 1.160046223913667740e+00 +7.564633275546290836e-01 1.041779306747426094e+14 1.595710004885718750e+14 2.494562880592496875e+14 9.164019913252904881e-02 5.861996253658838946e-02 9.734665648897494750e-02 1.139213678634613869e+00 +8.111308307896872849e-01 8.696060067245946875e+13 1.400514376619465938e+14 2.351627579885260312e+14 8.638933152691152806e-02 5.144926085442838581e-02 9.107507691652709514e-02 1.120717668697414959e+00 +8.697490026177834288e-01 7.224818784589743750e+13 1.223648297621967969e+14 2.210211727817767500e+14 8.119428234824209445e-02 4.495191303240408248e-02 8.501591014756625098e-02 1.104332549896363203e+00 +9.326033468832198858e-01 5.973595894146687500e+13 1.064157576949809688e+14 2.071008581536815312e+14 7.608051907359930643e-02 3.909286593605841575e-02 7.917572507952334859e-02 1.089853785592569402e+00 +1.000000000000000000e+00 4.914672937013000781e+13 9.210412454806562500e+13 1.934664647629811875e+14 7.107179175268987792e-02 3.383534798893206297e-02 7.356074516362634541e-02 1.077095321617479451e+00 +1.072267222010323096e+00 4.022974965998771094e+13 7.932647376554029688e+13 1.801773438237495000e+14 6.618990363256277432e-02 2.914135341671098348e-02 6.817666388974620573e-02 1.065887394059119364e+00 +1.149756995397735571e+00 3.275944492184633203e+13 6.797729374733382812e+13 1.672870188249035625e+14 6.145451708862170737e-02 2.497212150457599894e-02 6.302847174324166524e-02 1.056074709134503742e+00 +1.232846739442065909e+00 2.653403567693038281e+13 5.795027529190035938e+13 1.548427716134821250e+14 5.688300156828245135e-02 2.128859853103115540e-02 5.812030132979503771e-02 1.047514929974611153e+00 +1.321941148466028615e+00 2.137406830977950391e+13 4.913950910325897656e+13 1.428853403649940000e+14 5.249032263743620697e-02 1.805187768378806526e-02 5.345529101234232361e-02 1.040077427328733650e+00 +1.417474162926804837e+00 1.712088276152780273e+13 4.144059959959610938e+13 1.314487347412828594e+14 4.828897407688935439e-02 1.522360822821350324e-02 4.903547087477286986e-02 1.033642246966736344e+00 +1.519911082952933201e+00 1.363504391108575195e+13 3.475168030363070312e+13 1.205601627875218281e+14 4.428895102726179006e-02 1.276636852087810296e-02 4.486167166013776270e-02 1.028099256367702719e+00 +1.629750834620645072e+00 1.079476145950517773e+13 2.897431547580177344e+13 1.102400764289521875e+14 4.049776670265742284e-02 1.064399723329699857e-02 4.093346236279631761e-02 1.023347435236665826e+00 +1.747528400007684724e+00 8.494321102523551758e+12 2.401427813036819141e+13 1.005023270721968281e+14 3.692050955232346887e-02 8.821879163728216233e-03 3.724911675932988941e-02 1.019294279310076545e+00 +1.873817422860384996e+00 6.642547423180946289e+12 1.978219746431594141e+13 9.135442429466371875e+13 3.355993829272452267e-02 7.267183076492928287e-03 3.380560984850610601e-02 1.015855290235423647e+00 +2.009233002565047776e+00 5.161316341575615234e+12 1.619407283318226953e+13 8.279788309320454688e+13 3.041660947272233420e-02 5.949050516004723323e-03 3.059864234173447980e-02 1.012953528124521441e+00 +2.154434690031884259e+00 3.984132206205844238e+12 1.317165417435336133e+13 7.482864960748995312e+13 2.748903386720764896e-02 4.838735558976393208e-03 2.762269277296286810e-02 1.010519206573616602e+00 +2.310129700083160209e+00 3.054781784682008789e+12 1.064269209949990430e+13 6.743759468788264062e+13 2.477385779406974034e-02 3.909696688314053155e-03 2.487109623666095004e-02 1.008489313459992376e+00 +2.477076355991711498e+00 2.326074591466259766e+12 8.541064423502292969e+12 6.061105861230048438e+13 2.226606322124599635e-02 3.137643274751226834e-03 2.233614607977707847e-02 1.006807244589157158e+00 +2.656087782946686904e+00 1.758676251437396484e+12 6.806788274644006836e+12 5.433143189835042969e+13 1.995918113372110655e-02 2.500540025646434943e-03 2.000921497665199625e-02 1.005422440548501051e+00 +2.848035868435801810e+00 1.320039006982927979e+12 5.385929360677923828e+12 4.857775461639333594e+13 1.784551169702355486e-02 1.978573652988173913e-03 1.788089035557306403e-02 1.004290020498431302e+00 +3.053855508833415389e+00 9.834310893597186279e+11 4.230421110883147461e+12 4.332632226923183594e+13 1.591634683303511447e-02 1.554086433466480904e-03 1.594112071246861495e-02 1.003370409279419784e+00 +3.274549162877728570e+00 7.270645370993237305e+11 3.297807853952441406e+12 3.855128397763931250e+13 1.416218996927605216e-02 1.211481862366364229e-03 1.417936801644780614e-02 1.002628956953650619e+00 +3.511191734215131088e+00 5.333191878052713013e+11 2.550926777996636719e+12 3.422521969533789453e+13 1.257296808445404132e-02 9.371078184751517604e-04 1.258476136272069536e-02 1.002035552047357392e+00 +3.764935806792467421e+00 3.880590147995317993e+11 1.957543427048936523e+12 3.031968519920422266e+13 1.113823191592882254e-02 7.191226601701461874e-04 1.114624743503522288e-02 1.001564231391584681e+00 +4.037017258596553582e+00 2.800357345210944824e+11 1.489955077462706299e+12 2.680571572875643750e+13 9.847340976587265482e-03 5.473495218720438775e-04 9.852733865757820272e-03 1.001192790631023399e+00 +4.328761281083057355e+00 2.003736708074031067e+11 1.124575317742092041e+12 2.365428177017248047e+13 8.689630991545500491e-03 4.131237053961734338e-04 8.693222367781913013e-03 1.000902400017972926e+00 +4.641588833612781961e+00 1.421292145788439636e+11 8.415121051711517334e+11 2.083669141588459375e+13 7.654561708868179264e-03 3.091376749420795124e-04 7.656928754020393343e-03 1.000677230429396047e+00 +4.977023564332113459e+00 9.991783993620965576e+10 6.241500468201835938e+11 1.832493607222290234e+13 6.731843898641319719e-03 2.292876039492487683e-04 6.733387780992088241e-03 1.000504094340441519e+00 +5.336699231206313065e+00 6.960150162074356079e+10 4.587460089386787720e+11 1.609197861156461719e+13 5.911545208473248901e-03 1.685248182655890226e-04 5.912541618474992031e-03 1.000372106014050466e+00 +5.722367659350219959e+00 4.802931090207953644e+10 3.340453828720429688e+11 1.411198490069830664e+13 5.184175217696157176e-03 1.227148276912751689e-04 5.184811470942427523e-03 1.000272364431325833e+00 +6.135907273413176100e+00 3.282463131656645966e+10 2.409245697938116150e+11 1.236050052623933789e+13 4.540750359170201041e-03 8.850598926004959012e-05 4.541152278344977831e-03 1.000197661621429646e+00 +6.579332246575682497e+00 2.221211554049404144e+10 1.720635883427042542e+11 1.081457629016583594e+13 3.972840021291966506e-03 6.320923646325481734e-05 3.973091157350422398e-03 1.000142218158482477e+00 +7.054802310718645053e+00 1.487868417444875717e+10 1.216511235373576965e+11 9.452846917720173828e+12 3.472595462109337536e-03 4.468972609346090848e-05 3.472750658385051915e-03 1.000101446664640736e+00 +7.564633275546290392e+00 9.862992725533103943e+09 8.512294593115248108e+10 8.255568625788320312e+12 3.032763610431862995e-03 3.127074397108617018e-05 3.032858450171958993e-03 1.000071743311933048e+00 +8.111308307896871739e+00 6.468514352125196457e+09 5.893342500267601013e+10 7.204620928692994141e+12 2.646687729206477317e-03 2.164976816108341308e-05 2.646745030622772808e-03 1.000050306554167712e+00 +8.697490026177835176e+00 4.195956857482413292e+09 4.035890115511917877e+10 6.283478365265076172e+12 2.308297029181576813e-03 1.482623576017746499e-05 2.308331253044947247e-03 1.000034981710555382e+00 +9.326033468832198636e+00 2.691311430106618881e+09 2.733094044697205734e+10 5.477158018165085938e+12 2.012087389618180677e-03 1.004028739674394634e-05 2.012107591756675303e-03 1.000024129551870811e+00 +1.000000000000000000e+01 1.706380886010607719e+09 1.829696972141913605e+10 4.772148323973216797e+12 1.753095205982540790e-03 6.721570187055991953e-06 1.753106989614217548e-03 1.000016516710793280e+00 diff --git a/tests/test_theory.py b/tests/test_theory.py index 526e865b8..9c482317c 100644 --- a/tests/test_theory.py +++ b/tests/test_theory.py @@ -373,6 +373,29 @@ def test_profiles(modeling_data, profile_init): reltol, ) + # Test use_projected_quad + if mod.backend == "ccl" and profile_init == "einasto": + if hasattr(mod.hdpm, 'projected_quad'): + mod.set_projected_quad(True) + assert_allclose( + mod.eval_surface_density( + cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], verbose=True + ), + cfg["numcosmo_profiles"]["Sigma"], + reltol*1e-1, + ) + assert_allclose( + theo.compute_surface_density( + cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True, + use_projected_quad=True, + ), + cfg["numcosmo_profiles"]["Sigma"], + reltol*1e-1, + ) + + delattr(mod.hdpm, "projected_quad") + assert_raises(NotImplementedError, mod.set_projected_quad, True) + def test_2halo_term(modeling_data): cfg = load_validation_config() diff --git a/tests/test_theory_parent.py b/tests/test_theory_parent.py index c57d3c0f3..c8a27cec1 100644 --- a/tests/test_theory_parent.py +++ b/tests/test_theory_parent.py @@ -21,6 +21,7 @@ def test_unimplemented(modeling_data): assert_raises(NotImplementedError, mod._update_halo_density_profile) assert_raises(NotImplementedError, mod._set_einasto_alpha, 0.5) assert_raises(NotImplementedError, mod._get_einasto_alpha) + assert_raises(NotImplementedError, mod._set_projected_quad, True) assert_raises(NotImplementedError, mod.eval_3d_density, [0.3], 0.3) assert_raises(NotImplementedError, mod.eval_surface_density, [0.3], 0.3) assert_raises(NotImplementedError, mod.eval_mean_surface_density, [0.3], 0.3) @@ -91,6 +92,16 @@ def test_instantiate(modeling_data): assert_raises(ValueError, mod.set_halo_density_profile, halo_profile_model="bla") assert_raises(ValueError, mod.set_halo_density_profile, massdef="blu") + if theo.be_nick in ["nc", "ccl"]: + mod.set_halo_density_profile(massdef="virial") + assert_equal(mod.massdef, "virial") + + # reset + mod.massdef = "mean" + + mod.massdef = "virial" + assert_equal(mod.massdef, "virial") + if theo.be_nick == "nc": import gi @@ -150,3 +161,18 @@ def test_einasto(modeling_data): mod.eval_reduced_tangential_shear(0.1, 0.1, 0.5, verbose=True) mod.eval_magnification(0.1, 0.1, 0.5, verbose=True) mod.eval_magnification_bias(0.1, 2, 0.1, 0.5, verbose=True) + + +def test_set_projected_quad(modeling_data): + """Test set_projected_quad method""" + mod = theo.Modeling() + assert_raises(NotImplementedError, mod.set_projected_quad, True) + + if theo.be_nick == "ccl": + assert_raises(NotImplementedError, mod.set_projected_quad, True) + mod.set_halo_density_profile("hernquist") + assert_raises(NotImplementedError, mod.set_projected_quad, True) + mod.set_halo_density_profile("einasto") + mod.set_projected_quad(True) + else: + assert_raises(NotImplementedError, mod.set_projected_quad, True) From bf1b9e36fd63ad19354e432525c14bfbfee0ed04 Mon Sep 17 00:00:00 2001 From: Michel Aguena Date: Mon, 16 Oct 2023 15:45:59 +0200 Subject: [PATCH 4/4] Issue/572/dataops redshift (#596) * rename z_source->z_src * rm internal computation of sigma_c from compute_tangential_and_cross_components and compute_galaxy_weights * rm unnecessary use_pdz args in GalaxyCluster * create _validate_data_z_src func * update compute_background_probability, GalaxyCluster.compute_galaxy_weights * update z_src in .json files * make sigma_c=None for gamma components * force recomputation of sigma_c in GalaxyCluster when use_pdz flag is changed * separate sigma_c and sigma_c_eff in galcat * Update version to 1.10.0 --- clmm/__init__.py | 2 +- clmm/dataops/__init__.py | 223 +++++------------- clmm/galaxycluster.py | 70 +++--- clmm/support/mock_data.py | 4 +- clmm/theory/func_layer.py | 116 ++++----- clmm/utils/__init__.py | 1 + clmm/utils/validation.py | 17 ++ ...e1_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb | 14 +- ...e2_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb | 24 +- examples/NumCosmo/modeling_cmp_numcosmo.ipynb | 28 +-- examples/Paper_v1.0/gt_and_use_case.ipynb | 8 +- examples/Paper_v1.0/mcmc.ipynb | 20 +- .../demo_compute_deltasigma_weights.ipynb | 160 ++++++++----- examples/demo_theory_functionality.ipynb | 14 +- examples/demo_theory_functionality_oo.ipynb | 12 +- ...mple3_Fit_Halo_Mass_to_Shear_Catalog.ipynb | 4 +- .../Example4_Fit_Halo_mass_to_HSC_data.ipynb | 4 +- .../Example5_Fit_Halo_mass_to_DES_data.ipynb | 4 +- examples/other_flat_sky_limitations.ipynb | 8 +- tests/data/numcosmo/config.json | 2 +- .../numcosmo/config_einasto_benchmarks.json | 2 +- .../numcosmo/config_hernquist_benchmarks.json | 2 +- tests/data/numcosmo/config_old_units.json | 2 +- ..._einasto_hernquist_benchmarks_fromNC.ipynb | 36 +-- tests/test_clusterensemble.py | 4 +- tests/test_cosmo_parent.py | 10 +- tests/test_dataops.py | 200 ++++------------ tests/test_galaxycluster.py | 45 ++-- tests/test_theory.py | 80 +++---- 29 files changed, 487 insertions(+), 629 deletions(-) diff --git a/clmm/__init__.py b/clmm/__init__.py index 4071ee026..9689bbd54 100644 --- a/clmm/__init__.py +++ b/clmm/__init__.py @@ -26,4 +26,4 @@ ) from . import support -__version__ = "1.9.0" +__version__ = "1.10.0" diff --git a/clmm/dataops/__init__.py b/clmm/dataops/__init__.py index 4a2e3de44..33adb2dd9 100644 --- a/clmm/dataops/__init__.py +++ b/clmm/dataops/__init__.py @@ -13,6 +13,7 @@ validate_argument, _validate_ra, _validate_dec, + _validate_is_deltasigma_sigma_c, ) from ..redshift import ( _integ_pzfuncs, @@ -30,13 +31,7 @@ def compute_tangential_and_cross_components( shear2, geometry="curve", is_deltasigma=False, - cosmo=None, - z_lens=None, - z_source=None, sigma_c=None, - use_pdz=False, - pzbins=None, - pzpdf=None, validate_input=True, ): r"""Computes tangential- and cross- components for shear or ellipticity @@ -76,17 +71,15 @@ def compute_tangential_and_cross_components( g_t =& -\left( g_1\cos\left(2\phi\right)+g_2\sin\left(2\phi\right)\right)\\ g_x =& g_1 \sin\left(2\phi\right)-g_2\cos\left(2\phi\right) - Finally, and if requested by the user throught the `is_deltasigma` flag, an estimate of the - excess surface density :math:`\widehat{\Delta\Sigma}` is obtained from + Finally, if the critical surface density (:math:`\Sigma_\text{crit}`) is provided, an estimate + of the excess surface density :math:`\widehat{\Delta\Sigma}` is obtained from .. math:: - \widehat{\Delta\Sigma_{t,x}} = g_{t,x} \times \Sigma_c(cosmo, z_l, z_{\text{src}}) + \widehat{\Delta\Sigma_{t,x}} = g_{t,x} \times \Sigma_\text{crit}(z_l, z_{\text{src}}) - where :math:`\Sigma_c` is the critical surface density that depends on the cosmology and on - the lens and source redshifts. If :math:`g_{t,x}` correspond to the shear, the above - expression is an accurate. However, if :math:`g_{t,x}` correspond to ellipticities or reduced - shear, this expression only gives an estimate :math:`\widehat{\Delta\Sigma_{t,x}}`, valid only - in the weak lensing regime. + If :math:`g_{t,x}` correspond to the shear, the above expression is an accurate. However, if + :math:`g_{t,x}` correspond to ellipticities or reduced shear, this expression only gives an + estimate :math:`\widehat{\Delta\Sigma_{t,x}}`, valid only in the weak lensing regime. Parameters ---------- @@ -107,28 +100,10 @@ def compute_tangential_and_cross_components( Options are curve (uses astropy) or flat. is_deltasigma: bool If `True`, the tangential and cross components returned are multiplied by Sigma_crit. - Results in units of :math:`M_\odot\ Mpc^{-2}` - cosmo: clmm.Cosmology, optional - Required if `is_deltasigma` is True and `sigma_c` not provided. - Not used if `sigma_c` is provided. - z_lens: float, optional - Redshift of the lens, required if `is_deltasigma` is True and `sigma_c` not provided. - Not used if `sigma_c` is provided. - z_source: array, optional - Redshift of the source, required if `is_deltasigma` is True and `sigma_c` not provided. - Not used if `sigma_c` is provided or `use_pdz=True`. - sigma_c : float, optional - Critical surface density in units of :math:`M_\odot\ Mpc^{-2}`, - if provided, `cosmo`, `z_lens` and `z_source` are not used. - use_pdz: bool - Flag to use or not the source redshift p(z), required if `is_deltasigma` is True - and `sigma_c` not provided. If `False`, the point estimate provided by `z_source` is used. - pzpdf : array, optional - Photometric probablility density functions of the source galaxies, required if - `is_deltasigma=True` and `use_pdz=True` and `sigma_c` not provided. - pzbins : array, optional - Redshift axis on which the individual photoz pdf is tabulated, required if - `is_deltasigma=True` and `use_pdz=True` and `sigma_c` not provided. + It requires `sigma_c` argument. Results in units of :math:`M_\odot\ Mpc^{-2}` + sigma_c : None, array_like + Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`. + Used only when is_deltasigma=True. validate_input: bool Validade each input argument @@ -152,15 +127,13 @@ def compute_tangential_and_cross_components( validate_argument(locals(), "shear1", "float_array") validate_argument(locals(), "shear2", "float_array") validate_argument(locals(), "geometry", str) - validate_argument(locals(), "is_deltasigma", bool) - validate_argument(locals(), "z_lens", float, argmin=0, eqmin=True, none_ok=True) - validate_argument(locals(), "z_source", "float_array", argmin=0, eqmin=True, none_ok=True) validate_argument(locals(), "sigma_c", "float_array", none_ok=True) ra_source_, dec_source_, shear1_, shear2_ = arguments_consistency( [ra_source, dec_source, shear1, shear2], names=("Ra", "Dec", "Shear1", "Shear2"), prefix="Tangential- and Cross- shape components sources", ) + _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c) elif np.iterable(ra_source): ra_source_, dec_source_, shear1_, shear2_ = ( np.array(col) for col in [ra_source, dec_source, shear1, shear2] @@ -182,58 +155,33 @@ def compute_tangential_and_cross_components( # Compute the tangential and cross shears tangential_comp = _compute_tangential_shear(shear1_, shear2_, phi) cross_comp = _compute_cross_shear(shear1_, shear2_, phi) - # If the is_deltasigma flag is True, multiply the results by Sigma_crit. - - if is_deltasigma: - if sigma_c is None and use_pdz is False: - # Need to verify that cosmology and redshifts are provided - if any(t_ is None for t_ in (z_lens, z_source, cosmo)): - raise TypeError( - "To compute DeltaSigma, please provide a " - "i) cosmology, ii) redshift of lens and sources" - ) - - sigma_c = cosmo.eval_sigma_crit(z_lens, z_source) - - elif sigma_c is None: - # Need to verify that cosmology, lens redshift, source redshift bins and - # source redshift pdf are provided - if any(t_ is None for t_ in (z_lens, cosmo, pzbins, pzpdf)): - raise TypeError( - "To compute DeltaSigma using the redshift pdz of the sources, " - "please provide a " - "i) cosmology, ii) lens redshift, iii) source redshift bins and" - "iv) source redshift pdf" - ) - - sigma_c = compute_critical_surface_density_eff( - cosmo, z_lens, pzbins=pzbins, pzpdf=pzpdf - ) - tangential_comp *= sigma_c - cross_comp *= sigma_c + if sigma_c is not None: + _sigma_c_arr = np.array(sigma_c) + tangential_comp *= _sigma_c_arr + cross_comp *= _sigma_c_arr + return angsep, tangential_comp, cross_comp def compute_background_probability( - z_lens, z_source=None, use_pdz=False, pzpdf=None, pzbins=None, validate_input=True + z_lens, z_src=None, use_pdz=False, pzpdf=None, pzbins=None, validate_input=True ): - r"""Probability for being a background galaxy + r"""Probability for being a background galaxy, defined by: + + .. math:: + P(z_s > z_l) = \int_{z_l}^{+\infty} dz_s \; p_{\text{photoz}}(z_s), + + when the photometric probability density functions (:math:`p_{\text{photoz}}(z_s)`) are + provided. In the case of true redshifts, it returns 1 if :math:`z_s > z_l` else returns 0. + Parameters ---------- z_lens: float Redshift of the lens. - z_source: array, optional + z_src: array, optional Redshift of the source. Used only if pzpdf=pzbins=None. - use_pdz: bool - Flag to use or not the source redshif. If `False`, - the point estimate provided by `z_source` is used. - pzpdf : array, optional - Photometric probablility density functions of the source galaxies. - Used instead of z_source if provided. - pzbins : array, optional - Redshift axis on which the individual photoz pdf is tabulated. Returns ------- @@ -242,12 +190,12 @@ def compute_background_probability( """ if validate_input: validate_argument(locals(), "z_lens", float, argmin=0, eqmin=True) - validate_argument(locals(), "z_source", "float_array", argmin=0, eqmin=True, none_ok=True) + validate_argument(locals(), "z_src", "float_array", argmin=0, eqmin=True, none_ok=True) if use_pdz is False: - if z_source is None: - raise ValueError("z_source must be provided.") - p_background = np.array(z_source > z_lens, dtype=float) + if z_src is None: + raise ValueError("z_src must be provided.") + p_background = np.array(z_src > z_lens, dtype=float) else: if pzpdf is None or pzbins is None: raise ValueError("pzbins must be provided with pzpdf.") @@ -257,12 +205,6 @@ def compute_background_probability( def compute_galaxy_weights( - z_lens, - cosmo, - z_source=None, - use_pdz=False, - pzpdf=None, - pzbins=None, use_shape_noise=False, shape_component1=None, shape_component2=None, @@ -278,55 +220,39 @@ def compute_galaxy_weights( The weights :math:`w_{ls}` express as : :math:`w_{ls} = w_{ls, \text{geo}} \times w_{ls, \text{shape}}`, following E. S. Sheldon et al. (2003), arXiv:astro-ph/0312036: - 1. The geometrical weight :math:`w_{ls, \text{geo}}` depends on lens and source redshift - information. When considering only redshift point estimates, the weights read + 1. If computed for shear, the geometrical weights :math:`w_{ls, \text{geo}}` are equal to 1. If + computed for :math:`\Delta \Sigma`, it depends on lens and source redshift information via the + critical surface density. This component can be expressed as: .. math:: - w_{ls, \text{geo}} = \Sigma_c(\text{cosmo}, z_l, z_{\text{src}})^{-2}\;. + w_{ls, \text{geo}} = \Sigma_\text{crit}(z_l, z_{\text{src}})^{-2}\;. + + when only redshift point estimates are provided, or as: - If the redshift pdf of each source, :math:`p_{\text{photoz}}(z_s)`, is known, - the weights are computed instead as .. math:: - w_{ls, \text{geo}} = \left[\int_{\delta + z_l} dz_s p_{\text{photoz}}(z_s) - \Sigma_c(\text{cosmo}, z_l, z_s)^{-1}\right]^2 + w_{ls, \text{geo}} = \Sigma_\text{crit}^\text{eff}(z_l, z_{\text{src}})^{-2} + = \left[\int_{\delta + z_l} dz_s \; p_{\text{photoz}}(z_s) + \Sigma_\text{crit}(z_l, z_s)^{-1}\right]^2 - for the tangential shear, the weights :math:`w_{ls, \text{geo}}` are 1. + when the redshift pdf of each source, :math:`p_{\text{photoz}}(z_s)`, is known. 2. The shape weight :math:`w_{ls,{\text{shape}}}` depends on shapenoise and/or shape measurement errors .. math:: - w_{ls, \text{shape}} = 1/(\sigma_{\text{shapenoise}}^2 + - \sigma_{\text{measurement}}^2) - - - 3. The probability for a galaxy to be in the background of the cluster is defined by: - - .. math:: - P(z_s > z_l) = \int_{z_l}^{+\infty} dz_s p_{\text{photoz}}(z_s) - - The function return the probability for a galaxy to be in the background of the cluster; - if photometric probability density functions are provoded, the function computes the above - integral. In the case of true redshifts, it returns 1 if :math:`z_s > z_l` else returns 0. + w_{ls, \text{shape}}^{-1} = \sigma_{\text{shapenoise}}^2 + + \sigma_{\text{measurement}}^2 Parameters ---------- - z_lens: float - Redshift of the lens. - z_source: array_like, optional - Redshift of the source (point estimate). Used only if `use_pdz=False`. - cosmo: clmm.Comology object, None - CLMM Cosmology object. - use_pdz: bool - Flag to use or not the source redshift p(z). If `False` (default) the point estimate - provided by `z_source` is used. - pzpdf : array_like, optional - Photometric probablility density functions of the source galaxies. - Used instead of z_source if `use_pdz=True` - pzbins : array_like, optional - Redshift axis on which the individual photoz pdf is tabulated. Required if `use_pdz=True` + is_deltasigma: bool + If `False`, weights are computed for shear, else weights are computed for + :math:`\Delta \Sigma`. + sigma_c : None, array_like + Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`. + Used only when is_deltasigma=True. use_shape_noise: bool If `True` shape noise is included in the weight computation. It then requires `shape_componenet{1,2}` to be provided. Default: False. @@ -345,8 +271,6 @@ def compute_galaxy_weights( shape_component2_err: array_like The measurement error on the 2nd-component of ellipticity of the source galaxies, used if `use_shape_error=True` - is_deltasigma: bool - Indicates whether it is the excess surface density or the tangential shear validate_input: bool Validade each input argument @@ -356,54 +280,27 @@ def compute_galaxy_weights( Individual lens source pair weights """ if validate_input: - validate_argument(locals(), "z_lens", float, argmin=0, eqmin=True) - validate_argument(locals(), "z_source", "float_array", argmin=0, eqmin=True, none_ok=True) - validate_argument(locals(), "use_pdz", bool) - # validate_argument(locals(), 'pzpdf', 'float_array', none_ok=True) - # validate_argument(locals(), 'pzbins', 'float_array', none_ok=True) + validate_argument(locals(), "sigma_c", "float_array", none_ok=True) validate_argument(locals(), "shape_component1", "float_array", none_ok=True) validate_argument(locals(), "shape_component2", "float_array", none_ok=True) validate_argument(locals(), "shape_component1_err", "float_array", none_ok=True) validate_argument(locals(), "shape_component2_err", "float_array", none_ok=True) validate_argument(locals(), "use_shape_noise", bool) - validate_argument(locals(), "is_deltasigma", bool) + validate_argument(locals(), "use_shape_error", bool) arguments_consistency( [shape_component1, shape_component2], names=("shape_component1", "shape_component2"), prefix="Shape components sources", ) + _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c) # computing w_ls_geo - - if is_deltasigma is False: - w_ls_geo = 1.0 - else: - if sigma_c is None and use_pdz is False: - # Need to verify that cosmology and redshifts are provided - if any(t_ is None for t_ in (z_lens, z_source, cosmo)): - raise TypeError( - "To compute DeltaSigma, please provide a " - "i) cosmology, ii) redshift of lens and sources" - ) - sigma_c = cosmo.eval_sigma_crit(z_lens, z_source) - elif sigma_c is None: - # Need to verify that cosmology, lens redshift, source redshift bins and - # source redshift pdf are provided - if any(t_ is None for t_ in (z_lens, cosmo, pzbins, pzpdf)): - raise TypeError( - "To compute DeltaSigma using the redshift pdz of the sources, " - "please provide a " - "i) cosmology, ii) lens redshift, iii) source redshift bins and" - "iv) source redshift pdf" - ) - sigma_c = compute_critical_surface_density_eff( - cosmo, z_lens, pzbins=pzbins, pzpdf=pzpdf - ) - w_ls_geo = 1.0 / sigma_c**2 + w_ls_geo = 1.0 + if sigma_c is not None: + w_ls_geo /= np.array(sigma_c) ** 2 # computing w_ls_shape - ngals = len(pzpdf) if use_pdz else len(z_source) - err_e2 = np.zeros(ngals) + err_e2 = 0 if use_shape_noise: if shape_component1 is None or shape_component2 is None: @@ -420,8 +317,12 @@ def compute_galaxy_weights( ) err_e2 += shape_component1_err**2 err_e2 += shape_component2_err**2 - w_ls_shape = np.ones(ngals) - w_ls_shape[err_e2 > 0] = 1.0 / err_e2[err_e2 > 0] + + if hasattr(err_e2, "__len__"): + w_ls_shape = np.ones(len(err_e2)) + w_ls_shape[err_e2 > 0] = 1.0 / err_e2[err_e2 > 0] + else: + w_ls_shape = 1.0 / err_e2 if err_e2 > 0 else 1.0 w_ls = w_ls_shape * w_ls_geo diff --git a/clmm/galaxycluster.py b/clmm/galaxycluster.py index cbd6e51e4..b4db5446c 100644 --- a/clmm/galaxycluster.py +++ b/clmm/galaxycluster.py @@ -114,7 +114,7 @@ def _repr_html_(self): f"
{self.galcat._html_table()}" ) - def add_critical_surface_density(self, cosmo, use_pdz=False): + def add_critical_surface_density(self, cosmo, use_pdz=False, force=False): r"""Computes the critical surface density for each galaxy in `galcat`. It only runs if input cosmo != galcat cosmo or if `sigma_c` not in `galcat`. @@ -128,6 +128,8 @@ def add_critical_surface_density(self, cosmo, use_pdz=False): `sigma_c` is computed as 1/<1/Sigma_crit>, where the average is performed using the individual galaxy redshift pdf. In that case, the `galcat` table should have pzbins` and `pzpdf` columns. + force : bool + Force recomputation of sigma_c. Returns ------- @@ -135,7 +137,12 @@ def add_critical_surface_density(self, cosmo, use_pdz=False): """ if cosmo is None: raise TypeError("To compute Sigma_crit, please provide a cosmology") - if cosmo.get_desc() != self.galcat.meta["cosmo"] or "sigma_c" not in self.galcat.columns: + sigmac_colname = "sigma_c_eff" if use_pdz else "sigma_c" + if ( + cosmo.get_desc() != self.galcat.meta["cosmo"] + or sigmac_colname not in self.galcat.columns + or force + ): if self.z is None: raise TypeError("Cluster's redshift is None. Cannot compute Sigma_crit") if not use_pdz and "z" not in self.galcat.columns: @@ -149,19 +156,18 @@ def add_critical_surface_density(self, cosmo, use_pdz=False): ) self.galcat.update_cosmo(cosmo, overwrite=True) - if use_pdz is False: - self.galcat["sigma_c"] = cosmo.eval_sigma_crit(self.z, self.galcat["z"]) - self.galcat.meta["sigmac_type"] = "standard" + if not use_pdz: + self.galcat[sigmac_colname] = cosmo.eval_sigma_crit(self.z, self.galcat["z"]) else: zdata = self._get_input_galdata({"pzpdf": "pzpdf", "pzbins": "pzbins"}) - self.galcat["sigma_c"] = compute_critical_surface_density_eff( + self.galcat[sigmac_colname] = compute_critical_surface_density_eff( cosmo=cosmo, z_cluster=self.z, pzbins=zdata["pzbins"], pzpdf=zdata["pzpdf"], validate_input=self.validate_input, ) - self.galcat.meta["sigmac_type"] = "effective" + return sigmac_colname def _get_input_galdata(self, col_dict): """ @@ -211,15 +217,14 @@ def compute_tangential_and_cross_components( r"""Adds a tangential- and cross- components for shear or ellipticity to self Calls `clmm.dataops.compute_tangential_and_cross_components` with the following arguments: - ra_lens: cluster Ra - dec_lens: cluster Dec + ra_lens: `cluster` Ra + dec_lens: `cluster` Dec ra_source: `galcat` Ra dec_source: `galcat` Dec shear1: `galcat` shape_component1 shear2: `galcat` shape_component2 geometry: `input` geometry is_deltasigma: `input` is_deltasigma - sigma_c: `galcat` sigma_c | None Parameters ---------- @@ -258,26 +263,23 @@ def compute_tangential_and_cross_components( Cross shear (or assimilated quantity) for each source galaxy """ # Check is all the required data is available - cols = self._get_input_galdata( - { - "ra_source": "ra", - "dec_source": "dec", - "shear1": shape_component1, - "shear2": shape_component2, - } - ) - + col_dict = { + "ra_source": "ra", + "dec_source": "dec", + "shear1": shape_component1, + "shear2": shape_component2, + } if is_deltasigma: - self.add_critical_surface_density(cosmo, use_pdz=use_pdz) - cols["sigma_c"] = self.galcat["sigma_c"] + sigmac_colname = self.add_critical_surface_density(cosmo, use_pdz=use_pdz) + col_dict.update({"sigma_c": sigmac_colname}) + cols = self._get_input_galdata(col_dict) # compute shears angsep, tangential_comp, cross_comp = compute_tangential_and_cross_components( + is_deltasigma=is_deltasigma, ra_lens=self.ra, dec_lens=self.dec, geometry=geometry, - is_deltasigma=is_deltasigma, - use_pdz=use_pdz, validate_input=self.validate_input, **cols, ) @@ -285,6 +287,10 @@ def compute_tangential_and_cross_components( self.galcat["theta"] = angsep self.galcat[tan_component] = tangential_comp self.galcat[cross_component] = cross_comp + if is_deltasigma: + sigmac_type = "effective" if use_pdz else "standard" + self.galcat.meta[f"{tan_component}_sigmac_type"] = sigmac_type + self.galcat.meta[f"{cross_component}_sigmac_type"] = sigmac_type return angsep, tangential_comp, cross_comp def compute_background_probability( @@ -308,7 +314,7 @@ def compute_background_probability( Probability for being a background galaxy """ cols = self._get_input_galdata( - {"pzpdf": "pzpdf", "pzbins": "pzbins"} if use_pdz else {"z_source": "z"} + {"pzpdf": "pzpdf", "pzbins": "pzbins"} if use_pdz else {"z_src": "z"} ) p_background = compute_background_probability( self.z, use_pdz=use_pdz, validate_input=self.validate_input, **cols @@ -369,12 +375,9 @@ def compute_galaxy_weights( """ # input cols col_dict = {} - if use_pdz: - col_dict.update({"pzpdf": "pzpdf", "pzbins": "pzbins"}) if is_deltasigma: - if "sigma_c" not in self.galcat.columns: - self.add_critical_surface_density(cosmo, use_pdz=use_pdz) - col_dict.update({"z_source": "z", "sigma_c": "sigma_c"}) + sigmac_colname = self.add_critical_surface_density(cosmo, use_pdz=use_pdz) + col_dict.update({"sigma_c": sigmac_colname}) if use_shape_noise: col_dict.update( { @@ -393,17 +396,18 @@ def compute_galaxy_weights( # computes weights w_ls = compute_galaxy_weights( - self.z, - cosmo, - use_pdz=use_pdz, + is_deltasigma=is_deltasigma, use_shape_noise=use_shape_noise, use_shape_error=use_shape_error, - is_deltasigma=is_deltasigma, validate_input=self.validate_input, **cols, ) if add: self.galcat[weight_name] = w_ls + if is_deltasigma: + self.galcat.meta[f"{weight_name}_sigmac_type"] = ( + "effective" if use_pdz else "standard" + ) return w_ls def draw_gal_z_from_pdz(self, zcol_out="z", overwrite=False, nobj=1, xmin=None, xmax=None): diff --git a/clmm/support/mock_data.py b/clmm/support/mock_data.py index 8ef515f90..170b7c94b 100644 --- a/clmm/support/mock_data.py +++ b/clmm/support/mock_data.py @@ -392,7 +392,7 @@ def _generate_galaxy_catalog( mdelta=cluster_m, cdelta=cluster_c, z_cluster=cluster_z, - z_source=galaxy_catalog["ztrue"], + z_src=galaxy_catalog["ztrue"], cosmo=cosmo, delta_mdef=delta_so, halo_profile_model=halo_profile_model, @@ -407,7 +407,7 @@ def _generate_galaxy_catalog( mdelta=cluster_m, cdelta=cluster_c, z_cluster=cluster_z, - z_source=galaxy_catalog["ztrue"], + z_src=galaxy_catalog["ztrue"], cosmo=cosmo, delta_mdef=delta_so, halo_profile_model=halo_profile_model, diff --git a/clmm/theory/func_layer.py b/clmm/theory/func_layer.py index 0eb2d50c5..ac43d69bd 100644 --- a/clmm/theory/func_layer.py +++ b/clmm/theory/func_layer.py @@ -532,7 +532,7 @@ def compute_tangential_shear( mdelta, cdelta, z_cluster, - z_source, + z_src, cosmo, delta_mdef=200, halo_profile_model="nfw", @@ -563,7 +563,7 @@ def compute_tangential_shear( Galaxy cluster NFW concentration. z_cluster : float Galaxy cluster redshift - z_source : array_like, float, function + z_src : array_like, float, function Information on the background source galaxy redshift(s). Value required depends on `z_src_info` (see below). cosmo : clmm.cosmology.Cosmology object @@ -590,18 +590,18 @@ def compute_tangential_shear( If None, use the default value of the backend. (0.25 for the NumCosmo backend and a cosmology-dependent value for the CCL backend.) z_src_info : str, optional - Type of redshift information provided by the `z_source` argument. + Type of redshift information provided by the `z_src` argument. The following supported options are: - * 'discrete' (default) : The redshift of sources is provided by `z_source`. - It can be individual redshifts for each source galaxy when `z_source` is an array - or all sources are at the same redshift when `z_source` is a float. + * 'discrete' (default) : The redshift of sources is provided by `z_src`. + It can be individual redshifts for each source galaxy when `z_src` is an array + or all sources are at the same redshift when `z_src` is a float. - * 'distribution' : A redshift distribution function is provided by `z_source`. - `z_source` must be a one dimensional function. + * 'distribution' : A redshift distribution function is provided by `z_src`. + `z_src` must be a one dimensional function. - * 'beta' : The averaged lensing efficiency is provided by `z_source`. - `z_source` must be a tuple containing + * 'beta' : The averaged lensing efficiency is provided by `z_src`. + `z_src` must be a tuple containing ( :math:`\langle \beta_s \rangle, \langle \beta_s^2 \rangle`), the lensing efficiency and square of the lensing efficiency averaged over the galaxy redshift distribution repectively. @@ -655,7 +655,7 @@ def compute_tangential_shear( tangential_shear = _modeling_object.eval_tangential_shear( r_proj, z_cluster, - z_source, + z_src, z_src_info=z_src_info, beta_kwargs=beta_kwargs, verbose=verbose, @@ -670,7 +670,7 @@ def compute_convergence( mdelta, cdelta, z_cluster, - z_source, + z_src, cosmo, delta_mdef=200, halo_profile_model="nfw", @@ -701,7 +701,7 @@ def compute_convergence( Galaxy cluster NFW concentration. z_cluster : float Galaxy cluster redshift - z_source : array_like, float, function + z_src : array_like, float, function Information on the background source galaxy redshift(s). Value required depends on `z_src_info` (see below). cosmo : clmm.cosmology.Cosmology object @@ -728,18 +728,18 @@ def compute_convergence( If None, use the default value of the backend. (0.25 for the NumCosmo backend and a cosmology-dependent value for the CCL backend.) z_src_info : str, optional - Type of redshift information provided by the `z_source` argument. + Type of redshift information provided by the `z_src` argument. The following supported options are: - * 'discrete' (default) : The redshift of sources is provided by `z_source`. - It can be individual redshifts for each source galaxy when `z_source` is an array - or all sources are at the same redshift when `z_source` is a float. + * 'discrete' (default) : The redshift of sources is provided by `z_src`. + It can be individual redshifts for each source galaxy when `z_src` is an array + or all sources are at the same redshift when `z_src` is a float. - * 'distribution' : A redshift distribution function is provided by `z_source`. - `z_source` must be a one dimensional function. + * 'distribution' : A redshift distribution function is provided by `z_src`. + `z_src` must be a one dimensional function. - * 'beta' : The averaged lensing efficiency is provided by `z_source`. - `z_source` must be a tuple containing + * 'beta' : The averaged lensing efficiency is provided by `z_src`. + `z_src` must be a tuple containing ( :math:`\langle \beta_s \rangle, \langle \beta_s^2 \rangle`), the lensing efficiency and square of the lensing efficiency averaged over the galaxy redshift distribution repectively. @@ -789,7 +789,7 @@ def compute_convergence( convergence = _modeling_object.eval_convergence( r_proj, z_cluster, - z_source, + z_src, z_src_info=z_src_info, beta_kwargs=beta_kwargs, verbose=verbose, @@ -804,7 +804,7 @@ def compute_reduced_tangential_shear( mdelta, cdelta, z_cluster, - z_source, + z_src, cosmo, delta_mdef=200, halo_profile_model="nfw", @@ -831,7 +831,7 @@ def compute_reduced_tangential_shear( Galaxy cluster NFW concentration. z_cluster : float Galaxy cluster redshift - z_source : array_like, float, function + z_src : array_like, float, function Information on the background source galaxy redshift(s). Value required depends on `z_src_info` (see below). cosmo : clmm.cosmology.Cosmology object @@ -858,18 +858,18 @@ def compute_reduced_tangential_shear( If None, use the default value of the backend. (0.25 for the NumCosmo backend and a cosmology-dependent value for the CCL backend.) z_src_info : str, optional - Type of redshift information provided by the `z_source` argument. + Type of redshift information provided by the `z_src` argument. The following supported options are: - * 'discrete' (default) : The redshift of sources is provided by `z_source`. - It can be individual redshifts for each source galaxy when `z_source` is an array - or all sources are at the same redshift when `z_source` is a float. + * 'discrete' (default) : The redshift of sources is provided by `z_src`. + It can be individual redshifts for each source galaxy when `z_src` is an array + or all sources are at the same redshift when `z_src` is a float. - * 'distribution' : A redshift distribution function is provided by `z_source`. - `z_source` must be a one dimensional function. + * 'distribution' : A redshift distribution function is provided by `z_src`. + `z_src` must be a one dimensional function. - * 'beta' : The averaged lensing efficiency is provided by `z_source`. - `z_source` must be a tuple containing + * 'beta' : The averaged lensing efficiency is provided by `z_src`. + `z_src` must be a tuple containing ( :math:`\langle \beta_s \rangle, \langle \beta_s^2 \rangle`), the lensing efficiency and square of the lensing efficiency averaged over the galaxy redshift distribution repectively. @@ -887,7 +887,7 @@ def compute_reduced_tangential_shear( * None (default): Requires `z_src_info` to be 'discrete' or 'distribution'. If `z_src_info='discrete'`, full computation is made for each - `r_proj, z_source` pair individually. If `z_src_info='distribution'`, reduced + `r_proj, z_src` pair individually. If `z_src_info='distribution'`, reduced tangential shear at each value of `r_proj` is calculated as .. math:: @@ -959,7 +959,7 @@ def compute_reduced_tangential_shear( red_tangential_shear = _modeling_object.eval_reduced_tangential_shear( r_proj, z_cluster, - z_source, + z_src, z_src_info=z_src_info, approx=approx, beta_kwargs=beta_kwargs, @@ -975,7 +975,7 @@ def compute_magnification( mdelta, cdelta, z_cluster, - z_source, + z_src, cosmo, delta_mdef=200, halo_profile_model="nfw", @@ -1002,7 +1002,7 @@ def compute_magnification( Galaxy cluster NFW concentration. z_cluster : float Galaxy cluster redshift - z_source : array_like, float, function + z_src : array_like, float, function Information on the background source galaxy redshift(s). Value required depends on `z_src_info` (see below). cosmo : clmm.cosmology.Cosmology object @@ -1029,18 +1029,18 @@ def compute_magnification( If None, use the default value of the backend. (0.25 for the NumCosmo backend and a cosmology-dependent value for the CCL backend.) z_src_info : str, optional - Type of redshift information provided by the `z_source` argument. + Type of redshift information provided by the `z_src` argument. The following supported options are: - * 'discrete' (default) : The redshift of sources is provided by `z_source`. - It can be individual redshifts for each source galaxy when `z_source` is an array - or all sources are at the same redshift when `z_source` is a float. + * 'discrete' (default) : The redshift of sources is provided by `z_src`. + It can be individual redshifts for each source galaxy when `z_src` is an array + or all sources are at the same redshift when `z_src` is a float. - * 'distribution' : A redshift distribution function is provided by `z_source`. - `z_source` must be a one dimensional function. + * 'distribution' : A redshift distribution function is provided by `z_src`. + `z_src` must be a one dimensional function. - * 'beta' : The averaged lensing efficiency is provided by `z_source`. - `z_source` must be a tuple containing + * 'beta' : The averaged lensing efficiency is provided by `z_src`. + `z_src` must be a tuple containing ( :math:`\langle \beta_s \rangle, \langle \beta_s^2 \rangle`), the lensing efficiency and square of the lensing efficiency averaged over the galaxy redshift distribution repectively. @@ -1058,7 +1058,7 @@ def compute_magnification( * None (default): Requires `z_src_info` to be 'discrete' or 'distribution'. If `z_src_info='discrete'`, full computation is made for each - `r_proj, z_source` pair individually. If `z_src_info='distribution'`, magnification + `r_proj, z_src` pair individually. If `z_src_info='distribution'`, magnification at each value of `r_proj` is calculated as .. math:: @@ -1125,7 +1125,7 @@ def compute_magnification( magnification = _modeling_object.eval_magnification( r_proj, z_cluster, - z_source, + z_src, z_src_info=z_src_info, approx=approx, beta_kwargs=beta_kwargs, @@ -1142,7 +1142,7 @@ def compute_magnification_bias( mdelta, cdelta, z_cluster, - z_source, + z_src, cosmo, delta_mdef=200, halo_profile_model="nfw", @@ -1185,7 +1185,7 @@ def compute_magnification_bias( Galaxy cluster NFW concentration. z_cluster : float Galaxy cluster redshift - z_source : array_like, float, function + z_src : array_like, float, function Information on the background source galaxy redshift(s). Value required depends on `z_src_info` (see below). cosmo : clmm.cosmology.Cosmology object @@ -1212,18 +1212,18 @@ def compute_magnification_bias( * 'virial' z_src_info : str, optional - Type of redshift information provided by the `z_source` argument. + Type of redshift information provided by the `z_src` argument. The following supported options are: - * 'discrete' (default) : The redshift of sources is provided by `z_source`. - It can be individual redshifts for each source galaxy when `z_source` is an array - or all sources are at the same redshift when `z_source` is a float. + * 'discrete' (default) : The redshift of sources is provided by `z_src`. + It can be individual redshifts for each source galaxy when `z_src` is an array + or all sources are at the same redshift when `z_src` is a float. - * 'distribution' : A redshift distribution function is provided by `z_source`. - `z_source` must be a one dimensional function. + * 'distribution' : A redshift distribution function is provided by `z_src`. + `z_src` must be a one dimensional function. - * 'beta' : The averaged lensing efficiency is provided by `z_source`. - `z_source` must be a tuple containing + * 'beta' : The averaged lensing efficiency is provided by `z_src`. + `z_src` must be a tuple containing ( :math:`\langle \beta_s \rangle, \langle \beta_s^2 \rangle`), the lensing efficiency and square of the lensing efficiency averaged over the galaxy redshift distribution repectively. @@ -1241,7 +1241,7 @@ def compute_magnification_bias( * None (default): Requires `z_src_info` to be 'discrete' or 'distribution'. If `z_src_info='discrete'`, full computation is made for each - `r_proj, z_source` pair individually. If `z_src_info='distribution'`, magnification + `r_proj, z_src` pair individually. If `z_src_info='distribution'`, magnification bias at each value of `r_proj` is calculated as .. math:: @@ -1310,7 +1310,7 @@ def compute_magnification_bias( magnification_bias = _modeling_object.eval_magnification_bias( r_proj, z_cluster, - z_source, + z_src, alpha, z_src_info=z_src_info, approx=approx, diff --git a/clmm/utils/__init__.py b/clmm/utils/__init__.py index 9f8d1197c..cf15420ee 100644 --- a/clmm/utils/__init__.py +++ b/clmm/utils/__init__.py @@ -38,6 +38,7 @@ validate_argument, _validate_ra, _validate_dec, + _validate_is_deltasigma_sigma_c, ) from .units import ( diff --git a/clmm/utils/validation.py b/clmm/utils/validation.py index 29d4dffac..ed020d183 100644 --- a/clmm/utils/validation.py +++ b/clmm/utils/validation.py @@ -207,3 +207,20 @@ def _validate_dec(loc, dec_name, is_array): """ v_type = "float_array" if is_array else (float, str) validate_argument(loc, dec_name, v_type, argmin=-90, eqmin=True, argmax=90, eqmax=True) + + +def _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c): + r""" "Validate the compatibility between is_deltasigma and sigma_c arguments. + + + Parameters + ---------- + is_deltasigma: bool + If `False`, values are computed for shear, else they are computed for :math:`\Delta \Sigma`. + sigma_c : None, array_like + Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`. + """ + if is_deltasigma and sigma_c is None: + raise TypeError("sigma_c (=None) must be provided when is_deltasigma=True") + if not is_deltasigma and sigma_c is not None: + raise TypeError(f"sigma_c (={sigma_c}) must be None when is_deltasigma=False") diff --git a/examples/NumCosmo/Example1_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb b/examples/NumCosmo/Example1_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb index 2d963f0cd..1c6716138 100644 --- a/examples/NumCosmo/Example1_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb +++ b/examples/NumCosmo/Example1_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb @@ -568,21 +568,21 @@ "source": [ "class GaussGammaT(Ncm.DataGaussDiag):\n", " z_cluster = GObject.Property(type=float, flags=GObject.PARAM_READWRITE)\n", - " z_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", + " z_src = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", " r_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", "\n", - " def __init__(self, z_cluster, r_source, z_source, gt_profile, moo=None):\n", + " def __init__(self, z_cluster, r_source, z_src, gt_profile, moo=None):\n", " Ncm.DataGaussDiag.__init__(self, n_points=len(gt_profile))\n", "\n", " self.moo = moo if moo else clmm.Modeling()\n", "\n", - " assert len(gt_profile) == len(z_source)\n", + " assert len(gt_profile) == len(z_src)\n", " assert len(gt_profile) == len(r_source)\n", "\n", " self.set_size(len(gt_profile))\n", "\n", " self.props.z_cluster = z_cluster\n", - " self.props.z_source = Ncm.Vector.new_array(z_source)\n", + " self.props.z_src = Ncm.Vector.new_array(z_src)\n", " self.props.r_source = Ncm.Vector.new_array(r_source)\n", "\n", " self.y.set_array(gt_profile)\n", @@ -611,7 +611,7 @@ " self.moo.eval_reduced_tangential_shear(\n", " self.props.r_source.dup_array(),\n", " self.props.z_cluster,\n", - " self.props.z_source.dup_array(),\n", + " self.props.z_src.dup_array(),\n", " )\n", " )\n", " return\n", @@ -643,8 +643,8 @@ "moo2.set_cosmo(cosmo)\n", "moo2.set_concentration(4.0)\n", "\n", - "ggt1 = GaussGammaT(z_cluster=cluster_z, r_source=r1, z_source=z1, gt_profile=gt_profile1, moo=moo1)\n", - "ggt2 = GaussGammaT(z_cluster=cluster_z, r_source=r2, z_source=z2, gt_profile=gt_profile2, moo=moo2)\n", + "ggt1 = GaussGammaT(z_cluster=cluster_z, r_source=r1, z_src=z1, gt_profile=gt_profile1, moo=moo1)\n", + "ggt2 = GaussGammaT(z_cluster=cluster_z, r_source=r2, z_src=z2, gt_profile=gt_profile2, moo=moo2)\n", "\n", "mset1 = ggt1.moo.get_mset()\n", "mset2 = ggt2.moo.get_mset()\n", diff --git a/examples/NumCosmo/Example2_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb b/examples/NumCosmo/Example2_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb index 2e1933930..aab95262e 100644 --- a/examples/NumCosmo/Example2_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb +++ b/examples/NumCosmo/Example2_Fit_Halo_Mass_to_Shear_Catalog_NC.ipynb @@ -444,7 +444,7 @@ "source": [ "class GaussGammaTErr(Ncm.DataGaussDiag):\n", " z_cluster = GObject.Property(type=float, flags=GObject.PARAM_READWRITE)\n", - " z_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", + " z_src = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", " r_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", " z_err = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", "\n", @@ -452,20 +452,18 @@ " Ncm.DataGaussDiag.__init__(self, n_points=0)\n", " self.moo = clmm.Modeling()\n", "\n", - " def init_from_data(\n", - " self, z_cluster, r_source, z_source, gt_profile, gt_err, z_err=None, moo=None\n", - " ):\n", + " def init_from_data(self, z_cluster, r_source, z_src, gt_profile, gt_err, z_err=None, moo=None):\n", " if moo:\n", " self.moo = moo\n", "\n", - " assert len(gt_profile) == len(z_source)\n", + " assert len(gt_profile) == len(z_src)\n", " assert len(gt_profile) == len(r_source)\n", " assert len(gt_profile) == len(gt_err)\n", "\n", " self.set_size(len(gt_profile))\n", "\n", " self.props.z_cluster = z_cluster\n", - " self.props.z_source = Ncm.Vector.new_array(z_source)\n", + " self.props.z_src = Ncm.Vector.new_array(z_src)\n", " self.props.r_source = Ncm.Vector.new_array(r_source)\n", " if z_err:\n", " self.props.r_source = Ncm.Vector.new_array(z_err)\n", @@ -496,7 +494,7 @@ " self.moo.eval_reduced_tangential_shear(\n", " self.props.r_source.dup_array(),\n", " self.props.z_cluster,\n", - " self.props.z_source.dup_array(),\n", + " self.props.z_src.dup_array(),\n", " )\n", " )\n", " return\n", @@ -536,7 +534,7 @@ "ggt1.init_from_data(\n", " z_cluster=cluster_z,\n", " r_source=profile1[\"radius\"],\n", - " z_source=profile1[\"z\"],\n", + " z_src=profile1[\"z\"],\n", " gt_profile=profile1[\"gt\"],\n", " gt_err=profile1[\"gt_err\"],\n", " moo=moo1,\n", @@ -544,7 +542,7 @@ "ggt2.init_from_data(\n", " z_cluster=cluster_z,\n", " r_source=profile2[\"radius\"],\n", - " z_source=profile2[\"z\"],\n", + " z_src=profile2[\"z\"],\n", " gt_profile=profile2[\"gt\"],\n", " gt_err=profile2[\"gt_err\"],\n", " moo=moo2,\n", @@ -552,7 +550,7 @@ "ggt3.init_from_data(\n", " z_cluster=cluster_z,\n", " r_source=profile3[\"radius\"],\n", - " z_source=profile3[\"z\"],\n", + " z_src=profile3[\"z\"],\n", " gt_profile=profile3[\"gt\"],\n", " gt_err=profile3[\"gt_err\"],\n", " moo=moo3,\n", @@ -806,7 +804,7 @@ "outputs": [], "source": [ "def create_nc_data_cluster_wl(\n", - " theta, g_t, z_source, z_cluster, cosmo, dist, sigma_z=None, sigma_g=None\n", + " theta, g_t, z_src, z_cluster, cosmo, dist, sigma_z=None, sigma_g=None\n", "):\n", " r = clmm.convert_units(theta, \"radians\", \"Mpc\", redshift=z_cluster, cosmo=cosmo)\n", " ga = Ncm.ObjArray.new()\n", @@ -819,11 +817,11 @@ "\n", " if sigma_z:\n", " gzgs = Nc.GalaxyRedshiftGauss()\n", - " z_obs = np.column_stack((z_source, (1.0 + z_source) * sigma_z))\n", + " z_obs = np.column_stack((z_src, (1.0 + z_src) * sigma_z))\n", " gzgs.set_obs(Ncm.Matrix.new_array(z_obs.flatten(), 2))\n", " else:\n", " gzgs = Nc.GalaxyRedshiftSpec()\n", - " gzgs.set_z(Ncm.Vector.new_array(z_source))\n", + " gzgs.set_z(Ncm.Vector.new_array(z_src))\n", "\n", " gwl = Nc.GalaxyWL(wl_dist=grsg, gz_dist=gzgs)\n", " ga.add(gwl)\n", diff --git a/examples/NumCosmo/modeling_cmp_numcosmo.ipynb b/examples/NumCosmo/modeling_cmp_numcosmo.ipynb index d7a2b5e3e..1e2accb3c 100644 --- a/examples/NumCosmo/modeling_cmp_numcosmo.ipynb +++ b/examples/NumCosmo/modeling_cmp_numcosmo.ipynb @@ -121,7 +121,7 @@ "cluster_concentration = 4.0\n", "z_max = 3.0\n", "z_cluster = 1.0\n", - "z_source = 2.0" + "z_src = 2.0" ] }, { @@ -446,8 +446,8 @@ } ], "source": [ - "Sigmac = pp.compute_critical_surface_density(cosmo_ccl, z_cluster=z_cluster, z_source=z_source)\n", - "nc_Sigmac = smd.sigma_critical(cosmo, z_source, z_cluster, z_cluster)\n", + "Sigmac = pp.compute_critical_surface_density(cosmo_ccl, z_cluster=z_cluster, z_src=z_src)\n", + "nc_Sigmac = smd.sigma_critical(cosmo, z_src, z_cluster, z_cluster)\n", "\n", "print(\"% 22.15g % 22.15g %e\" % (Sigmac, nc_Sigmac, Sigmac / nc_Sigmac - 1.0))" ] @@ -484,14 +484,14 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cluster,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo_ccl,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=\"nfw\",\n", " z_src_model=\"single_plane\",\n", ")\n", "\n", - "nc_gammat = np.array([smd.shear(dp, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d])\n", + "nc_gammat = np.array([smd.shear(dp, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d])\n", "\n", "fig, axs = compare(r3d, gammat, nc_gammat, x_name=\"radius [mpc]\", y_name=r\"{\\gamma_t}\")\n", "axs[0].set_xscale(\"log\")" @@ -529,7 +529,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cluster,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo_ccl,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=\"nfw\",\n", @@ -537,7 +537,7 @@ ")\n", "\n", "nc_kappa = np.array(\n", - " [smd.convergence(dp, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.convergence(dp, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "\n", "fig, axs = compare(r3d, kappa, nc_kappa, x_name=\"radius [mpc]\", y_name=r\"\\kappa\")\n", @@ -576,14 +576,14 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cluster,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo_ccl,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=\"nfw\",\n", " z_src_model=\"single_plane\",\n", ")\n", "nc_gt = np.array(\n", - " [smd.reduced_shear(dp, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.reduced_shear(dp, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "\n", "fig, axs = compare(r3d, gt, nc_gt, x_name=\"radius [mpc]\", y_name=r\"{g_t}\")\n", @@ -598,7 +598,7 @@ "outputs": [], "source": [ "nc_mu = np.array(\n", - " [smd.magnification(dp, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.magnification(dp, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")" ] }, @@ -639,15 +639,15 @@ "source": [ "config_dict = {\n", " \"dl\": dist.angular_diameter(cosmo, z_cluster) * cosmo.RH_Mpc(),\n", - " \"z_source\": z_source,\n", + " \"z_src\": z_src,\n", " \"cluster_mass\": cluster_mass,\n", " \"G[m3/km.s2]\": Ncm.C.G(),\n", " \"aexp_cluster\": 1.0 / (1.0 + z_cluster),\n", " \"density_profile_parametrization\": density_profile_parametrization,\n", - " \"ds\": dist.angular_diameter(cosmo, z_source) * cosmo.RH_Mpc(),\n", + " \"ds\": dist.angular_diameter(cosmo, z_src) * cosmo.RH_Mpc(),\n", " \"cosmo_Ob0\": cosmo_ccl[\"Omega_b0\"],\n", - " \"aexp_source\": 1.0 / (1.0 + z_source),\n", - " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_source) * cosmo.RH_Mpc(),\n", + " \"aexp_source\": 1.0 / (1.0 + z_src),\n", + " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_src) * cosmo.RH_Mpc(),\n", " \"z_cluster\": z_cluster,\n", " \"mass_Delta\": mass_Delta,\n", " \"lightspeed[km/s]\": Ncm.C.c() / 1000.0,\n", diff --git a/examples/Paper_v1.0/gt_and_use_case.ipynb b/examples/Paper_v1.0/gt_and_use_case.ipynb index 31c94f3ea..ddd60862b 100644 --- a/examples/Paper_v1.0/gt_and_use_case.ipynb +++ b/examples/Paper_v1.0/gt_and_use_case.ipynb @@ -325,7 +325,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=np.mean(cluster.galcat[\"z\"]), # Mean value of source galaxies redshift\n", + " z_src=np.mean(cluster.galcat[\"z\"]), # Mean value of source galaxies redshift\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -369,7 +369,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=z_inf, # Redshift value at infinity\n", + " z_src=z_inf, # Redshift value at infinity\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -379,7 +379,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=z_inf, # Redshift value at infinity\n", + " z_src=z_inf, # Redshift value at infinity\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -421,7 +421,7 @@ " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", " # Redshift value of each source galaxy inside the radial bin\n", - " z_source=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", + " z_src=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", diff --git a/examples/Paper_v1.0/mcmc.ipynb b/examples/Paper_v1.0/mcmc.ipynb index d2c65d157..caa0393ca 100644 --- a/examples/Paper_v1.0/mcmc.ipynb +++ b/examples/Paper_v1.0/mcmc.ipynb @@ -442,7 +442,7 @@ "source": [ "class GaussGammaTErr(Ncm.DataGaussDiag):\n", " z_cluster = GObject.Property(type=float, flags=GObject.PARAM_READWRITE)\n", - " z_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", + " z_src = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", " r_source = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", " z_err = GObject.Property(type=Ncm.Vector, flags=GObject.PARAM_READWRITE)\n", "\n", @@ -450,20 +450,18 @@ " Ncm.DataGaussDiag.__init__(self, n_points=0)\n", " self.moo = clmm.Modeling()\n", "\n", - " def init_from_data(\n", - " self, z_cluster, r_source, z_source, gt_profile, gt_err, z_err=None, moo=None\n", - " ):\n", + " def init_from_data(self, z_cluster, r_source, z_src, gt_profile, gt_err, z_err=None, moo=None):\n", " if moo:\n", " self.moo = moo\n", "\n", - " assert len(gt_profile) == len(z_source)\n", + " assert len(gt_profile) == len(z_src)\n", " assert len(gt_profile) == len(r_source)\n", " assert len(gt_profile) == len(gt_err)\n", "\n", " self.set_size(len(gt_profile))\n", "\n", " self.props.z_cluster = z_cluster\n", - " self.props.z_source = Ncm.Vector.new_array(z_source)\n", + " self.props.z_src = Ncm.Vector.new_array(z_src)\n", " self.props.r_source = Ncm.Vector.new_array(r_source)\n", " if z_err:\n", " self.props.r_source = Ncm.Vector.new_array(z_err)\n", @@ -494,7 +492,7 @@ " self.moo.eval_reduced_tangential_shear(\n", " self.props.r_source.dup_array(),\n", " self.props.z_cluster,\n", - " self.props.z_source.dup_array(),\n", + " self.props.z_src.dup_array(),\n", " )\n", " )\n", " return\n", @@ -526,7 +524,7 @@ "ggt.init_from_data(\n", " z_cluster=cluster_z,\n", " r_source=cl.profile[\"radius\"],\n", - " z_source=cl.profile[\"z\"],\n", + " z_src=cl.profile[\"z\"],\n", " gt_profile=cl.profile[\"gt\"],\n", " gt_err=cl.profile[\"gt_err\"],\n", " moo=moo,\n", @@ -882,7 +880,7 @@ "outputs": [], "source": [ "def create_nc_data_cluster_wl(\n", - " theta, g_t, z_source, z_cluster, cosmo, dist, sigma_z=None, sigma_g=None\n", + " theta, g_t, z_src, z_cluster, cosmo, dist, sigma_z=None, sigma_g=None\n", "):\n", " r = clmm.convert_units(theta, \"radians\", \"Mpc\", redshift=z_cluster, cosmo=cosmo)\n", " ga = Ncm.ObjArray.new()\n", @@ -895,11 +893,11 @@ "\n", " if sigma_z:\n", " gzgs = Nc.GalaxyRedshiftGauss()\n", - " z_obs = np.column_stack((z_source, (1.0 + z_source) * sigma_z))\n", + " z_obs = np.column_stack((z_src, (1.0 + z_src) * sigma_z))\n", " gzgs.set_obs(Ncm.Matrix.new_array(z_obs.flatten(), 2))\n", " else:\n", " gzgs = Nc.GalaxyRedshiftSpec()\n", - " gzgs.set_z(Ncm.Vector.new_array(z_source))\n", + " gzgs.set_z(Ncm.Vector.new_array(z_src))\n", "\n", " gwl = Nc.GalaxyWL(wl_dist=grsg, gz_dist=gzgs)\n", " ga.add(gwl)\n", diff --git a/examples/demo_compute_deltasigma_weights.ipynb b/examples/demo_compute_deltasigma_weights.ipynb index 2ebdaeb7c..d261446b4 100644 --- a/examples/demo_compute_deltasigma_weights.ipynb +++ b/examples/demo_compute_deltasigma_weights.ipynb @@ -55,6 +55,7 @@ "from clmm import GalaxyCluster\n", "from clmm.dataops import compute_galaxy_weights, compute_background_probability\n", "from clmm.support import mock_data as mock\n", + "from clmm.theory import compute_critical_surface_density_eff\n", "\n", "clmm.__version__" ] @@ -122,20 +123,7 @@ "z_gal = noisy_data_z[\"ztrue\"]\n", "# add redshift dependency on shape measurement error\n", "noisy_data_z[\"e_err\"] = noisy_data_z[\"e_err\"] * (1 + 0.4 * noisy_data_z[\"ztrue\"])\n", - "cl0 = GalaxyCluster(\"mock_cluster\", cluster_ra, cluster_dec, cluster_z, noisy_data_z)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "71a6f518-f910-4d5e-b5a5-7c9d82366b86", - "metadata": {}, - "outputs": [], - "source": [ - "args = (\"mock_cluster\", cluster_ra, cluster_dec, cluster_z, noisy_data_z)\n", - "cl1 = GalaxyCluster(*args)\n", - "cl2 = GalaxyCluster(*args)\n", - "cl3 = GalaxyCluster(*args)" + "cluster = GalaxyCluster(\"mock_cluster\", cluster_ra, cluster_dec, cluster_z, noisy_data_z)" ] }, { @@ -163,9 +151,19 @@ "id": "747e99bf", "metadata": {}, "source": [ - "#### using the functional interface\n", + "#### Using the functional interface\n", "\n", - "Here, we use the true source redshifts stored in `z_gal`" + "First, we need to compute $\\Sigma_{\\rm crit}$. Here, we use the true source redshifts stored in `z_gal`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3432e008", + "metadata": {}, + "outputs": [], + "source": [ + "sigma_c = cosmo.eval_sigma_crit(cluster_z, z_gal)" ] }, { @@ -176,18 +174,9 @@ "outputs": [], "source": [ "w_ls_true = compute_galaxy_weights(\n", - " cluster_z,\n", - " cosmo,\n", - " z_source=z_gal,\n", - " shape_component1=noisy_data_z[\"e1\"],\n", - " shape_component2=noisy_data_z[\"e2\"],\n", - " shape_component1_err=noisy_data_z[\"e_err\"],\n", - " shape_component2_err=noisy_data_z[\"e_err\"],\n", - " use_pdz=False,\n", - " pzpdf=None,\n", - " pzbins=None,\n", - " use_shape_noise=False,\n", + " sigma_c=sigma_c,\n", " is_deltasigma=True,\n", + " use_shape_noise=False,\n", ")" ] }, @@ -196,7 +185,7 @@ "id": "206a9562", "metadata": {}, "source": [ - "#### or as a method of the `GalaxyCluster` object\n", + "#### As a method of the `GalaxyCluster` object\n", "As a method of the `GalaxyCluster` object, `compute_galaxy_weights` uses the content of the `z` column of the object's `galcat` table as the source redshift point estimates. Given that mock data was generated with a photoz error, this point estimate is different from the true redshift used in the cell above." ] }, @@ -207,7 +196,7 @@ "metadata": {}, "outputs": [], "source": [ - "w_ls_point = cl0.compute_galaxy_weights(\n", + "w_ls_point = cluster.compute_galaxy_weights(\n", " use_pdz=False, weight_name=\"w_ls_point\", cosmo=cosmo, is_deltasigma=True, add=True\n", ")" ] @@ -225,16 +214,65 @@ "id": "5f288e2c-32cc-4f35-8744-c66c073b3024", "metadata": {}, "source": [ + "When considering the photo-z distribution, we can compute the weight based on an effective critical surface density:\n", + "\n", + "$$\n", + "w_{\\rm ls} = \\Sigma_{\\rm crit}^{\\rm eff}(z_l)^{-2},\n", "$$\n", - "w_{\\rm ls} = \\left(\\int_{z_l}^{+\\infty}\\Sigma_{\\rm crit}(z_l, z)^{-1}p(z) dz\\right)^2\n", + "\n", + "where\n", + "\n", + "$$\n", + "\\Sigma_{\\rm crit}^{\\rm eff}(z_l) = \\left(\\int_{z_l}^{+\\infty}\\Sigma_{\\rm crit}(z_l, z)^{-1}p(z) dz\\right)^{-1}.\n", "$$" ] }, + { + "cell_type": "markdown", + "id": "6355d76b", + "metadata": {}, + "source": [ + "#### Using the functional interface\n", + "\n", + "First, we need to compute $\\Sigma_{\\rm crit}^{\\rm eff}$. Here, we use the true source redshifts stored in `z_gal`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0dbbfa25", + "metadata": {}, + "outputs": [], + "source": [ + "sigma_c_eff = compute_critical_surface_density_eff(\n", + " cosmo=cosmo,\n", + " z_cluster=cluster_z,\n", + " pzbins=noisy_data_z.pzpdf_info[\"zbins\"],\n", + " pzpdf=noisy_data_z[\"pzpdf\"],\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aee36658", + "metadata": {}, + "outputs": [], + "source": [ + "w_ls_photoz = compute_galaxy_weights(\n", + " sigma_c=sigma_c_eff,\n", + " is_deltasigma=True,\n", + " use_shape_noise=False,\n", + ")" + ] + }, { "cell_type": "markdown", "id": "5285a1a7-e990-4d83-a418-15e04d80a948", "metadata": {}, "source": [ + "#### As a method of the `GalaxyCluster` object\n", + "\n", "When used as a method of the `GalaxyCluster` object, with `use_pdz=True`, `compute_galaxy_weights` uses the content of the `pzpdf` and `pzbins` columns of the `galcat` table. It will return an error if those do not exist." ] }, @@ -245,7 +283,7 @@ "metadata": {}, "outputs": [], "source": [ - "w_ls_photoz = cl1.compute_galaxy_weights(\n", + "w_ls_photoz = cluster.compute_galaxy_weights(\n", " use_pdz=True, weight_name=\"w_ls_photoz\", cosmo=cosmo, is_deltasigma=True, add=True\n", ")" ] @@ -275,7 +313,7 @@ "metadata": {}, "outputs": [], "source": [ - "w_ls_shape = cl2.compute_galaxy_weights(\n", + "w_ls_shape = cluster.compute_galaxy_weights(\n", " use_pdz=False,\n", " use_shape_noise=True,\n", " shape_component1=\"e1\",\n", @@ -304,7 +342,7 @@ "metadata": {}, "source": [ "$$\n", - "w_{\\rm ls} = \\frac{\\left(\\int_{z_l}^{+\\infty}\\Sigma_{\\rm crit}(z_l, z)^{-1}p(z) dz\\right)^2}{\\sigma_{\\rm shapenoise}^2 + \\sigma^2_{\\rm shape\\ error}}\n", + "w_{\\rm ls} = \\frac{\\Sigma_{\\rm crit}^{\\rm eff}(z_l, z)^{-2}}{\\sigma_{\\rm shapenoise}^2 + \\sigma^2_{\\rm shape\\ error}}\n", "$$" ] }, @@ -315,7 +353,7 @@ "metadata": {}, "outputs": [], "source": [ - "w_ls_photoz_shape = cl3.compute_galaxy_weights(\n", + "w_ls_photoz_shape = cluster.compute_galaxy_weights(\n", " use_pdz=True,\n", " use_shape_noise=True,\n", " shape_component1=\"e1\",\n", @@ -345,7 +383,7 @@ "metadata": {}, "outputs": [], "source": [ - "cl0.galcat.colnames" + "cluster.galcat.colnames" ] }, { @@ -355,15 +393,15 @@ "tags": [] }, "source": [ - "### $\\Sigma_c$ metadata\n", + "### $\\Sigma_{\\rm crit}$ metadata\n", "\n", - "As seen above, the weights are computed either using the standard definition of $\\Sigma_c^{\\rm std}$, using point estimate redshift, or the effective definition based on the inverse $\\Sigma_c^{\\rm eff}$ averaged over the redshift PDF $p(z)$:\n", + "As seen above, the weights are computed either using the standard definition of $\\Sigma_{\\rm crit}^{\\rm std}$, using point estimate redshift, or the effective definition based on the inverse $\\Sigma_c^{\\rm eff}$ averaged over the redshift PDF $p(z)$:\n", "\n", "$$ \n", - "\\Sigma_c^{\\rm std}\\equiv\\Sigma_{\\rm crit}(z_l, z_s) \\;\\;{\\rm and}\\;\\; \\Sigma_c^{\\rm eff}\\equiv\\left( \\int \\Sigma_{\\rm crit}(z_l, z)^{-1} p(z) dz\\right)^{-1}\n", + "\\Sigma_{\\rm crit}^{\\rm std}\\equiv\\Sigma_{\\rm crit}(z_l, z_s) \\;\\;{\\rm and}\\;\\; \\Sigma_{\\rm crit}^{\\rm eff}\\equiv\\left( \\int \\Sigma_{\\rm crit}(z_l, z)^{-1} p(z) dz\\right)^{-1}\n", "$$\n", "\n", - "To keep track of what definition of $\\Sigma_c$ was used, `standard` or `effective` the user may look into the `galcat` metadata " + "To keep track of what definition of $\\Sigma_{\\rm crit}$ was used, `standard` or `effective` the user may look into the `galcat` metadata " ] }, { @@ -373,8 +411,22 @@ "metadata": {}, "outputs": [], "source": [ - "print(f\"For cluster 0: {cl0.galcat.meta['sigmac_type']}\")\n", - "print(f\"For cluster 1: {cl1.galcat.meta['sigmac_type']}\")" + "print(\n", + " \"For cluster w_ls_point column :\",\n", + " cluster.galcat.meta[\"w_ls_point_sigmac_type\"],\n", + ")\n", + "print(\n", + " \"For cluster w_ls_photoz column :\",\n", + " cluster.galcat.meta[\"w_ls_photoz_sigmac_type\"],\n", + ")\n", + "print(\n", + " \"For cluster w_ls_shape column :\",\n", + " cluster.galcat.meta[\"w_ls_shape_sigmac_type\"],\n", + ")\n", + "print(\n", + " \"For cluster w_ls_photoz_shape column :\",\n", + " cluster.galcat.meta[\"w_ls_photoz_shape_sigmac_type\"],\n", + ")" ] }, { @@ -405,30 +457,30 @@ "\n", "ax[0].scatter(\n", " z_gal,\n", - " 1e3 * cl0.galcat[\"w_ls_point\"] / np.sum(cl0.galcat[\"w_ls_point\"]),\n", + " 1e3 * cluster.galcat[\"w_ls_point\"] / cluster.galcat[\"w_ls_point\"].sum(),\n", " c=\"r\",\n", " label=\"point estimate z\",\n", " s=5,\n", ")\n", "ax[0].scatter(\n", " z_gal,\n", - " 1e3 * cl1.galcat[\"w_ls_photoz\"] / np.sum(cl1.galcat[\"w_ls_photoz\"]),\n", + " 1e3 * cluster.galcat[\"w_ls_photoz\"] / cluster.galcat[\"w_ls_photoz\"].sum(),\n", " c=\"orange\",\n", " label=\"photoz pdf\",\n", " marker=\"+\",\n", " s=5,\n", ")\n", - "ax[0].scatter(z_gal, 1e3 * w_ls_true / np.sum(w_ls_true), c=\"g\", label=\"true z\", marker=\"x\", s=5)\n", + "ax[0].scatter(z_gal, 1e3 * w_ls_true / w_ls_true.sum(), c=\"g\", label=\"true z\", marker=\"x\", s=5)\n", "ax[1].scatter(\n", " z_gal,\n", - " 1e3 * cl2.galcat[\"w_ls_shape\"] / np.sum(cl2.galcat[\"w_ls_shape\"]),\n", + " 1e3 * cluster.galcat[\"w_ls_shape\"] / cluster.galcat[\"w_ls_shape\"].sum(),\n", " c=\"blue\",\n", " label=r\"shape_error, point z\",\n", " s=5,\n", ")\n", "ax[1].scatter(\n", " z_gal,\n", - " 1e3 * cl3.galcat[\"w_ls_photoz_shape\"] / np.sum(cl3.galcat[\"w_ls_photoz_shape\"]),\n", + " 1e3 * cluster.galcat[\"w_ls_photoz_shape\"] / cluster.galcat[\"w_ls_photoz_shape\"].sum(),\n", " c=\"cyan\",\n", " label=\"shape_error + photoz pdf\",\n", " s=5,\n", @@ -500,7 +552,7 @@ " field_size=10.0,\n", " ngals=3000,\n", ")\n", - "cl0_new = clmm.GalaxyCluster(\"mock_cluster\", 0, 0, cluster_z, noisy_data_z_2)" + "cluster_new = clmm.GalaxyCluster(\"mock_cluster\", 0, 0, cluster_z, noisy_data_z_2)" ] }, { @@ -520,7 +572,7 @@ "metadata": {}, "outputs": [], "source": [ - "p_background_photoz_1 = cl0.compute_background_probability(\n", + "p_background_photoz_1 = cluster.compute_background_probability(\n", " use_pdz=True, p_background_name=\"p_background_photoz_1\", add=True\n", ")" ] @@ -532,7 +584,7 @@ "metadata": {}, "outputs": [], "source": [ - "p_background_photoz_2 = cl0_new.compute_background_probability(\n", + "p_background_photoz_2 = cluster_new.compute_background_probability(\n", " use_pdz=True, p_background_name=\"p_background_photoz_2\", add=True\n", ")" ] @@ -549,7 +601,7 @@ "\n", "plt.tick_params(axis=\"both\", which=\"major\", labelsize=10)\n", "plt.scatter(\n", - " cl0_new.galcat[\"ztrue\"],\n", + " cluster_new.galcat[\"ztrue\"],\n", " p_background_photoz_2,\n", " c=\"darkorange\",\n", " label=r\"$\\sigma_z = 0.02$\",\n", @@ -558,7 +610,7 @@ " alpha=0.5,\n", ")\n", "plt.scatter(\n", - " cl0.galcat[\"ztrue\"],\n", + " cluster.galcat[\"ztrue\"],\n", " p_background_photoz_1,\n", " c=\"blue\",\n", " label=r\"$\\sigma_z = 0.05$\",\n", @@ -574,12 +626,12 @@ "\n", "plt.xlabel(\"true source redshift\", fontsize=15)\n", "plt.ylabel(r\"$P(z_s > z_l)$\", fontsize=15)\n", - "plt.legend(frameon=True, fontsize=15)\n", + "plt.legend(frameon=True, fontsize=15, loc=4)\n", "\n", "\n", "ax2 = fig.add_axes([0.155, 0.65, 0.17, 0.18])\n", "ax2.scatter(\n", - " cl0_new.galcat[\"z\"],\n", + " cluster_new.galcat[\"z\"],\n", " p_background_photoz_2,\n", " c=\"darkorange\",\n", " label=r\"$\\sigma_z = 0.02$\",\n", @@ -589,7 +641,7 @@ " lw=0.1,\n", ")\n", "ax2.scatter(\n", - " cl0.galcat[\"z\"],\n", + " cluster.galcat[\"z\"],\n", " p_background_photoz_1,\n", " c=\"blue\",\n", " label=r\"$\\sigma_z = 0.05$\",\n", diff --git a/examples/demo_theory_functionality.ipynb b/examples/demo_theory_functionality.ipynb index 5bb640cce..31d720432 100644 --- a/examples/demo_theory_functionality.ipynb +++ b/examples/demo_theory_functionality.ipynb @@ -110,7 +110,7 @@ "z_cl = 1.0\n", "\n", "# source properties\n", - "z_source = 2.0 # all sources in the same plan\n", + "z_src = 2.0 # all sources in the same plan\n", "z_distrib_func = clmm.redshift.distributions.chang2013 # sources redshift following a distribution\n", "alpha = [2, -0.5]" ] @@ -187,7 +187,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", @@ -206,7 +206,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", @@ -225,7 +225,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", @@ -244,7 +244,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", @@ -264,7 +264,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_source,\n", + " z_src=z_src,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", @@ -290,7 +290,7 @@ " mdelta=cluster_mass,\n", " cdelta=cluster_concentration,\n", " z_cluster=z_cl,\n", - " z_source=z_distrib_func,\n", + " z_src=z_distrib_func,\n", " cosmo=cosmo,\n", " delta_mdef=mass_Delta,\n", " halo_profile_model=density_profile_parametrization,\n", diff --git a/examples/demo_theory_functionality_oo.ipynb b/examples/demo_theory_functionality_oo.ipynb index 3e8083c3a..2274307df 100644 --- a/examples/demo_theory_functionality_oo.ipynb +++ b/examples/demo_theory_functionality_oo.ipynb @@ -105,7 +105,7 @@ "z_cl = 1.0\n", "\n", "# source properties\n", - "z_source = 2.0 # all sources in the same plane\n", + "z_src = 2.0 # all sources in the same plane\n", "z_distrib_func = clmm.redshift.distributions.chang2013 # sources redshift following a distribution\n", "alpha = [2, -0.5]" ] @@ -127,17 +127,17 @@ "rho = moo.eval_3d_density(r3d, z_cl)\n", "Sigma = moo.eval_surface_density(r3d, z_cl)\n", "DeltaSigma = moo.eval_excess_surface_density(r3d, z_cl)\n", - "gammat = moo.eval_tangential_shear(r3d, z_cl, z_source)\n", - "kappa = moo.eval_convergence(r3d, z_cl, z_source)\n", + "gammat = moo.eval_tangential_shear(r3d, z_cl, z_src)\n", + "kappa = moo.eval_convergence(r3d, z_cl, z_src)\n", "\n", - "gt = moo.eval_reduced_tangential_shear(r3d, z_cl, z_source)\n", + "gt = moo.eval_reduced_tangential_shear(r3d, z_cl, z_src)\n", "# Lensing quantities assuming sources follow a given redshift distribution.\n", "gt_z = moo.eval_reduced_tangential_shear(\n", " r3d, z_cl, z_distrib_func, z_src_info=\"distribution\", approx=\"order2\"\n", ")\n", "\n", - "mu = moo.eval_magnification(r3d, z_cl, z_source)\n", - "mu_bias = moo.eval_magnification_bias(r3d, z_cl, z_source, alpha)" + "mu = moo.eval_magnification(r3d, z_cl, z_src)\n", + "mu_bias = moo.eval_magnification_bias(r3d, z_cl, z_src, alpha)" ] }, { diff --git a/examples/mass_fitting/Example3_Fit_Halo_Mass_to_Shear_Catalog.ipynb b/examples/mass_fitting/Example3_Fit_Halo_Mass_to_Shear_Catalog.ipynb index e3efcfc9b..0cbce9bb9 100644 --- a/examples/mass_fitting/Example3_Fit_Halo_Mass_to_Shear_Catalog.ipynb +++ b/examples/mass_fitting/Example3_Fit_Halo_Mass_to_Shear_Catalog.ipynb @@ -452,7 +452,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=clmm.redshift.distributions.chang2013, # We provide the redshift distribution (default: Chang et al. 2013) for calculating the beta_s statistics\n", + " z_src=clmm.redshift.distributions.chang2013, # We provide the redshift distribution (default: Chang et al. 2013) for calculating the beta_s statistics\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " # massdef='critical',\n", @@ -473,7 +473,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=clmm.redshift.distributions.chang2013, # We provide the redshift distribution (default: Chang et al. 2013) for calculating the beta_s statistics\n", + " z_src=clmm.redshift.distributions.chang2013, # We provide the redshift distribution (default: Chang et al. 2013) for calculating the beta_s statistics\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " # massdef='critical',\n", diff --git a/examples/mass_fitting/Example4_Fit_Halo_mass_to_HSC_data.ipynb b/examples/mass_fitting/Example4_Fit_Halo_mass_to_HSC_data.ipynb index 45a76d5ec..0c423d25b 100644 --- a/examples/mass_fitting/Example4_Fit_Halo_mass_to_HSC_data.ipynb +++ b/examples/mass_fitting/Example4_Fit_Halo_mass_to_HSC_data.ipynb @@ -476,7 +476,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n", + " z_src=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n", " z_src_info=\"beta\",\n", " approx=\"order1\",\n", " cosmo=cosmo,\n", @@ -504,7 +504,7 @@ " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", " # Redshift value of each source galaxy inside the radial bin\n", - " z_source=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", + " z_src=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " massdef=\"critical\",\n", diff --git a/examples/mass_fitting/Example5_Fit_Halo_mass_to_DES_data.ipynb b/examples/mass_fitting/Example5_Fit_Halo_mass_to_DES_data.ipynb index a1439d1f7..3e24d6f69 100644 --- a/examples/mass_fitting/Example5_Fit_Halo_mass_to_DES_data.ipynb +++ b/examples/mass_fitting/Example5_Fit_Halo_mass_to_DES_data.ipynb @@ -404,7 +404,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n", + " z_src=(bs_mean, bs2_mean), # tuple of (bs_mean, bs2_mean)\n", " z_src_info=\"beta\",\n", " approx=\"order1\",\n", " cosmo=cosmo,\n", @@ -432,7 +432,7 @@ " cdelta=concentration, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", " # Redshift value of each source galaxy inside the radial bin\n", - " z_source=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", + " z_src=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " massdef=\"critical\",\n", diff --git a/examples/other_flat_sky_limitations.ipynb b/examples/other_flat_sky_limitations.ipynb index 75a9b2ea6..4447c592b 100644 --- a/examples/other_flat_sky_limitations.ipynb +++ b/examples/other_flat_sky_limitations.ipynb @@ -371,7 +371,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=np.mean(cluster.galcat[\"z\"]), # Mean value of source galaxies redshift\n", + " z_src=np.mean(cluster.galcat[\"z\"]), # Mean value of source galaxies redshift\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -415,7 +415,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=z_inf, # Redshift value at infinity\n", + " z_src=z_inf, # Redshift value at infinity\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -425,7 +425,7 @@ " mdelta=10**logm, # Mass of the cluster [M_sun]\n", " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", - " z_source=z_inf, # Redshift value at infinity\n", + " z_src=z_inf, # Redshift value at infinity\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", @@ -467,7 +467,7 @@ " cdelta=4, # Concentration of the cluster\n", " z_cluster=cluster_z, # Redshift of the cluster\n", " # Redshift value of each source galaxy inside the radial bin\n", - " z_source=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", + " z_src=cluster.galcat[radial_bin[\"gal_id\"]][\"z\"],\n", " cosmo=cosmo,\n", " delta_mdef=200,\n", " halo_profile_model=\"nfw\",\n", diff --git a/tests/data/numcosmo/config.json b/tests/data/numcosmo/config.json index c81716df1..c38ce5e87 100644 --- a/tests/data/numcosmo/config.json +++ b/tests/data/numcosmo/config.json @@ -1 +1 @@ -{"dl": 1696.50282336234, "z_source": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "nfw", "ds": 1767.4306833378118, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962517, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435031.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} \ No newline at end of file +{"dl": 1696.50282336234, "z_src": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "nfw", "ds": 1767.4306833378118, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962517, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435031.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} diff --git a/tests/data/numcosmo/config_einasto_benchmarks.json b/tests/data/numcosmo/config_einasto_benchmarks.json index 0d6f949fb..dd201b9aa 100644 --- a/tests/data/numcosmo/config_einasto_benchmarks.json +++ b/tests/data/numcosmo/config_einasto_benchmarks.json @@ -1 +1 @@ -{"dl": 1696.502823362356, "z_source": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "einasto", "ds": 1767.4306833377823, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962118, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435132.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16, "alpha_einasto": 0.3683247081598754} \ No newline at end of file +{"dl": 1696.502823362356, "z_src": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "einasto", "ds": 1767.4306833377823, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962118, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435132.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16, "alpha_einasto": 0.3683247081598754} diff --git a/tests/data/numcosmo/config_hernquist_benchmarks.json b/tests/data/numcosmo/config_hernquist_benchmarks.json index bc425840c..59eb97c68 100644 --- a/tests/data/numcosmo/config_hernquist_benchmarks.json +++ b/tests/data/numcosmo/config_hernquist_benchmarks.json @@ -1 +1 @@ -{"dl": 1696.502823362356, "z_source": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "hernquist", "ds": 1767.4306833377823, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962118, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435132.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} \ No newline at end of file +{"dl": 1696.502823362356, "z_src": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "aexp_cluster": 0.5, "density_profile_parametrization": "hernquist", "ds": 1767.4306833377823, "cosmo_Ob0": 0.049, "aexp_source": 0.3333333333333333, "dsl": 636.4288010962118, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 67.66, "cluster_concentration": 4.0, "cosmo_Om0": 0.31240715689016263, "cosmo_Odm0": 0.262, "nc_Sigmac": 2722127302435132.5, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} diff --git a/tests/data/numcosmo/config_old_units.json b/tests/data/numcosmo/config_old_units.json index 42ae6f974..b483a268d 100644 --- a/tests/data/numcosmo/config_old_units.json +++ b/tests/data/numcosmo/config_old_units.json @@ -1 +1 @@ -{"dl": 1177679548.8532429, "z_source": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "nc_cor_factor": 1.0, "aexp_cluster": 0.5, "density_profile_parametrization": "nfw", "ds": 1241373844.9905102, "cosmo_Ob0": 0.045, "aexp_source": 0.3333333333333333, "dsl": 456254145.7550621, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 70.0, "cluster_concentration": 4.0, "cosmo_Om0": 0.27, "nc_Sigmac": 3841.8383445955924, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} \ No newline at end of file +{"dl": 1177679548.8532429, "z_src": 2.0, "cluster_mass": 1000000000000000.0, "G[m3/km.s2]": 6.6743e-11, "nc_cor_factor": 1.0, "aexp_cluster": 0.5, "density_profile_parametrization": "nfw", "ds": 1241373844.9905102, "cosmo_Ob0": 0.045, "aexp_source": 0.3333333333333333, "dsl": 456254145.7550621, "z_cluster": 1.0, "mass_Delta": 200, "lightspeed[km/s]": 299792.458, "cosmo_H0": 70.0, "cluster_concentration": 4.0, "cosmo_Om0": 0.27, "nc_Sigmac": 3841.8383445955924, "Msun[kg]": 1.988409870698051e+30, "pc_to_m": 3.085677581491367e+16} diff --git a/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb b/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb index aeaf5e279..fbd7f9f4d 100644 --- a/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb +++ b/tests/data/numcosmo/generate_einasto_hernquist_benchmarks_fromNC.ipynb @@ -107,7 +107,7 @@ "cluster_concentration = 4.0\n", "z_max = 3.0\n", "z_cluster = 1.0\n", - "z_source = 2.0" + "z_src = 2.0" ] }, { @@ -487,23 +487,23 @@ "metadata": {}, "outputs": [], "source": [ - "nc_Sigmac = smd.sigma_critical(cosmo, z_source, z_cluster, z_cluster)\n", + "nc_Sigmac = smd.sigma_critical(cosmo, z_src, z_cluster, z_cluster)\n", "\n", "nc_rho_ein = np.array([nc_ein.eval_density(cosmo, r3d_i, z_cluster) for r3d_i in r3d])\n", "nc_Sigma_ein = np.array([smd.sigma(nc_ein, cosmo, r3d_i, z_cluster) for r3d_i in r3d])\n", "nc_SigmaMean_ein = np.array([smd.sigma_mean(nc_ein, cosmo, r3d_i, z_cluster) for r3d_i in r3d])\n", "nc_DeltaSigma_ein = nc_SigmaMean_ein - nc_Sigma_ein\n", "nc_gammat_ein = np.array(\n", - " [smd.shear(nc_ein, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.shear(nc_ein, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_kappa_ein = np.array(\n", - " [smd.convergence(nc_ein, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.convergence(nc_ein, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_gt_ein = np.array(\n", - " [smd.reduced_shear(nc_ein, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.reduced_shear(nc_ein, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_mu_ein = np.array(\n", - " [smd.magnification(nc_ein, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.magnification(nc_ein, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")" ] }, @@ -525,16 +525,16 @@ "nc_SigmaMean_her = np.array([smd.sigma_mean(nc_her, cosmo, r3d_i, z_cluster) for r3d_i in r3d])\n", "nc_DeltaSigma_her = nc_SigmaMean_her - nc_Sigma_her\n", "nc_gammat_her = np.array(\n", - " [smd.shear(nc_her, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.shear(nc_her, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_kappa_her = np.array(\n", - " [smd.convergence(nc_her, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.convergence(nc_her, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_gt_her = np.array(\n", - " [smd.reduced_shear(nc_her, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.reduced_shear(nc_her, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")\n", "nc_mu_her = np.array(\n", - " [smd.magnification(nc_her, cosmo, r3d_i, z_source, z_cluster, z_cluster) for r3d_i in r3d]\n", + " [smd.magnification(nc_her, cosmo, r3d_i, z_src, z_cluster, z_cluster) for r3d_i in r3d]\n", ")" ] }, @@ -601,15 +601,15 @@ "source": [ "config_dict_ein = {\n", " \"dl\": dist.angular_diameter(cosmo, z_cluster) * cosmo.RH_Mpc(),\n", - " \"z_source\": z_source,\n", + " \"z_src\": z_src,\n", " \"cluster_mass\": cluster_mass,\n", " \"G[m3/km.s2]\": Ncm.C.G(),\n", " \"aexp_cluster\": 1.0 / (1.0 + z_cluster),\n", " \"density_profile_parametrization\": \"einasto\",\n", - " \"ds\": dist.angular_diameter(cosmo, z_source) * cosmo.RH_Mpc(),\n", + " \"ds\": dist.angular_diameter(cosmo, z_src) * cosmo.RH_Mpc(),\n", " \"cosmo_Ob0\": cosmo_ccl[\"Omega_b0\"],\n", - " \"aexp_source\": 1.0 / (1.0 + z_source),\n", - " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_source) * cosmo.RH_Mpc(),\n", + " \"aexp_source\": 1.0 / (1.0 + z_src),\n", + " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_src) * cosmo.RH_Mpc(),\n", " \"z_cluster\": z_cluster,\n", " \"mass_Delta\": mass_Delta,\n", " \"lightspeed[km/s]\": Ncm.C.c() / 1000.0,\n", @@ -637,15 +637,15 @@ "source": [ "config_dict_her = {\n", " \"dl\": dist.angular_diameter(cosmo, z_cluster) * cosmo.RH_Mpc(),\n", - " \"z_source\": z_source,\n", + " \"z_src\": z_src,\n", " \"cluster_mass\": cluster_mass,\n", " \"G[m3/km.s2]\": Ncm.C.G(),\n", " \"aexp_cluster\": 1.0 / (1.0 + z_cluster),\n", " \"density_profile_parametrization\": \"hernquist\",\n", - " \"ds\": dist.angular_diameter(cosmo, z_source) * cosmo.RH_Mpc(),\n", + " \"ds\": dist.angular_diameter(cosmo, z_src) * cosmo.RH_Mpc(),\n", " \"cosmo_Ob0\": cosmo_ccl[\"Omega_b0\"],\n", - " \"aexp_source\": 1.0 / (1.0 + z_source),\n", - " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_source) * cosmo.RH_Mpc(),\n", + " \"aexp_source\": 1.0 / (1.0 + z_src),\n", + " \"dsl\": dist.angular_diameter_z1_z2(cosmo, z_cluster, z_src) * cosmo.RH_Mpc(),\n", " \"z_cluster\": z_cluster,\n", " \"mass_Delta\": mass_Delta,\n", " \"lightspeed[km/s]\": Ncm.C.c() / 1000.0,\n", diff --git a/tests/test_clusterensemble.py b/tests/test_clusterensemble.py index 7751d7bb6..63c3d3958 100644 --- a/tests/test_clusterensemble.py +++ b/tests/test_clusterensemble.py @@ -23,7 +23,7 @@ def test_cluster_ensemble(): ra_source = [120.1, 119.9] dec_source = [41.9, 42.2] theta_source = [0.0025, 0.015] - z_source = [1.0, 2.0] + z_src = [1.0, 2.0] shear1 = [0.2, 0.4] shear2 = [0.3, 0.5] w_ls = [1.0e-30, 1.0e-31] @@ -33,7 +33,7 @@ def test_cluster_ensemble(): names = ("ra", "dec", "theta", "w_ls", "e1", "e2", "z") galcat = clmm.GCData( - [ra_source, dec_source, theta_source, w_ls, shear1, shear2, z_source], names=names + [ra_source, dec_source, theta_source, w_ls, shear1, shear2, z_src], names=names ) # create cluster cluster = clmm.GalaxyCluster( diff --git a/tests/test_cosmo_parent.py b/tests/test_cosmo_parent.py index b65666e97..67de814db 100644 --- a/tests/test_cosmo_parent.py +++ b/tests/test_cosmo_parent.py @@ -269,7 +269,7 @@ def test_eval_sigma_crit(modeling_data): cosmo, testcase, _ = load_validation_config() assert_allclose( - cosmo.eval_sigma_crit(testcase["z_cluster"], testcase["z_source"]), + cosmo.eval_sigma_crit(testcase["z_cluster"], testcase["z_src"]), testcase["nc_Sigmac"], reltol, ) @@ -278,7 +278,7 @@ def test_eval_sigma_crit(modeling_data): assert_raises(ValueError, cosmo.eval_sigma_crit, 0.2, -0.3) # Check behaviour when sources are in front of the lens z_cluster = 0.3 - z_source = 0.2 - assert_allclose(cosmo.eval_sigma_crit(z_cluster, z_source), np.inf, 1.0e-10) - z_source = [0.2, 0.12, 0.25] - assert_allclose(cosmo.eval_sigma_crit(z_cluster, z_source), [np.inf, np.inf, np.inf], 1.0e-10) + z_src = 0.2 + assert_allclose(cosmo.eval_sigma_crit(z_cluster, z_src), np.inf, 1.0e-10) + z_src = [0.2, 0.12, 0.25] + assert_allclose(cosmo.eval_sigma_crit(z_cluster, z_src), [np.inf, np.inf, np.inf], 1.0e-10) diff --git a/tests/test_dataops.py b/tests/test_dataops.py index aae203de5..f60ac795b 100644 --- a/tests/test_dataops.py +++ b/tests/test_dataops.py @@ -6,6 +6,7 @@ from clmm import GCData from scipy.stats import multivariate_normal import clmm.dataops as da +from clmm.theory import compute_critical_surface_density_eff TOLERANCE = {"rtol": 1.0e-7, "atol": 1.0e-7} @@ -444,35 +445,9 @@ def test_compute_tangential_and_cross_components(modeling_data): # Check behaviour for the deltasigma option. cosmo = clmm.Cosmology(H0=70.0, Omega_dm0=0.275, Omega_b0=0.025) - # test missing info for is_deltasigma=True - assert_raises( - TypeError, - da.compute_tangential_and_cross_components, - ra_lens=ra_lens, - dec_lens=dec_lens, - ra_source=gals["ra"], - dec_source=gals["dec"], - shear1=gals["e1"], - shear2=gals["e2"], - is_deltasigma=True, - cosmo=None, - z_lens=z_lens, - z_source=gals["z"], - ) - assert_raises( - TypeError, - da.compute_tangential_and_cross_components, - ra_lens=ra_lens, - dec_lens=dec_lens, - ra_source=gals["ra"], - dec_source=gals["dec"], - shear1=gals["e1"], - shear2=gals["e2"], - is_deltasigma=True, - cosmo=cosmo, - z_lens=None, - z_source=gals["z"], - ) + # check values for DeltaSigma + sigma_c = cosmo.eval_sigma_crit(z_lens, gals["z"]) + # check validation between is_deltasigma and sigma_c assert_raises( TypeError, da.compute_tangential_and_cross_components, @@ -482,13 +457,9 @@ def test_compute_tangential_and_cross_components(modeling_data): dec_source=gals["dec"], shear1=gals["e1"], shear2=gals["e2"], - is_deltasigma=True, - cosmo=cosmo, - z_lens=z_lens, - z_source=None, + is_deltasigma=False, + sigma_c=sigma_c, ) - - # test missing info for use_pdz=True assert_raises( TypeError, da.compute_tangential_and_cross_components, @@ -499,30 +470,9 @@ def test_compute_tangential_and_cross_components(modeling_data): shear1=gals["e1"], shear2=gals["e2"], is_deltasigma=True, - use_pdz=True, - cosmo=cosmo, - z_lens=z_lens, - z_source=None, + sigma_c=None, ) - - # Trying to got through line 173 of dataops/__init__.py - da.compute_tangential_and_cross_components( - ra_lens=ra_lens, - dec_lens=dec_lens, - ra_source=gals["ra"][0], - dec_source=gals["dec"][0], - shear1=gals["e1"][0], - shear2=gals["e2"][0], - is_deltasigma=True, - use_pdz=True, - cosmo=cosmo, - z_lens=z_lens, - z_source=None, - pzbins=[[0.55, 0.6, 0.65, 0.7, 0.75]], - pzpdf=[[0.01, 1, 0.01, 0.001, 0.0001]], - ) - - # check values for DeltaSigma + # test values for geometry, expected in geo_tests: angsep_DS, tDS, xDS = da.compute_tangential_and_cross_components( ra_lens=ra_lens, @@ -532,9 +482,7 @@ def test_compute_tangential_and_cross_components(modeling_data): shear1=gals["e1"], shear2=gals["e2"], is_deltasigma=True, - cosmo=cosmo, - z_lens=z_lens, - z_source=gals["z"], + sigma_c=sigma_c, geometry=geometry, ) assert_allclose( @@ -583,15 +531,20 @@ def test_compute_tangential_and_cross_components(modeling_data): err_msg="Cross Shear not correct when using cluster method", ) + # test basic weights functionality + cluster.compute_galaxy_weights() + expected = np.array([1.0, 1.0]) + assert_allclose(cluster.galcat["w_ls"], expected, **TOLERANCE) + def test_compute_background_probability(): """test for compute background probability""" z_lens = 0.1 - z_source = np.array([0.22, 0.35, 1.7]) + z_src = np.array([0.22, 0.35, 1.7]) # true redshift p_bkg = da.compute_background_probability( - z_lens, z_source=z_source, use_pdz=False, pzpdf=None, pzbins=None, validate_input=True + z_lens, z_src=z_src, use_pdz=False, pzpdf=None, pzbins=None, validate_input=True ) expected = np.array([1.0, 1.0, 1.0]) assert_allclose(p_bkg, expected, **TOLERANCE) @@ -599,7 +552,7 @@ def test_compute_background_probability(): ValueError, da.compute_background_probability, z_lens, - z_source=None, + z_src=None, use_pdz=False, pzpdf=None, pzbins=None, @@ -608,13 +561,13 @@ def test_compute_background_probability(): # photoz + deltasigma pzbin = np.linspace(0.0001, 5, 100) - pzbins = [pzbin for i in range(z_source.size)] - pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_source] + pzbins = [pzbin for i in range(z_src.size)] + pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_src] assert_raises( ValueError, da.compute_background_probability, z_lens, - z_source=z_source, + z_src=z_src, use_pdz=True, pzpdf=None, pzbins=pzbins, @@ -626,27 +579,23 @@ def test_compute_galaxy_weights(): """test for compute galaxy weights""" cosmo = clmm.Cosmology(H0=71.0, Omega_dm0=0.265 - 0.0448, Omega_b0=0.0448, Omega_k0=0.0) z_lens = 0.1 - z_source = [0.22, 0.35, 1.7] + z_src = [0.22, 0.35, 1.7] shape_component1 = np.array([0.143, 0.063, -0.171]) shape_component2 = np.array([-0.011, 0.012, -0.250]) shape_component1_err = np.array([0.11, 0.01, 0.2]) shape_component2_err = np.array([0.14, 0.16, 0.21]) # true redshift + deltasigma + sigma_c = cosmo.eval_sigma_crit(z_lens, z_src) weights = da.compute_galaxy_weights( - z_lens, - cosmo, - z_source=z_source, - use_pdz=False, - pzpdf=None, - pzbins=None, + is_deltasigma=True, + sigma_c=sigma_c, use_shape_noise=False, shape_component1=shape_component1, shape_component2=shape_component2, use_shape_error=False, shape_component1_err=shape_component1_err, shape_component2_err=shape_component2_err, - is_deltasigma=True, validate_input=True, ) expected = np.array([4.58644320e-31, 9.68145632e-31, 5.07260777e-31]) @@ -654,22 +603,23 @@ def test_compute_galaxy_weights(): # photoz + deltasigma pzbin = np.linspace(0.0001, 5, 100) - pzbins = [pzbin for i in range(len(z_source))] - pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_source] - weights = da.compute_galaxy_weights( - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, + pzbins = [pzbin for i in range(len(z_src))] + pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_src] + sigma_c_eff = compute_critical_surface_density_eff( + cosmo=cosmo, + z_cluster=z_lens, pzbins=pzbins, + pzpdf=pzpdf, + ) + weights = da.compute_galaxy_weights( + is_deltasigma=True, + sigma_c=sigma_c_eff, use_shape_noise=False, shape_component1=shape_component1, shape_component2=shape_component2, use_shape_error=False, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=True, validate_input=True, ) @@ -679,21 +629,16 @@ def test_compute_galaxy_weights(): # photoz + deltasigma - shared bins pzbin = np.linspace(0.0001, 5, 100) pzbins = pzbin - pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_source] + pzpdf = [multivariate_normal.pdf(pzbin, mean=z, cov=0.3) for z in z_src] weights = da.compute_galaxy_weights( - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, + is_deltasigma=True, + sigma_c=sigma_c_eff, use_shape_noise=False, shape_component1=shape_component1, shape_component2=shape_component2, use_shape_error=False, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=True, validate_input=True, ) @@ -702,19 +647,14 @@ def test_compute_galaxy_weights(): # test with noise weights = da.compute_galaxy_weights( - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, + is_deltasigma=True, + sigma_c=sigma_c_eff, use_shape_noise=True, shape_component1=shape_component1, shape_component2=shape_component2, use_shape_error=False, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=True, validate_input=True, ) @@ -723,19 +663,14 @@ def test_compute_galaxy_weights(): # test with is_deltasigma=False and geometric weights only weights = da.compute_galaxy_weights( - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, + is_deltasigma=False, + sigma_c=None, use_shape_noise=False, shape_component1=shape_component1, shape_component2=shape_component2, use_shape_error=False, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=False, validate_input=True, ) @@ -746,19 +681,14 @@ def test_compute_galaxy_weights(): assert_raises( ValueError, da.compute_galaxy_weights, - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, + is_deltasigma=True, + sigma_c=sigma_c_eff, use_shape_noise=True, shape_component1=None, shape_component2=None, use_shape_error=False, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=False, validate_input=True, ) @@ -766,52 +696,12 @@ def test_compute_galaxy_weights(): assert_raises( ValueError, da.compute_galaxy_weights, - z_lens, - cosmo, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, - use_shape_noise=False, - use_shape_error=True, - shape_component1_err=None, - shape_component2_err=None, - is_deltasigma=False, - validate_input=True, - ) - - assert_raises( - TypeError, - da.compute_galaxy_weights, - z_lens, - cosmo=None, - z_source=None, - use_pdz=False, - pzpdf=pzpdf, - pzbins=pzbins, - use_shape_noise=True, - shape_component1=None, - shape_component2=None, - use_shape_error=False, - shape_component1_err=None, - shape_component2_err=None, is_deltasigma=True, - validate_input=True, - ) - assert_raises( - TypeError, - da.compute_galaxy_weights, - z_lens, - cosmo=None, - z_source=None, - use_pdz=True, - pzpdf=pzpdf, - pzbins=pzbins, + sigma_c=sigma_c_eff, use_shape_noise=False, - use_shape_error=False, + use_shape_error=True, shape_component1_err=None, shape_component2_err=None, - is_deltasigma=True, validate_input=True, ) diff --git a/tests/test_galaxycluster.py b/tests/test_galaxycluster.py index a3987255f..04d73c6dc 100644 --- a/tests/test_galaxycluster.py +++ b/tests/test_galaxycluster.py @@ -140,12 +140,12 @@ def test_print_gc(): def test_integrity_of_lensfuncs(): """test integrity of lensfuncs""" ra_source, dec_source = [120.1, 119.9, 119.9], [41.9, 42.2, 42.2] - id_source, z_source = [1, 2, 3], [1, 1, 1] + id_source, z_src = [1, 2, 3], [1, 1, 1] shape_component1 = np.array([0.143, 0.063, -0.171]) shape_component2 = np.array([-0.011, 0.012, -0.250]) galcat = GCData( - [ra_source, dec_source, z_source, id_source, shape_component1, shape_component2], + [ra_source, dec_source, z_src, id_source, shape_component1, shape_component2], names=("ra", "dec", "z", "id", "e1", "e2"), ) galcat_noz = GCData([ra_source, dec_source, id_source], names=("ra", "dec", "id")) @@ -168,8 +168,8 @@ def test_integrity_of_lensfuncs(): pzbins = np.linspace(0.0001, 5, 100) cluster = clmm.GalaxyCluster(unique_id="1", ra=161.3, dec=34.0, z=0.3, galcat=galcat) cluster.galcat.pzpdf_info["zbins"] = pzbins - cluster.galcat["pzbins"] = [pzbins for i in range(len(z_source))] - cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_source] + cluster.galcat["pzbins"] = [pzbins for i in range(len(z_src))] + cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_src] for pztype in ("individual_bins", "shared_bins"): cluster.galcat.pzpdf_info["type"] = pztype @@ -177,21 +177,20 @@ def test_integrity_of_lensfuncs(): cluster.compute_tangential_and_cross_components( is_deltasigma=True, use_pdz=True, cosmo=cosmo, add=True ) - assert_equal(cluster.galcat.meta["sigmac_type"], "effective") + for comp_name in ("et", "ex"): + assert_equal(cluster.galcat.meta[f"{comp_name}_sigmac_type"], "effective") def test_integrity_of_probfuncs(): """test integrity of prob funcs""" ra_source, dec_source = [120.1, 119.9, 119.9], [41.9, 42.2, 42.2] - id_source, z_sources = [1, 2, 3], [1, 1, 1] + id_source, z_srcs = [1, 2, 3], [1, 1, 1] cluster = clmm.GalaxyCluster( unique_id="1", ra=161.3, dec=34.0, z=0.3, - galcat=GCData( - [ra_source, dec_source, z_sources, id_source], names=("ra", "dec", "z", "id") - ), + galcat=GCData([ra_source, dec_source, z_srcs, id_source], names=("ra", "dec", "z", "id")), ) # true redshift cluster.compute_background_probability(use_pdz=False, p_background_name="p_bkg_true") @@ -202,8 +201,8 @@ def test_integrity_of_probfuncs(): assert_raises(TypeError, cluster.compute_background_probability, use_photoz=True) pzbins = np.linspace(0.0001, 5, 1000) cluster.galcat.pzpdf_info["zbins"] = pzbins - cluster.galcat["pzbins"] = [pzbins for i in range(len(z_sources))] - cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.01) for z in z_sources] + cluster.galcat["pzbins"] = [pzbins for i in range(len(z_srcs))] + cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.01) for z in z_srcs] for pztype in ("individual_bins", "shared_bins"): cluster.galcat.pzpdf_info["type"] = pztype cluster.compute_background_probability(use_pdz=True, p_background_name="p_bkg_pz") @@ -214,7 +213,7 @@ def test_integrity_of_weightfuncs(): """test integrity of weight funcs""" cosmo = clmm.Cosmology(H0=71.0, Omega_dm0=0.265 - 0.0448, Omega_b0=0.0448, Omega_k0=0.0) z_lens = 0.1 - z_source = [0.22, 0.35, 1.7] + z_src = [0.22, 0.35, 1.7] shape_component1 = np.array([0.143, 0.063, -0.171]) shape_component2 = np.array([-0.011, 0.012, -0.250]) shape_component1_err = np.array([0.11, 0.01, 0.2]) @@ -231,7 +230,7 @@ def test_integrity_of_weightfuncs(): shape_component2, shape_component1_err, shape_component2_err, - z_source, + z_src, ], names=("e1", "e2", "e1_err", "e2_err", "z"), ), @@ -245,8 +244,8 @@ def test_integrity_of_weightfuncs(): # photoz + deltasigma pzbins = np.linspace(0.0001, 5, 100) cluster.galcat.pzpdf_info["zbins"] = pzbins - cluster.galcat["pzbins"] = [pzbins for i in range(len(z_source))] - cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_source] + cluster.galcat["pzbins"] = [pzbins for i in range(len(z_src))] + cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_src] for pztype in ("individual_bins", "shared_bins"): cluster.galcat.pzpdf_info["type"] = pztype cluster.compute_galaxy_weights( @@ -271,11 +270,11 @@ def test_integrity_of_weightfuncs(): def test_pzpdf_random_draw(): """test draw_gal_z_from_pdz""" z_lens = 0.1 - z_source = [0.22, 0.35, 1.7] + z_src = [0.22, 0.35, 1.7] shape_component1 = np.array([0.143, 0.063, -0.171]) shape_component2 = np.array([-0.011, 0.012, -0.250]) cluster_kwargs = dict(unique_id="1", ra=161.3, dec=34.0, z=z_lens) - gcat_args = [shape_component1, shape_component2, z_source] + gcat_args = [shape_component1, shape_component2, z_src] gcat_kwargs = {"names": ("e1", "e2", "z")} # set up photoz @@ -288,19 +287,17 @@ def test_pzpdf_random_draw(): assert_raises(TypeError, cluster.draw_gal_z_from_pdz) cluster.galcat.pzpdf_info["zbins"] = pzbins - cluster.galcat["pzbins"] = [pzbins for i in range(len(z_source))] + cluster.galcat["pzbins"] = [pzbins for i in range(len(z_src))] assert_raises(TypeError, cluster.draw_gal_z_from_pdz) cluster.galcat.pzpdf_info.pop("zbins") cluster.galcat.remove_column("pzbins") - cluster.galcat["pzpdf"] = [ - multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_source - ] + cluster.galcat["pzpdf"] = [multivariate_normal.pdf(pzbins, mean=z, cov=0.3) for z in z_src] assert_raises(TypeError, cluster.draw_gal_z_from_pdz) # add pzbins back to galcat cluster.galcat.pzpdf_info["zbins"] = pzbins - cluster.galcat["pzbins"] = [pzbins for i in range(len(z_source))] + cluster.galcat["pzbins"] = [pzbins for i in range(len(z_src))] # test raising TypeError when the name of the new column is already in cluster.galcat # also test default overwrite=False and zcol_out='z' assert_raises(TypeError, cluster.draw_gal_z_from_pdz) @@ -349,7 +346,7 @@ def test_plot_profiles(): ra_lens, dec_lens, z_lens = 120.0, 42.0, 0.5 ra_source = [120.1, 119.9] dec_source = [41.9, 42.2] - z_source = [1.0, 2.0] + z_src = [1.0, 2.0] shear1 = [0.2, 0.4] shear2 = [0.3, 0.5] # Set up radial values @@ -362,7 +359,7 @@ def test_plot_profiles(): dec=dec_lens, z=z_lens, galcat=GCData( - [ra_source, dec_source, shear1, shear2, z_source], names=("ra", "dec", "e1", "e2", "z") + [ra_source, dec_source, shear1, shear2, z_src], names=("ra", "dec", "e1", "e2", "z") ), ) cluster.compute_tangential_and_cross_components() diff --git a/tests/test_theory.py b/tests/test_theory.py index 9c482317c..ad8562b33 100644 --- a/tests/test_theory.py +++ b/tests/test_theory.py @@ -94,7 +94,7 @@ def load_validation_config(halo_profile_model=None): "mdelta": testcase["cluster_mass"], "cdelta": testcase["cluster_concentration"], "z_cluster": testcase["z_cluster"], - "z_source": testcase["z_source"], + "z_src": testcase["z_src"], "delta_mdef": testcase["mass_Delta"], "halo_profile_model": testcase["density_profile_parametrization"], "z_src_info": "discrete", @@ -102,7 +102,7 @@ def load_validation_config(halo_profile_model=None): return { "TEST_CASE": testcase, - "z_source": testcase["z_source"], + "z_src": testcase["z_src"], "cosmo": cosmo, "cosmo_pars": {k.replace("cosmo_", ""): v for k, v in testcase.items() if "cosmo_" in k}, "RHO_PARAMS": RHO_PARAMS, @@ -473,7 +473,7 @@ def helper_physics_functions(func, additional_kwargs={}): "mdelta": 1.0e15, "cdelta": 4.0, "z_cluster": 0.2, - "z_source": 0.45, + "z_src": 0.45, "cosmo": theo.Cosmology(Omega_dm0=0.25, Omega_b0=0.05, H0=70.0), } kwargs.update(additional_kwargs) @@ -547,19 +547,19 @@ def test_shear_convergence_unittests(modeling_data, profile_init): cfg_inf = load_validation_config() # compute some values - cfg_inf["GAMMA_PARAMS"]["z_source"] = 1000.0 + cfg_inf["GAMMA_PARAMS"]["z_src"] = 1000.0 beta_s_mean = compute_beta_s_mean( - cfg_inf["GAMMA_PARAMS"]["z_cluster"], cfg_inf["GAMMA_PARAMS"]["z_source"], cosmo + cfg_inf["GAMMA_PARAMS"]["z_cluster"], cfg_inf["GAMMA_PARAMS"]["z_src"], cosmo ) beta_s_square_mean = compute_beta_s_square_mean( - cfg_inf["GAMMA_PARAMS"]["z_cluster"], cfg_inf["GAMMA_PARAMS"]["z_source"], cosmo + cfg_inf["GAMMA_PARAMS"]["z_cluster"], cfg_inf["GAMMA_PARAMS"]["z_src"], cosmo ) gammat_inf = theo.compute_tangential_shear(cosmo=cosmo, **cfg_inf["GAMMA_PARAMS"]) kappa_inf = theo.compute_convergence(cosmo=cosmo, **cfg_inf["GAMMA_PARAMS"]) # test z_src = chang2013 distribution - cfg_inf["GAMMA_PARAMS"]["z_source"] = chang2013 + cfg_inf["GAMMA_PARAMS"]["z_src"] = chang2013 cfg_inf["GAMMA_PARAMS"]["z_src_info"] = "distribution" # store original values @@ -762,7 +762,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): # test z_src_info = 'beta' beta_s_mean, beta_s_square_mean = 0.9, 0.6 - cfg_inf["GAMMA_PARAMS"]["z_source"] = (beta_s_mean, beta_s_square_mean) + cfg_inf["GAMMA_PARAMS"]["z_src"] = (beta_s_mean, beta_s_square_mean) cfg_inf["GAMMA_PARAMS"]["z_src_info"] = "beta" # tangential shear assert_allclose( @@ -836,7 +836,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): # First, check for a array of radius and single source z radius = np.logspace(-2, 2, 10) z_cluster = 0.3 - z_source = 0.2 + z_src = 0.2 assert_allclose( theo.compute_convergence( @@ -844,7 +844,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), np.zeros(len(radius)), @@ -856,7 +856,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), np.zeros(len(radius)), @@ -868,7 +868,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), np.zeros(len(radius)), @@ -880,7 +880,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), np.ones(len(radius)), @@ -893,7 +893,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), np.ones(len(radius)), @@ -902,17 +902,17 @@ def test_shear_convergence_unittests(modeling_data, profile_init): # Second, check a single radius and array of source z radius = 1.0 - z_source = [0.25, 0.1, 0.14, 0.02] + z_src = [0.25, 0.1, 0.14, 0.02] assert_allclose( theo.compute_convergence( radius, mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), - np.zeros(len(z_source)), + np.zeros(len(z_src)), 1.0e-10, ) assert_allclose( @@ -921,10 +921,10 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), - np.zeros(len(z_source)), + np.zeros(len(z_src)), 1.0e-10, ) assert_allclose( @@ -933,10 +933,10 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), - np.zeros(len(z_source)), + np.zeros(len(z_src)), 1.0e-10, ) assert_allclose( @@ -945,10 +945,10 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), - np.ones(len(z_source)), + np.ones(len(z_src)), 1.0e-10, ) assert_allclose( @@ -958,10 +958,10 @@ def test_shear_convergence_unittests(modeling_data, profile_init): mdelta=1.0e15, cdelta=4.0, z_cluster=z_cluster, - z_source=z_source, + z_src=z_src, cosmo=cosmo, ), - np.ones(len(z_source)), + np.ones(len(z_src)), 1.0e-10, ) @@ -996,7 +996,7 @@ def test_shear_convergence_unittests(modeling_data, profile_init): profile_pars = [ cfg["GAMMA_PARAMS"]["r_proj"], cfg["GAMMA_PARAMS"]["z_cluster"], - cfg["GAMMA_PARAMS"]["z_source"], + cfg["GAMMA_PARAMS"]["z_src"], ] # Validate tangential shear gammat = mod.eval_tangential_shear(*profile_pars) @@ -1113,49 +1113,49 @@ def test_shear_convergence_unittests(modeling_data, profile_init): # First, check for a array of radius and single source z radius = np.logspace(-2, 2, 10) z_cluster = 0.3 - z_source = 0.2 + z_src = 0.2 assert_allclose( - mod.eval_convergence(radius, z_cluster, z_source), np.zeros(len(radius)), 1.0e-10 + mod.eval_convergence(radius, z_cluster, z_src), np.zeros(len(radius)), 1.0e-10 ) assert_allclose( - mod.eval_tangential_shear(radius, z_cluster, z_source), np.zeros(len(radius)), 1.0e-10 + mod.eval_tangential_shear(radius, z_cluster, z_src), np.zeros(len(radius)), 1.0e-10 ) assert_allclose( - mod.eval_reduced_tangential_shear(radius, z_cluster, z_source), + mod.eval_reduced_tangential_shear(radius, z_cluster, z_src), np.zeros(len(radius)), 1.0e-10, ) assert_allclose( - mod.eval_magnification(radius, z_cluster, z_source), np.ones(len(radius)), 1.0e-10 + mod.eval_magnification(radius, z_cluster, z_src), np.ones(len(radius)), 1.0e-10 ) assert_allclose( - mod.eval_magnification_bias(radius, z_cluster, z_source, alpha), + mod.eval_magnification_bias(radius, z_cluster, z_src, alpha), np.ones(len(radius)), 1.0e-10, ) # Second, check a single radius and array of source z radius = 1.0 - z_source = [0.25, 0.1, 0.14, 0.02] + z_src = [0.25, 0.1, 0.14, 0.02] assert_allclose( - mod.eval_convergence(radius, z_cluster, z_source), np.zeros(len(z_source)), 1.0e-10 + mod.eval_convergence(radius, z_cluster, z_src), np.zeros(len(z_src)), 1.0e-10 ) assert_allclose( - mod.eval_tangential_shear(radius, z_cluster, z_source), np.zeros(len(z_source)), 1.0e-10 + mod.eval_tangential_shear(radius, z_cluster, z_src), np.zeros(len(z_src)), 1.0e-10 ) assert_allclose( - mod.eval_reduced_tangential_shear(radius, z_cluster, z_source), - np.zeros(len(z_source)), + mod.eval_reduced_tangential_shear(radius, z_cluster, z_src), + np.zeros(len(z_src)), 1.0e-10, ) assert_allclose( - mod.eval_magnification(radius, z_cluster, z_source), np.ones(len(z_source)), 1.0e-10 + mod.eval_magnification(radius, z_cluster, z_src), np.ones(len(z_src)), 1.0e-10 ) assert_allclose( - mod.eval_magnification_bias(radius, z_cluster, z_source, alpha), - np.ones(len(z_source)), + mod.eval_magnification_bias(radius, z_cluster, z_src, alpha), + np.ones(len(z_src)), 1.0e-10, )