コード例 #1
0
ファイル: velocity_models.py プロジェクト: parejkoj/halotools
    def dimensionless_velocity_dispersion(self, x, conc):
        """
        Parameters 
        -----------
        x : array_like 
            Halo-centric distance scaled by the halo boundary, so that 
            :math:`0 <= x <= 1`. Can be a scalar or numpy array

        conc : float 
            Concentration of the halo.

        Returns 
        -------
        result : array_like 
            Radial velocity dispersion profile scaled by the virial velocity. 
            The returned result has the same dimension as the input ``x``. 
        """
        x = convert_to_ndarray(x)
        x = x.astype(float)
        result = np.zeros_like(x)

        prefactor = conc*(conc*x)*(1. + conc*x)**2/self.g(conc)

        lower_limit = conc*x
        upper_limit = float("inf")
        for i in range(len(x)):
            term1, _ = quad_integration(self._jeans_integrand_term1, 
                lower_limit[i], upper_limit, epsrel=1e-5)
            term2, _ = quad_integration(self._jeans_integrand_term2, 
                lower_limit[i], upper_limit, epsrel=1e-5)
            result[i] = term1 - term2 

        return np.sqrt(result*prefactor)
コード例 #2
0
def dimensionless_radial_velocity_dispersion(scaled_radius,
                                             halo_conc,
                                             gal_conc,
                                             profile_integration_tol=1e-4):
    r"""
    Analytical solution to the isotropic jeans equation for an NFW potential,
    rendered dimensionless via scaling by the virial velocity.

    :math:`\tilde{\sigma}^{2}_{r}(\tilde{r})\equiv\sigma^{2}_{r}(\tilde{r})/V_{\rm vir}^{2} = \frac{c^{2}\tilde{r}(1 + c\tilde{r})^{2}}{g(c)}\int_{c\tilde{r}}^{\infty}{\rm d}y\frac{g(y)}{y^{3}(1 + y)^{2}}`

    See :ref:`nfw_jeans_velocity_profile_derivations` for derivations and implementation details.

    Parameters
    -----------
    scaled_radius : array_like
        Length-Ngals numpy array storing the halo-centric distance
        *r* scaled by the halo boundary :math:`R_{\Delta}`, so that
        :math:`0 <= \tilde{r} \equiv r/R_{\Delta} <= 1`.

    halo_conc : float
        Concentration of the halo.

    Returns
    -------
    result : array_like
        Radial velocity dispersion profile scaled by the virial velocity.
        The returned result has the same dimension as the input ``scaled_radius``.
    """
    x = np.atleast_1d(scaled_radius).astype(np.float64)
    result = np.zeros_like(x)

    prefactor = gal_conc * gal_conc * x * (
        1. + gal_conc * x)**2 / _g_integral(halo_conc)
    extra_args = halo_conc / np.atleast_1d(gal_conc).astype('f4')

    lower_limit = gal_conc * x
    upper_limit = float("inf")
    for i in range(len(x)):
        term1, _ = quad_integration(_jeans_integrand_term1,
                                    lower_limit[i],
                                    upper_limit,
                                    epsrel=profile_integration_tol,
                                    args=extra_args)
        term2, _ = quad_integration(_jeans_integrand_term2,
                                    lower_limit[i],
                                    upper_limit,
                                    epsrel=profile_integration_tol,
                                    args=extra_args)
        result[i] = term1 - term2

    return np.sqrt(result * prefactor)
コード例 #3
0
    def cumulative_mass_PDF(self, scaled_radius, *prof_params):
        r"""
        The fraction of the total mass enclosed within dimensionless radius,

        :math:`P_{\rm prof}(<\tilde{r}) \equiv M_{\Delta}(<\tilde{r}) / M_{\Delta},`
        where :math:`\tilde{r} \equiv r / R_{\Delta}`.

        Parameters
        -----------
        scaled_radius : array_like
            Halo-centric distance *r* scaled by the halo boundary :math:`R_{\Delta}`, so that
            :math:`0 <= \tilde{r} \equiv r/R_{\Delta} <= 1`. Can be a scalar or numpy array.

        *prof_params : array_like, optional
            Any additional array(s) necessary to specify the shape of the radial profile,
            e.g., halo concentration.

        Returns
        -------------
        p: array_like
            The fraction of the total mass enclosed
            within radius x, in :math:`M_{\odot}/h`;
            has the same dimensions as the input ``x``.

        Notes
        ------
        See :ref:`halo_profile_definitions` for derivations and implementation details.
        """
        x = np.atleast_1d(scaled_radius).astype(np.float64)
        enclosed_mass = np.zeros_like(x)

        for i in range(len(x)):
            enclosed_mass[i], _ = quad_integration(
                self._enclosed_dimensionless_mass_integrand,
                0.0,
                x[i],
                epsrel=1e-5,
                args=prof_params,
            )

        total, _ = quad_integration(
            self._enclosed_dimensionless_mass_integrand,
            0.0,
            1.0,
            epsrel=1e-5,
            args=prof_params,
        )

        return enclosed_mass / total
