clenspy.lensing.LensingProfile¶
- class clenspy.lensing.LensingProfile(z_cluster, m200, cosmology=None, concentration=4.0, model='NFW', include_2halo=True, backend_2halo='camb', z_source=1.0, halo_profile=None, two_halo=None, bias=None, k_grid=None)[source]¶
Bases:
objectA unified class for weak lensing calculations, combining a 1-halo term (NfwProfile) with an optional linear-bias 2-halo term (TwoHaloTerm):
NOTE: masses are M_200m (200x the comoving mean matter density at z=0), inherited from NfwProfile – not M_200c.
NOTE: all quantities are h-free absolute units – mass in Msun, lengths in Mpc, Sigma and DeltaSigma in Msun/Mpc^2, wavenumbers in 1/Mpc.
\[\Sigma(R) = \Sigma_{\rm 1h}(R) + b(M)\, \rho_m\, \Sigma_{\rm 2h}(R)\]where \(b(M)\) is the linear halo bias (BiasModel) and \(\rho_m = \Omega_{m,0}\,\rho_{c,0}\) is the present-day (comoving) mean matter density – no redshift dependence.
- Parameters:
- cosmology¶
Cosmology used for all calculations.
- model¶
Halo profile model, normalised to lower case. See SUPPORTED_MODELS; currently only “nfw” is implemented.
- Type:
Notes
The constructor stores; it does not compute. Pkvec, two_halo_profile, bias_model, bias, halo_profile and sigma_crit are functools.cached_property, so
LensingProfile(z_cluster=0.3, m200=1e14)costs nothing and only Pkvec starts a Boltzmann solver – on the first call that needs it. Passtwo_halo=,bias=orhalo_profile=to supply a collaborator instead, which is how a driver reuses one P(k) across many halos. Only_validate_inputsruns eagerly, so a bad redshift or mass still raises at construction rather than pages later.deltasigma’s 2-halo term previously multiplied by a hardcoded
1e12instead ofself.rho_m(the factor sigma’s 2-halo term correctly uses - TwoHaloTerm.sigma/deltasigma are both derived from the same un-normalized xi(r) grid, so they need the same normalization). Confirmed this was wrong empirically (deltasigma came out ~1e10x larger than sigma, giving unphysical shear >> 1) and against tests/test_twohalo.py’s own cluster_toolkit-validated reference pattern, which usesTwoHaloTerm.deltasigma(...) * rho_mwith no extra factor. Fixed to match.- __init__(z_cluster, m200, cosmology=None, concentration=4.0, model='NFW', include_2halo=True, backend_2halo='camb', z_source=1.0, halo_profile=None, two_halo=None, bias=None, k_grid=None)[source]¶
- Parameters:
z_cluster (float) – Cluster (lens) redshift.
m200 (float) – Halo mass M_200m [Msun], w.r.t. 200x the comoving mean matter density.
cosmology (astropy.cosmology.Cosmology, optional) – Cosmology to use (default: fiducial_cosmology()).
concentration (float, optional) – Halo concentration c_200 (default: 4.0).
model (str, optional) – Halo profile model, case-insensitive and normalised to lower case. See SUPPORTED_MODELS; only “nfw” is implemented (default: “NFW”).
include_2halo (bool, optional) – Whether to add the 2-halo term (default: True). Nothing is built until an observable is evaluated – see the class Notes.
backend_2halo ({"camb", "pyccl"}, optional) – PkGrid backend for the 2-halo term’s P(k) (default: “camb”).
z_source (float, optional) – Source redshift, must exceed
z_cluster(default: 1.0).halo_profile (optional) – A pre-built 1-halo profile, e.g. NfwProfile. Built from
modelif omitted.two_halo (optional) – A pre-built TwoHaloTerm. Built from
k_gridand a fresh ~clenspy.cosmology.PkGrid if omitted – which is what runs the Boltzmann solver, so pass one to reuse a P(k).bias (float, optional) – Linear halo bias \(b(M)\). Computed from the same P(k) as
two_haloif omitted. Pass a number to fix it to a published value and skip that computation.k_grid (array-like, optional) – Wavenumbers for the 2-halo term [1/Mpc]. Defaults to K_GRID_2HALO; see the note there for why that extent.
- Return type:
None
Methods
__init__(z_cluster, m200[, cosmology, ...])convergence(R)Convergence (dimensionless).
deltasigma(R)Excess surface density, in Msun/Mpc^2.
density(r)3D density, in Msun/Mpc^3.
Intended: the mass-normalized Fourier transform \(u(k) \equiv \tilde\rho(k)/M\),
Reduced shear.
shear(R)Tangential shear (dimensionless).
sigma(R)Surface density, in Msun/Mpc^2.
Attributes
Linear P(k) on kvec at
z_cluster[Mpc^3].Linear halo bias \(b(M_{200m})\), as supplied or computed.
BiasModel on the same P(k) the 2-halo term uses.
as supplied, or built from
model.Return a summary dictionary of the profile parameters.
\(\Sigma_{\rm crit}(z_l, z_s)\) [Msun/Mpc^2].
as supplied, or built from Pkvec.
- property halo_profile¶
as supplied, or built from
model.- Type:
The 1-halo profile
- property Pkvec¶
Linear P(k) on kvec at
z_cluster[Mpc^3]. Runs the solver.
- property two_halo_profile¶
as supplied, or built from Pkvec.
- Type:
The 2-halo term
- deltasigma(R)[source]¶
Excess surface density, in Msun/Mpc^2.
\[\Delta\Sigma(R) = \Delta\Sigma_{\rm 1h}(R) + b(M)\, \Delta\Sigma_{\rm 2h}(R)\]See the class Notes for a units caveat on the 2-halo term here.
- sigma(R)[source]¶
Surface density, in Msun/Mpc^2.
\[\Sigma(R) = \Sigma_{\rm 1h}(R) + b(M)\, \rho_m\, \Sigma_{\rm 2h}(R)\]
- density(r)[source]¶
3D density, in Msun/Mpc^3.
\[\rho(r) = \rho_{\rm 1h}(r) + \rho_m \left[1 + b(M)\, \xi_{\rm 2h}(r)\right]\]where \(\xi_{\rm 2h}\) is the matter correlation function (TwoHaloTerm.xi).
- shear(R)[source]¶
Tangential shear (dimensionless).
\[\gamma_t(R) = \frac{\Delta\Sigma(R)}{\Sigma_{\rm crit}}\]
- convergence(R)[source]¶
Convergence (dimensionless).
\[\kappa(R) = \frac{\Sigma(R)}{\Sigma_{\rm crit}}\]
- reduced_shear(R)[source]¶
Reduced shear.
\[g_t(R) = \frac{\gamma_t(R)}{1 - \kappa(R)}\]- Raises:
ValueError – If \(\kappa(R) \geq 1\) anywhere (the reduced-shear expansion is invalid in the strong-lensing regime).
- Parameters:
- Return type:
- fourier_profile(k)[source]¶
Intended: the mass-normalized Fourier transform \(u(k) \equiv \tilde\rho(k)/M\),
\[u(k) = u_{\rm 1h}(k) + \frac{b(M)}{M}\, P_{\rm 2h}(k).\]NOTE: not what this currently returns.
self.halo_profile.fourier(k)is \(\tilde\rho_{\rm 1h}(k)\) [Msun], not divided bym200(see NfwProfile.fourier’s own NOTE) – while the 2-halo term here already is. The two terms are off by a factor of order \(M_{200}\) in scale, so the sum below is \(\tilde\rho_{\rm 1h}(k) + b(M)P_{\rm 2h}(k)/M\), not \(u(k)\): the 1-halo term dominates at every \(k\), and the 2-halo term is numerically swamped rather than combined. Divideself.halo_profile.fourier(k)byself.m200to get the \(u(k)\) documented above; not fixed here since it changes this method’s public output.
- property info: LensingProfileInfo¶
Return a summary dictionary of the profile parameters.