pynbody.analysis.theoretical_profiles.NFWProfile#
- class pynbody.analysis.theoretical_profiles.NFWProfile(density_scale_radius=None, scale_radius=None, halo_radius=None, concentration=None, halo_mass=None)[source]#
Bases:
AbstractBaseProfile
Represents a Navarro-Frenk-White (NFW) profile.
Methods
__call__
(radius)Call self as a function.
enclosed_mass
(radius)Return the mass, M(r), enclosed within a given radius
fit
(radial_data, profile_data[, ...])Fit the given profile using a least-squares method.
keys
()Return the keys of the profile parameters
logarithmic_slope
(radius)Return the logarithmic slope of the profile, d ln rho / d ln r, at a given radius
parameter_bounds
(r_values, rho_values)Return bounds on the parameter values for the profile fit
jacobian
- __init__(density_scale_radius=None, scale_radius=None, halo_radius=None, concentration=None, halo_mass=None)[source]#
Represents a Navarro-Frenk-White (NFW) profile.
The profile can then be initialised through one of the following combination of parameters:
scale_radius, density_scale_radius and optionally halo_radius;
halo_radius, concentration and density_scale_radius;
halo_radius, concentration and halo_mass.
From one mode of initialisation, the derived parameters of the others are calculated, e.g. if you initialise with halo_mass + concentration, the scale_radius and central density will be derived. The exception is if you initialise with scale_radius + density_scale_radius without halo_radius.
Units may be passed into the parameters by using scalar arrays.
- Parameters:
scale_radius (float | array-like, optional) – The radius at which the slope is equal to -2
density_scale_radius (float | array-like, optional) – 1/4 of density at r=rs (normalisation).
halo_mass (float | array-like, optional) – The mass enclosed inside the outer halo radius
halo_radius (float | array-like) – The outer boundary of the halo (r200m, r200c, rvir … depending on definitions)
concentration (float | array-like, optional) – The outer_radius / scale_radius
- classmethod fit(radial_data, profile_data, profile_err=None, use_analytical_jac=True, guess=None, verbose=0, return_profile=True)#
Fit the given profile using a least-squares method.
- Parameters:
radial_data (array_like) – The central radius of the bins in which the profile data is measured
profile_data (array_like) – The profile density values
profile_err (array_like, optional) – The error on the profile data
use_analytical_jac (bool) – Whether to use the analytical jacobian of the profile function. If False, finite differencing is used.
guess (array_like, optional) – An initial guess for the parameters of the profile. If None, the initial guess is taken to be all ones, according to the underlying
scipy.optimize.curve_fit
function.verbose (int) – The verbosity level to pass to the underlying
scipy.optimize.curve_fit
function.return_profile (bool) – Whether to return the profile object or just the parameters
- Returns:
fitted_profile (array_like | AbstractBaseProfile) – If return_profile is True, the fitted profile object. Otherwise, the fitted parameters.
cov (array_like) – The covariance matrix of the fit. The diagonal elements are the variance of the parameters.
- keys()#
Return the keys of the profile parameters
- logarithmic_slope(radius)[source]#
Return the logarithmic slope of the profile, d ln rho / d ln r, at a given radius
- classmethod parameter_bounds(r_values, rho_values)[source]#
Return bounds on the parameter values for the profile fit
- Parameters:
r_values (array_like) – The radii at which the profile is measured
rho_values (array_like) – The density values of the profile
- Returns:
bounds – A 2-tuple containing lower and upper bounds respectively for the parameters of the profile
- Return type:
tuple[array_like]