コード例 #4
0
def dimensionless_radial_velocity_dispersion(scaled_radius, halo_conc, gal_conc,
        profile_integration_tol=1e-4):
    r"""
    Analytical solution to the isotropic jeans equation for an NFW potential,
    rendered dimensionless via scaling by the virial velocity.

    :math:`\tilde{\sigma}^{2}_{r}(\tilde{r})\equiv\sigma^{2}_{r}(\tilde{r})/V_{\rm vir}^{2} = \frac{c^{2}\tilde{r}(1 + c\tilde{r})^{2}}{g(c)}\int_{c\tilde{r}}^{\infty}{\rm d}y\frac{g(y)}{y^{3}(1 + y)^{2}}`

    See :ref:`nfw_jeans_velocity_profile_derivations` for derivations and implementation details.

    Parameters
    -----------
    scaled_radius : array_like
        Length-Ngals numpy array storing the halo-centric distance
        *r* scaled by the halo boundary :math:`R_{\Delta}`, so that
        :math:`0 <= \tilde{r} \equiv r/R_{\Delta} <= 1`.

    halo_conc : float
        Concentration of the halo.

    Returns
    -------
    result : array_like
        Radial velocity dispersion profile scaled by the virial velocity.
        The returned result has the same dimension as the input ``scaled_radius``.
    """
    x = np.atleast_1d(scaled_radius).astype(np.float64)
    result = np.zeros_like(x)

    prefactor = gal_conc*gal_conc*x*(1. + gal_conc*x)**2/_g_integral(halo_conc)
    extra_args = halo_conc/gal_conc

    lower_limit = gal_conc*x
    upper_limit = float("inf")
    for i in range(len(x)):
        term1, _ = quad_integration(_jeans_integrand_term1,
            lower_limit[i], upper_limit, epsrel=profile_integration_tol,
            args=extra_args)
        term2, _ = quad_integration(_jeans_integrand_term2,
            lower_limit[i], upper_limit, epsrel=profile_integration_tol,
            args=extra_args)
        result[i] = term1 - term2

    return np.sqrt(result*prefactor)
コード例 #5
0
    def dimensionless_radial_velocity_dispersion(self, scaled_radius, *conc):
        """
        Analytical solution to the isotropic jeans equation for an NFW potential,
        rendered dimensionless via scaling by the virial velocity.

        :math:`\\tilde{\\sigma}^{2}_{r}(\\tilde{r})\\equiv\\sigma^{2}_{r}(\\tilde{r})/V_{\\rm vir}^{2} = \\frac{c^{2}\\tilde{r}(1 + c\\tilde{r})^{2}}{g(c)}\int_{c\\tilde{r}}^{\infty}{\\rm d}y\\frac{g(y)}{y^{3}(1 + y)^{2}}`

        See :ref:`nfw_jeans_velocity_profile_derivations` for derivations and implementation details.

        Parameters
        -----------
        scaled_radius : array_like
            Length-Ngals numpy array storing the halo-centric distance
            *r* scaled by the halo boundary :math:`R_{\\Delta}`, so that
            :math:`0 <= \\tilde{r} \\equiv r/R_{\\Delta} <= 1`.

        total_mass: array_like
            Length-Ngals numpy array storing the halo mass in :math:`M_{\odot}/h`.

        conc : float
            Concentration of the halo.

        Returns
        -------
        result : array_like
            Radial velocity dispersion profile scaled by the virial velocity.
            The returned result has the same dimension as the input ``scaled_radius``.
        """
        x = np.atleast_1d(scaled_radius).astype(np.float64)
        result = np.zeros_like(x)

        prefactor = conc*(conc*x)*(1. + conc*x)**2/self.g(conc)

        lower_limit = conc*x
        upper_limit = float("inf")
        for i in range(len(x)):
            term1, _ = quad_integration(self._jeans_integrand_term1,
                lower_limit[i], upper_limit, epsrel=1e-5)
            term2, _ = quad_integration(self._jeans_integrand_term2,
                lower_limit[i], upper_limit, epsrel=1e-5)
            result[i] = term1 - term2

        return np.sqrt(result*prefactor)
