The Profile base class
All profiles in profiley inherit from the Profile base class, which
implements numerical calculations of all methods, starting from a profile
method in which the three-dimensional profile is defined. The Profile base
class allows for all profiles to have a common, simple API. See all implemented
profiles here.
Methods defined in this class |
|
|---|---|
|
three-dimensional profile |
|
mean value within |
|
spherical integral within |
|
Line-of-sight projected profile |
|
Line-of-sight projected cumulative profile |
|
difference between |
|
gravitational potential |
|
escape velocity |
|
mass within a specified overdensity |
|
radius enclosing a specified overdensity |
where R are the radii at which to return the profiles. Where available,
these methods are implemented using the analytical expressions; otherwise they
are calculated numerically. Additional arguments absorbed in kwargs relate
to the precision (and speed) of numerical integration. See below.
Numerical calculations
If any of the above methods are not defined analytically, they are
calculated by numerical integration, using scipy.integrate.simps.
Cumulative profile
Mean value of the profile within the specified radius:
Cumulative mass
Spherical integral within a radius R. For a density profile this corresponds
to the enclosed mass:
Projected profile
The projection of the profile along the line of sight, \(\Sigma(R)\), can be calculated as follows:
Cumulative projected profile
The enclosed (or cumulative) projected profile is then
Excess projected profile
The excess projected profile is defined as
This quantity is particularly useful in weak gravitational lensing studies, where \(\Delta\Sigma(R)\) is the excess surface density (ESD), which is directly related to the weak lensing shape distortion, called shear, \(\gamma\), through \(\gamma=\Delta\Sigma/\Sigma_\mathrm{c}\), where \(\Sigma_\mathrm{c}\) is the critical surface density (see Lensing).
Gravitational potential
The Poisson equation implies that the gravitational potential can be calculated as
The gravitational potential is returned in units of \(\mathrm{Mpc^2\,s^{-2}}\).
Escape velocity
The escape velocity is related to the gravitational potential through
and is returned in \(\mathrm{km\,s^{-1}}\).
Precision of numerical integration
Several optional arguments allow the user to find their own sweet-spot in the trade-off between precision and execution time. Using the default parameters the precision of the numerical calculations for an NFW profile is better than 0.1% at all radii, as demonstrated in the numerical integration example.
Offset profiles
It is also possible to calculate a given profile projection when the reference point is not the center of the profile itself. If the projected distance between the reference point and the center of the profile is \(R_\mathrm{off}\), then the measured projected profile is
and analogously for other projections. These offset profiles are calculated
numerically using the offset wrapper:
offset(func, R, R_off, theta_samples=360, weights=None, **kwargs)
where func is any of the methods above, R_off is either a float or a
1-d np.ndarray, theta_samples sets the precision for the angular
integral, and weights is a weight array applied to average the profiles
evaluated at different \(R_\mathrm{off}\). Each of the projected profiles
is implemented in the following convenience functions:
|
|
|
|
Stand-alone offset functionality
Since v1.4.0 it is also possible to offset an arbitrary profile given as an
array, using the offset function within the numeric module:
from profiley.nfw import NFW
from profiley.numeric import offset
mass = 1e14
concentration = 5
z = 0.2
nfw = NFW(mass, concentration, z)
R = np.logspace(-1, 1, 20)
sigma = nfw.projected(R)
Roff = np.arange(0, 1, 10)
weights = np.normal(0.2, 0.1, Roff.size)
sigma_off = offset(sigma, R, Roff, weights=weights)
For more details, see the offset example.
In fact, the latter implementation is about an order of magnitude faster
than the Profile method described above, and should be preferred for
the time being. The current methods will be replaced by this implementation in the future.
A note on the radial coordinate
All examples in these docs employ one-dimensional radial arrays, R, to calculate profiles. In fact, profiley can manage R of any shape. The resulting profiles will depend on the shape of R: dimensions will be added to R to the extent that they are needed to be able to multiply R with an array of shape p.shape. Below are a few examples, assuming p is a Profile object with shape=(12, 7, 5). For instance,
mass = np.logspace(14, 15, 5)
concentration = np.linspace(2, 9, 7)
z = np.linspace(0, 1, 12)
p = NFW(mass, concentration[:,None], z[:,None,None])
The shape of the result of any of p’s profile methods will be as follows:
|
profile shape |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Etc. That is, if the last N dimensions of R match the first N dimensions of p (considering empty dimensions appropriately), they will be assumed to correspond to each set of profiles. Exceptional situations, e.g., when the number of radial elements (or the last dimension) is equal to the first element of p.shape but it is not meant to represent one radial vector per profile, will not behave as expected. Such fringe cases must be appropriately handled by the user, but should generally be avoided.
Inheritance
What follows are the descriptions of helper classes from which Profile
inherits. These classes are not to be instantiated directly, but the description
of attributes and methods defined within these classes is separated for clarity.
BaseCosmo: Cosmology
The cosmology in which a Profile object is embedded is specified through the
cosmo optional argument, which must be any astropy.cosmology.FLRW object.
This allows for the definition of the background density as well as calculations
of distances detailed below.
Optional arguments inherited from this class |
||
|---|---|---|
|
|
Whether overdensities are defined w.r.t. the critical or mean density |
|
|
Cosmology (default: |
|
|
Whether to work in comoving or physical coordinates |
Attributes inherited from this class |
||
|---|---|---|
|
|
critical density of the universe at all supplied redshifts |
|
|
mean density of the universe at all supplied redshifts |
|
|
alias for either |
Lens: Gravitational lensing functionality
The Profile class inherits from the Lens helper class,
which implements quantities relevant for gravitational lensing analysis.
Attributes inherited from this class |
||
|---|---|---|
|
|
angular diameter distance from observer to lens object, in Mpc |
Methods inherited from this class |
|
|---|---|
|
angular diameter distance from lens to source, in Mpc |
|
\(\max(0, D_\mathrm{ls}/D_\mathrm{s})\) |
|
lensing convergence |
|
offset lensing convergence |
|
critical surface density |
In all these methods, z_s is the source redshift.