コード例 #6
0
    def dimensionless_radial_velocity_dispersion(self, scaled_radius, *conc):
        """
        Analytical solution to the isotropic jeans equation for an NFW potential, 
        rendered dimensionless via scaling by the virial velocity. 

        :math:`\\tilde{\\sigma}^{2}_{r}(\\tilde{r})\\equiv\\sigma^{2}_{r}(\\tilde{r})/V_{\\rm vir}^{2} = \\frac{c^{2}\\tilde{r}(1 + c\\tilde{r})^{2}}{g(c)}\int_{c\\tilde{r}}^{\infty}{\\rm d}y\\frac{g(y)}{y^{3}(1 + y)^{2}}`

        See :ref:`nfw_jeans_velocity_profile_derivations` for derivations and implementation details.  

        Parameters 
        -----------
        scaled_radius : array_like 
            Length-Ngals numpy array storing the halo-centric distance 
            *r* scaled by the halo boundary :math:`R_{\\Delta}`, so that 
            :math:`0 <= \\tilde{r} \\equiv r/R_{\\Delta} <= 1`.  

        total_mass: array_like
            Length-Ngals numpy array storing the halo mass in :math:`M_{\odot}/h`. 

        conc : float  
            Concentration of the halo. 

        Returns 
        -------
        result : array_like 
            Radial velocity dispersion profile scaled by the virial velocity. 
            The returned result has the same dimension as the input ``scaled_radius``. 
        """
        x = convert_to_ndarray(scaled_radius, dt = np.float64)
        result = np.zeros_like(x)

        prefactor = conc*(conc*x)*(1. + conc*x)**2/self.g(conc)

        lower_limit = conc*x
        upper_limit = float("inf")
        for i in range(len(x)):
            term1, _ = quad_integration(self._jeans_integrand_term1, 
                lower_limit[i], upper_limit, epsrel=1e-5)
            term2, _ = quad_integration(self._jeans_integrand_term2, 
                lower_limit[i], upper_limit, epsrel=1e-5)
            result[i] = term1 - term2 

        return np.sqrt(result*prefactor)
コード例 #7
0
    def cumulative_mass_PDF(self, scaled_radius, *prof_params):
        """
        The fraction of the total mass enclosed within dimensionless radius,

        :math:`P_{\\rm prof}(<\\tilde{r}) \equiv M_{\\Delta}(<\\tilde{r}) / M_{\\Delta},`
        where :math:`\\tilde{r} \\equiv r / R_{\\Delta}`.

        Parameters
        -----------
        scaled_radius : array_like
            Halo-centric distance *r* scaled by the halo boundary :math:`R_{\\Delta}`, so that
            :math:`0 <= \\tilde{r} \\equiv r/R_{\\Delta} <= 1`. Can be a scalar or numpy array.

        *prof_params : array_like, optional
            Any additional array(s) necessary to specify the shape of the radial profile,
            e.g., halo concentration.

        Returns
        -------------
        p: array_like
            The fraction of the total mass enclosed
            within radius x, in :math:`M_{\odot}/h`;
            has the same dimensions as the input ``x``.

        Notes
        ------
        See :ref:`halo_profile_definitions` for derivations and implementation details.
        """
        x = convert_to_ndarray(scaled_radius, dt=np.float64)
        enclosed_mass = np.zeros_like(x)

        for i in range(len(x)):
            enclosed_mass[i], _ = quad_integration(
                self._enclosed_dimensionless_mass_integrand, 0., x[i], epsrel=1e-5,
                args=prof_params)

        total, _ = quad_integration(
                self._enclosed_dimensionless_mass_integrand, 0., 1.0, epsrel=1e-5,
                args=prof_params)

        return enclosed_mass / total
コード例 #8
0
def _nfw_velocity_dispersion_table(scaled_radius_table, conc, tol=1e-5):
    """
    """
    x = np.atleast_1d(scaled_radius_table).astype(np.float64)
    result = np.zeros_like(x)

    prefactor = conc * (conc * x) * (1. + conc * x)**2 / _g_integral(conc)

    lower_limit = conc * x
    upper_limit = float("inf")
    for i in range(len(x)):
        term1, __ = quad_integration(_jeans_integrand_term1,
                                     lower_limit[i],
                                     upper_limit,
                                     epsrel=tol)
        term2, __ = quad_integration(_jeans_integrand_term2,
                                     lower_limit[i],
                                     upper_limit,
                                     epsrel=tol)
        result[i] = term1 - term2

    dimless_velocity_table = np.sqrt(result * prefactor)
    return dimless_velocity_table
コード例 #9
0
ファイル: profile_models.py プロジェクト: parejkoj/halotools
    def cumulative_mass_PDF(self, x, *args):
        """
        The fraction of the total mass enclosed within 
        dimensionless radius :math:`x = r / R_{\\rm halo}`.

        Parameters 
        -----------
        x : array_like 
            Halo-centric distance scaled by the halo boundary, so that 
            :math:`0 <= x <= 1`. Can be a scalar or numpy array

        args : array_like, optional 
            Any additional array(s) necessary to specify the shape of the radial profile, 
            e.g., halo concentration.         
            
        Returns
        -------------
        p: array_like
            The fraction of the total mass enclosed 
            within radius x, in :math:`M_{\odot}/h`; 
            has the same dimensions as the input ``x``.
        """
        x = convert_to_ndarray(x)
        x = x.astype(np.float64)
        enclosed_mass = np.zeros_like(x)

        for i in range(len(x)):
            enclosed_mass[i], _ = quad_integration(
                self._enclosed_dimensionless_mass_integrand, 0., x[i], epsrel = 1e-5, 
                args = args)
    
        total, _ = quad_integration(
                self._enclosed_dimensionless_mass_integrand, 0., 1.0, epsrel = 1e-5, 
                args = args)

        return enclosed_mass / total