
    HR-e                    z   d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZmZmZ d dlZd dlmZmZ d dlmZ d dlmZ d dlmZmZ d d	lmZm Z m!Z! d d
l"m#Z#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* ddgZ+ddgiZ,erd dl-m.Z. e&rd dl/m0Z0 nd Z0ej1        ej2        ej3        z  z  4                    dej2        z            Z5ej2        4                    ej6                  Z7dde	z  ej8        z  z  j9        j:        Z;dej<        z  4                    ej=                  Z>dej<        z  4                    ej?                  Z@dejA        z  ejB        dz  z  j9        j:        ZCejD        4                    ejE        ejF        z            ZG edd          ZH edd          ZI G d de          ZJ G d de          ZKdS )    )annotationsN)abstractmethod)expfloorlogpisqrt)Number)TYPE_CHECKINGAnyTypeVar)infsin)	CosmologyFlatCosmologyMixin)	Parameter_validate_non_negative_validate_with_unit)aszarrvectorize_redshift_method)	HAS_SCIPY)lazyproperty)AstropyUserWarningFLRWFlatFLRWMixin*scipy)Mapping)quadc                      t          d          )Nz!No module named 'scipy.integrate')ModuleNotFoundError)argskwargss     ;lib/python3.11/site-packages/astropy/cosmology/flrw/base.pyr   r   (   s    !"EFFF          ?            _FLRWT)bound_FlatFLRWMixinTc                      e Zd ZdZ eddd          Z edd          Z ed	d
          Z eddd          Z edd          Z	 edd e
j                              Z ed          Zde
j        z  dde
j        z  dfddd fdZej        d             Zej        d             Zed             Zed             Zed             Zed             Zed             Zed             Zed              Zed!             Zed"             Zed#             Zed$             Zed%             Zed&             Z d' Z!d( Z"d) Z#d* Z$d+ Z%d, Z&d- Z'd. Z(d/ Z)d0 Z*d1 Z+d2 Z,d3 Z-d4 Z.d5 Z/d6 Z0d7 Z1d8 Z2d9 Z3d: Z4d; Z5d< Z6d= Z7e8d>             Z9d? Z:d@ Z;dA Z<e8dB             Z=dC Z>dD Z?dE Z@ e8dFG          dH             ZAdI ZBdJ ZCdK ZDdL ZEdM ZFdN ZGe8dO             ZHdP ZIdQ ZJdR ZKdS ZLdT ZMdU ZNdV ZO xZPS )Wr   a	  
    A class describing an isotropic and homogeneous
    (Friedmann-Lemaitre-Robertson-Walker) cosmology.

    This is an abstract base class -- you cannot instantiate examples of this
    class, but must work with one of its subclasses, such as
    :class:`~astropy.cosmology.LambdaCDM` or :class:`~astropy.cosmology.wCDM`.

    Parameters
    ----------
    H0 : float or scalar quantity-like ['frequency']
        Hubble constant at z = 0.  If a float, must be in [km/sec/Mpc].

    Om0 : float
        Omega matter: density of non-relativistic matter in units of the
        critical density at z=0. Note that this does not include massive
        neutrinos.

    Ode0 : float
        Omega dark energy: density of dark energy in units of the critical
        density at z=0.

    Tcmb0 : float or scalar quantity-like ['temperature'], optional
        Temperature of the CMB z=0. If a float, must be in [K]. Default: 0 [K].
        Setting this to zero will turn off both photons and neutrinos
        (even massive ones).

    Neff : float, optional
        Effective number of Neutrino species. Default 3.04.

    m_nu : quantity-like ['energy', 'mass'] or array-like, optional
        Mass of each neutrino species in [eV] (mass-energy equivalency enabled).
        If this is a scalar Quantity, then all neutrino species are assumed to
        have that mass. Otherwise, the mass of each species. The actual number
        of neutrino species (and hence the number of elements of m_nu if it is
        not scalar) must be the floor of Neff. Typically this means you should
        provide three neutrino masses unless you are considering something like
        a sterile neutrino.

    Ob0 : float or None, optional
        Omega baryons: density of baryonic matter in units of the critical
        density at z=0.  If this is set to None (the default), any computation
        that requires its value will raise an exception.

    name : str or None (optional, keyword-only)
        Name for this cosmological object.

    meta : mapping or None (optional, keyword-only)
        Metadata for the cosmology, e.g., a reference.

    Notes
    -----
    Class instances are immutable -- you cannot change the parameters' values.
    That is, all of the above attributes (except meta) are read only.

    For details on how to create performant custom subclasses, see the
    documentation on :ref:`astropy-cosmology-fast-integrals`.
    z7Hubble constant as an `~astropy.units.Quantity` at z=0.z
km/(s Mpc)scalar)docunit	fvalidatez5Omega matter; matter density/critical density at z=0.znon-negative)r0   r2   z?Omega dark energy; dark energy density/critical density at z=0.floatz;Temperature of the CMB as `~astropy.units.Quantity` at z=0.Kelvinz%Number of effective neutrino species.zMass of neutrino species.eV)r0   r1   equivalenciesz>Omega baryon; baryonic matter density/critical density at z=0.)r0           gRQ@Nnamemetac                  t                                          ||	           || _        || _        || _        || _        || _        || _        || _        |d n| j	        | j
        z
  | _        | j        j        dz  | _        t          j        | j        z                      t$          j                  | _        | j        j        t*          z  }
t,          |
z  t$          j        z  | _        t2          |
dz  z  }|t$          j        t$          j        dz  z  z  | _        t:          | j        j        dz  z  | j        j        z  | _        d| j        z  | _         | j!        +d| _"        d | _#        d| _$        d | _%        d x| _&        | _'        ntQ          | j)                  | _"        | j)        | j"        z  | _#        tU          j+        | j!        j        dk              d         }|j,        dk    | _$        t[          |          | _&        | j$        r| j!        |         j        nd | _%        | j"        | j&        z
  | _'        | j$        rd| j%        t\          | j         z  z  }|j        | _/        | j/        0                                | _1        | j        | 2                    d          z  | _3        n%d	| j)        z  | j        z  | _3        d x| _/        | _1        d
| j	        z
  | j4        z
  | j        z
  | j3        z
  | _5        | j6        | _7        d| _8        d S )Nr8   g      Y@   r'   r*   grv}+?r   FC?r&    )9super__init__H0Om0Ode0Tcmb0Neffm_nuOb0_Om0_Ob0_Odm0_H0value_hconstctouMpc_hubble_distance_H0units_to_invs_sec_to_GyrGyr_hubble_time_critdens_constgcm_critical_density0_a_B_c2_Tcmb0_Ogamma0_Tnu0_m_nu_nneutrinos_neff_per_nu
_massivenu_massivenu_mass_nmassivenu_nmasslessnur   _Neffnpnonzerosizelen_kB_evK_nu_ytolist
_nu_y_listnu_relative_density_Onu0_Ode0_Ok0	inv_efunc_inv_efunc_scalar_inv_efunc_scalar_args)selfrA   rB   rC   rD   rE   rF   rG   r9   r:   H0_scd0valuemassivenu_y	__class__s                 r$   r@   zFLRW.__init__   s    	d... 	
		 ![TTty49/D
 (.5(!&48!3 7 7 > >x~ 00(4/AE9 #T1W,"*acAD!Gm";  $+"3Q"669P9VV
 ($+5
 : D $D#DO#'D 377Dt00$TZ00D !%
T-= =D j!1A!566q9G%lQ.DO"7||D-1_F
7#))$   !% 043C CD ? 
	0'7TZ+?@DDJ"j//11DO)A)A!)D)DDDJJ
 '3dmCDJ+//DJ $)Odj04=@4:M	 "&&(###r%   c                d    ||S t          | ||          }|| j        k    rt          d          |S )zCValidate baryon density to None or positive float > matter density.Nz=baryonic density can not be larger than total matter density.)r   rB   
ValueError)rw   paramrL   s      r$   rG   zFLRW.Ob0  sH     =L&tUE::48O   r%   c                r   t          | j                  x}dk    s| j        j        dk    rdS t	          | ||          }|j        d|ffvr#t          d| dt          |           d          t          j	        |j        dk               rt          d          |j
        rt          j        |||          }|S )	zValidate neutrino masses to right value, units, and shape.

        There are no neutrinos if floor(Neff) or Tcmb0 are 0.
        The number of neutrinos must match floor(Neff).
        Neutrino masses cannot be negative.
        r   Nr>   u2   unexpected number of neutrino masses — expected z, got .z-invalid (negative) neutrino mass encountered.)shape)r   rg   r]   rL   r   r   r~   rk   rh   anyisscalar	full_like)rw   r   rL   
nneutrinoss       r$   rF   z	FLRW.m_nu  s      
+++J11T[5F!5K5K4 $D%77 ;rJ=111<&< <.1%jj< < <   VEK!O$$ 	NLMMM > 	ALZ@@@Er%   c                H    t          | j        dk    o
| j        dk              S )z-Return bool; `True` if the cosmology is flat.r7   r&   )boolrs   Otot0rw   s    r$   is_flatzFLRW.is_flat5  s%     TY#%>DJ#,=???r%   c                P    | j         | j        z   | j        z   | j        z   | j        z   S )7Omega total; the total density/critical density at z=0.)rH   r^   rq   rr   rs   r   s    r$   r   z
FLRW.Otot0:  s(     y4=(4:5
BTYNNr%   c                    | j         S )z?Omega dark matter; dark matter density/critical density at z=0.)rJ   r   s    r$   Odm0z	FLRW.Odm0?       zr%   c                    | j         S )zIOmega curvature; the effective curvature density/critical density at z=0.)rs   r   s    r$   Ok0zFLRW.Ok0D  s     yr%   c                    | j         S )z]
        Temperature of the neutrino background as `~astropy.units.Quantity` at z=0.
        )r_   r   s    r$   Tnu0z	FLRW.Tnu0I  s    
 zr%   c                4    | j         j        dk    rdS | j        S )z?Does this cosmology have at least one massive neutrino species?r   F)r_   rL   rc   r   s    r$   has_massive_nuzFLRW.has_massive_nuP  s!     :q  5r%   c                    | j         S )z:Dimensionless Hubble constant: h = H_0 / 100 [km/sec/Mpc].)rM   r   s    r$   hzFLRW.hW  s     wr%   c                    | j         S )z)Hubble time as `~astropy.units.Quantity`.)rW   r   s    r$   hubble_timezFLRW.hubble_time\  s       r%   c                    | j         S )z-Hubble distance as `~astropy.units.Quantity`.)rS   r   s    r$   hubble_distancezFLRW.hubble_distancea  s     $$r%   c                    | j         S )z5Critical density as `~astropy.units.Quantity` at z=0.)r[   r   s    r$   critical_density0zFLRW.critical_density0f  s     &&r%   c                    | j         S )z<Omega gamma; the density/critical density of photons at z=0.)r^   r   s    r$   Ogamma0zFLRW.Ogamma0k  s     }r%   c                    | j         S )z;Omega nu; the density/critical density of neutrinos at z=0.)rq   r   s    r$   Onu0z	FLRW.Onu0p  r   r%   c                     t          d          )a  The dark energy equation of state.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        w : ndarray or float
            The dark energy equation of state.
            `float` if scalar input.

        Notes
        -----
        The dark energy equation of state is defined as
        :math:`w(z) = P(z)/\rho(z)`, where :math:`P(z)` is the pressure at
        redshift z and :math:`\rho(z)` is the density at redshift z, both in
        units where c=1.

        This must be overridden by subclasses.
        zw(z) is not implemented)NotImplementedErrorrw   zs     r$   wzFLRW.ww  s    0 "";<<<r%   c                    |                      |          |                     |          z   |                     |          z   |                     |          z   |                     |          z   S )a  The total density parameter at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts.

        Returns
        -------
        Otot : ndarray or float
            The total density relative to the critical density at each redshift.
            Returns float if input scalar.
        )OmOgammaOnuOdeOkr   s     r$   Ototz	FLRW.Otot  sQ     wwqzzDKKNN*TXXa[[8488A;;FQRSSr%   c                r    t          |          }| j        |dz   dz  z  |                     |          dz  z  S )ae  
        Return the density parameter for non-relativistic matter
        at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Om : ndarray or float
            The density of non-relativistic matter relative to the critical
            density at each redshift.
            Returns `float` if the input is scalar.

        Notes
        -----
        This does not include neutrinos, even if non-relativistic at the
        redshift of interest; see `Onu`.
        r&   r'   r<   )r   rH   rt   r   s     r$   r   zFLRW.Om  s:    , 1IIyAG>)DNN1,=,=,BBBr%   c                    | j         t          d          t          |          }| j         |dz   dz  z  |                     |          dz  z  S )a	  Return the density parameter for baryonic matter at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Ob : ndarray or float
            The density of baryonic matter relative to the critical density at
            each redshift.
            Returns `float` if the input is scalar.

        Raises
        ------
        ValueError
            If ``Ob0`` is `None`.
        Nz)Baryon density not set for this cosmologyr&   r'   r<   )rI   r~   r   rt   r   s     r$   ObzFLRW.Ob  sQ    ( 9HIII1IIyAG>)DNN1,=,=,BBBr%   c                    | j         t          d          t          |          }| j         |dz   dz  z  |                     |          dz  z  S )a  Return the density parameter for dark matter at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Odm : ndarray or float
            The density of non-relativistic dark matter relative to the
            critical density at each redshift.
            Returns `float` if the input is scalar.

        Raises
        ------
        ValueError
            If ``Ob0`` is `None`.

        Notes
        -----
        This does not include neutrinos, even if non-relativistic at the
        redshift of interest.
        NzSBaryonic density not set for this cosmology, unclear meaning of dark matter densityr&   r'   r<   )rJ   r~   r   rt   r   s     r$   OdmzFLRW.Odm  s[    2 :9   1IIzQWN*T^^A->->!-CCCr%   c                    t          |          }| j        dk    r+t          |d          rt          j        |j                  ndS | j        |dz   dz  z  |                     |          dz  z  S )a  
        Return the equivalent density parameter for curvature at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Ok : ndarray or float
            The equivalent density parameter for curvature at each redshift.
            Returns `float` if the input is scalar.
        r   r   r7   r&   r<   )r   rs   hasattrrh   zerosr   rt   r   s     r$   r   zFLRW.Ok  sk     1II9>>(/7(;(;D28AG$$$DyAG>)DNN1,=,=,BBBr%   c                    t          |          }| j        dk    r+t          |d          rt          j        |j                  ndS | j        |                     |          z  |                     |          dz  z  S )a  Return the density parameter for dark energy at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Ode : ndarray or float
            The density of non-relativistic matter relative to the critical
            density at each redshift.
            Returns `float` if the input is scalar.
        r   r   r7   r<   )r   rr   r   rh   r   r   de_density_scalert   r   s     r$   r   zFLRW.Ode  sq     1II:??(/7(;(;D28AG$$$DzD11!444t~~a7H7HA7MMMr%   c                r    t          |          }| j        |dz   dz  z  |                     |          dz  z  S )a  Return the density parameter for photons at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Ogamma : ndarray or float
            The energy density of photons relative to the critical density at
            each redshift.
            Returns `float` if the input is scalar.
        r&   r*   r<   )r   r^   rt   r   s     r$   r   zFLRW.Ogamma  s:     1II}CA~-q0A0AQ0FFFr%   c                    t          |          }| j        dk    r+t          |d          rt          j        |j                  ndS |                     |          |                     |          z  S )a  Return the density parameter for neutrinos at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Onu : ndarray or float
            The energy density of neutrinos relative to the critical density at
            each redshift. Note that this includes their kinetic energy (if
            they have mass), so it is not equal to the commonly used
            :math:`\sum \frac{m_{\nu}}{94 eV}`, which does not include
            kinetic energy.
            Returns `float` if the input is scalar.
        r   r   r7   )r   rq   r   rh   r   r   r   rp   r   s     r$   r   zFLRW.Onu.  sc    $ 1II:??(/7(;(;D28AG$$$D{{1~~ 8 8 ; ;;;r%   c                6    | j         t          |          dz   z  S )aI  Return the CMB temperature at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Tcmb : `~astropy.units.Quantity` ['temperature']
            The temperature of the CMB in K.
        r&   )r]   r   r   s     r$   Tcmbz	FLRW.TcmbE  s     {fQii#o..r%   c                6    | j         t          |          dz   z  S )ad  Return the neutrino temperature at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        Tnu : `~astropy.units.Quantity` ['temperature']
            The temperature of the cosmic neutrino background in K.
        r&   )r_   r   r   s     r$   TnuzFLRW.TnuT  s     zVAYY_--r%   c                \   d}t          |          }| j        s6|| j        z  t          |d          rt	          j        |j                  ndz  S d}d}d}| j        dt	          j        |d          z   z  }d||z  |z  z   |z  }|	                    d          | j
        z   }|| j        z  |z  S )	a  Neutrino density function relative to the energy density in photons.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        f : ndarray or float
            The neutrino density scaling factor relative to the density in
            photons at each redshift.
            Only returns `float` if z is scalar.

        Notes
        -----
        The density in neutrinos is given by

        .. math::

           \rho_{\nu} \left(a\right) = 0.2271 \, N_{eff} \,
           f\left(m_{\nu} a / T_{\nu 0} \right) \,
           \rho_{\gamma} \left( a \right)

        where

        .. math::

           f \left(y\right) = \frac{120}{7 \pi^4}
           \int_0^{\infty} \, dx \frac{x^2 \sqrt{x^2 + y^2}}
           {e^x + 1}

        assuming that all neutrino species have the same mass.
        If they have different masses, a similar term is calculated for each
        one. Note that ``f`` has the asymptotic behavior :math:`f(0) = 1`. This
        method returns :math:`0.2271 f` using an analytical fitting formula
        given in Komatsu et al. 2011, ApJS 192, 18.
        r=   r   r&   gHzG?g'|?gTN?)axis)r   rc   rg   r   rh   onesr   rm   expand_dimssumrf   rb   )	rw   r   prefacpinvpk	curr_nu_yrel_mass_perrel_masss	            r$   rp   zFLRW.nu_relative_densityc  s    ^  1II 	#71g;N;N'Wrwqw'7'7'7TWX
 J#qr(B(B(B"BC	q9}22t;##B''$*;;))H44r%   c                R    d|                      t          |          dz
            z   S )a  Internal convenience function for w(z) integral (eq. 5 of [1]_).

        Parameters
        ----------
        ln1pz : `~numbers.Number` or scalar ndarray
            Assumes scalar input, since this should only be called inside an
            integral.

        References
        ----------
        .. [1] Linder, E. (2003). Exploring the Expansion History of the
               Universe. Phys. Rev. Lett., 90, 091301.
        r&   )r   r   )rw   ln1pzs     r$   _w_integrandzFLRW._w_integrand  s&     TVVCJJ,----r%   c                N    t          |          }t          |t          t          j        f          s7t          j         fd|D                       }t          j        d|z            S t           j        dt          |dz                       d         }t          d|z            S )a{  Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        I : ndarray or float
            The scaling of the energy density of dark energy with redshift.
            Returns `float` if the input is scalar.

        Notes
        -----
        The scaling factor, I, is defined by :math:`\rho(z) = \rho_0 I`,
        and is given by

        .. math::

           I = \exp \left( 3 \int_{a}^1 \frac{ da^{\prime} }{ a^{\prime} }
                          \left[ 1 + w\left( a^{\prime} \right) \right] \right)

        The actual integral used is rewritten from [1]_ to be in terms of z.

        It will generally helpful for subclasses to overload this method if
        the integral can be done analytically for the particular dark
        energy equation of state that they implement.

        References
        ----------
        .. [1] Linder, E. (2003). Exploring the Expansion History of the
               Universe. Phys. Rev. Lett., 90, 091301.
        c           
     h    g | ].}t          j        d t          d|z                       d          /S )r   r)   )r   r   r   ).0redshiftrw   s     r$   
<listcomp>z)FLRW.de_density_scale.<locals>.<listcomp>  s9    TTThd'CH,=,=>>qATTTr%   r'   r   r&   )
r   
isinstancer
   rh   genericarrayr   r   r   r   )rw   r   ivals   `  r$   r   zFLRW.de_density_scale  s    R 1II!fbj122 	!8TTTTRSTTT D 6!d(###)1c!c'll;;A>Dq4x== r%   c                (   | j         | j        s| j        n| j         |                     |          z  z   }t	          |          dz   }t          j        |dz  ||z  | j        z   |z  | j        z   z  | j	        | 
                    |          z  z             S )a\  Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        E : ndarray or float
            The redshift scaling of the Hubble constant.
            Returns `float` if the input is scalar.
            Defined such that :math:`H(z) = H_0 E(z)`.

        Notes
        -----
        It is not necessary to override this method, but if de_density_scale
        takes a particularly simple form, it may be advantageous to.
        r&   r<   )r^   rc   rq   rp   r   rh   r	   rH   rs   rr   r   rw   r   Orzp1s       r$   efuncz
FLRW.efunc  s    ( ]?=DJJ!9!9!!<!<<

 Qii#owFrCx$)+s2TY>?j4003334
 
 	
r%   c                
   | j         | j        s| j        n| j         |                     |          z  z   }t	          |          dz   }|dz  ||z  | j        z   |z  | j        z   z  | j        |                     |          z  z   dz  S )a]  Inverse of ``efunc``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        E : ndarray or float
            The redshift scaling of the inverse Hubble constant.
            Returns `float` if the input is scalar.
        r&   r<   g      )	r^   rc   rq   rp   r   rH   rs   rr   r   r   s       r$   rt   zFLRW.inv_efunc
  s     ]?=DJJ!9!9!!<!<<

 Qii#o FrCx$)+s2TY>?j4003334 	r%   c                4     | j         |g| j        R  |dz   z  S )a  Integrand of the lookback time (equation 30 of [1]_).

        Parameters
        ----------
        z : float
            Input redshift.

        Returns
        -------
        I : float
            The integrand for the lookback time.

        References
        ----------
        .. [1] Hogg, D. (1999). Distance measures in cosmology, section 11.
               arXiv e-prints, astro-ph/9905116.
        r&   )ru   rv   r   s     r$   _lookback_time_integrand_scalarz$FLRW._lookback_time_integrand_scalar%  s+    $ &t%aF$*EFFF!c'RRr%   c                V    t          |          }|                     |          |dz   z  S )a  Integrand of the lookback time (equation 30 of [1]_).

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        I : float or array
            The integrand for the lookback time.

        References
        ----------
        .. [1] Hogg, D. (1999). Distance measures in cosmology, section 11.
               arXiv e-prints, astro-ph/9905116.
        r&   r   rt   r   s     r$   lookback_time_integrandzFLRW.lookback_time_integrand9  s*    $ 1II~~a  AG,,r%   c                >    | j         }|dz   dz   | j        |g|R  z  S )a  Integrand of the absorption distance [1]_.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        X : float
            The integrand for the absorption distance.

        References
        ----------
        .. [1] Hogg, D. (1999). Distance measures in cosmology, section 11.
               arXiv e-prints, astro-ph/9905116.
        r&   r<   )rv   ru   )rw   r   r"   s      r$   _abs_distance_integrand_scalarz#FLRW._abs_distance_integrand_scalarN  s5    $ *CA~ 6 6q @4 @ @ @@@r%   c                \    t          |          }|dz   dz  |                     |          z  S )a  Integrand of the absorption distance [1]_.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        X : float or array
            The integrand for the absorption distance.

        References
        ----------
        .. [1] Hogg, D. (1999). Distance measures in cosmology, section 11.
               arXiv e-prints, astro-ph/9905116.
        r&   r<   r   r   s     r$   abs_distance_integrandzFLRW.abs_distance_integrandc  s.    $ 1IICA~q 1 111r%   c                <    | j         |                     |          z  S )aM  Hubble parameter (km/s/Mpc) at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        H : `~astropy.units.Quantity` ['frequency']
            Hubble parameter at each input redshift.
        )rK   r   r   s     r$   HzFLRW.Hx  s     x$**Q--''r%   c                ,    dt          |          dz   z  S )a  Scale factor at redshift ``z``.

        The scale factor is defined as :math:`a = 1 / (1 + z)`.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        a : ndarray or float
            Scale factor at each input redshift.
            Returns `float` if the input is scalar.
        r&   )r   r   s     r$   scale_factorzFLRW.scale_factor  s      fQii#o&&r%   c                ,    |                      |          S )a)  Lookback time in Gyr to redshift ``z``.

        The lookback time is the difference between the age of the Universe now
        and the age at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : `~astropy.units.Quantity` ['time']
            Lookback time in Gyr to each input redshift.

        See Also
        --------
        z_at_value : Find the redshift corresponding to a lookback time.
        )_lookback_timer   s     r$   lookback_timezFLRW.lookback_time  s    ( ""1%%%r%   c                <    | j         |                     |          z  S )a  Lookback time in Gyr to redshift ``z``.

        The lookback time is the difference between the age of the Universe now
        and the age at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : `~astropy.units.Quantity` ['time']
            Lookback time in Gyr to each input redshift.
        )rW   _integral_lookback_timer   s     r$   r   zFLRW._lookback_time  s        4#?#?#B#BBBr%   c               :    t          | j        d|          d         S )a  Lookback time to redshift ``z``. Value in units of Hubble time.

        The lookback time is the difference between the age of the Universe now
        and the age at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : float or ndarray
            Lookback time to each input redshift in Hubble time units.
            Returns `float` if input scalar, `~numpy.ndarray` otherwise.
        r   )r   r   r   s     r$   r   zFLRW._integral_lookback_time  s    $ D8!Q??BBr%   c                    |                      |          t          j        z                      t          j                  S )a  
        The lookback distance is the light travel time distance to a given
        redshift. It is simply c * lookback_time. It may be used to calculate
        the proper distance between two redshifts, e.g. for the mean free path
        to ionizing radiation.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Lookback distance in Mpc
        )r   rN   rO   rP   rQ   rR   r   s     r$   lookback_distancezFLRW.lookback_distance  s/    " ""1%%/33AE:::r%   c                ,    |                      |          S )a  Age of the universe in Gyr at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : `~astropy.units.Quantity` ['time']
            The age of the universe in Gyr at each input redshift.

        See Also
        --------
        z_at_value : Find the redshift corresponding to an age.
        )_ager   s     r$   agezFLRW.age  s    " yy||r%   c                <    | j         |                     |          z  S )a  Age of the universe in Gyr at redshift ``z``.

        This internal function exists to be re-defined for optimizations.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : `~astropy.units.Quantity` ['time']
            The age of the universe in Gyr at each input redshift.
        )rW   _integral_ager   s     r$   r   z	FLRW._age  s       4#5#5a#8#888r%   c               D    t          | j        |t                    d         S )aE  Age of the universe at redshift ``z``. Value in units of Hubble time.

        Calculated using explicit integration.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        t : float or ndarray
            The age of the universe at each input redshift in Hubble time units.
            Returns `float` if input scalar, `~numpy.ndarray` otherwise.

        See Also
        --------
        z_at_value : Find the redshift corresponding to an age.
        r   )r   r   r   r   s     r$   r   zFLRW._integral_age  s    * D8!SAA!DDr%   c                B    | j         |                     |          dz  z  S )aV  Critical density in grams per cubic cm at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        rho : `~astropy.units.Quantity`
            Critical density in g/cm^3 at each input redshift.
        r<   )r[   r   r   s     r$   critical_densityzFLRW.critical_density#  s!     &$**Q--A)===r%   c                .    |                      d|          S )a  Comoving line-of-sight distance in Mpc at a given redshift.

        The comoving distance along the line-of-sight between two objects
        remains constant with time for objects in the Hubble flow.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Comoving distance in Mpc to each input redshift.
        r   )_comoving_distance_z1z2r   s     r$   comoving_distancezFLRW.comoving_distance2  s      ++Aq111r%   c                .    |                      ||          S )a$  
        Comoving line-of-sight distance in Mpc between objects at redshifts
        ``z1`` and ``z2``.

        The comoving distance along the line-of-sight between two objects
        remains constant with time for objects in the Hubble flow.

        Parameters
        ----------
        z1, z2 : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Comoving distance in Mpc between each input redshift.
        ) _integral_comoving_distance_z1z2rw   z1z2s      r$   r   zFLRW._comoving_distance_z1z2D  s    $ 44R<<<r%   r<   )ninc               H    t          | j        ||| j                  d         S )a`  
        Comoving line-of-sight distance between objects at redshifts ``z1`` and
        ``z2``. Value in Mpc.

        The comoving distance along the line-of-sight between two objects
        remains constant with time for objects in the Hubble flow.

        Parameters
        ----------
        z1, z2 : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts.

        Returns
        -------
        d : float or ndarray
            Comoving distance in Mpc between each input redshift.
            Returns `float` if input scalar, `~numpy.ndarray` otherwise.
        )r"   r   )r   ru   rv   r   s      r$   '_integral_comoving_distance_z1z2_scalarz,FLRW._integral_comoving_distance_z1z2_scalarX  s'    ( D*B9TUUUVWXXr%   c                >    | j         |                     ||          z  S )a  
        Comoving line-of-sight distance in Mpc between objects at redshifts
        ``z1`` and ``z2``. The comoving distance along the line-of-sight
        between two objects remains constant with time for objects in the
        Hubble flow.

        Parameters
        ----------
        z1, z2 : Quantity-like ['redshift'] or array-like
            Input redshifts.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Comoving distance in Mpc between each input redshift.
        )rS   r  r   s      r$   r   z%FLRW._integral_comoving_distance_z1z2n  s$    " $t'S'STVXZ'['[[[r%   c                .    |                      d|          S )a  Comoving transverse distance in Mpc at a given redshift.

        This value is the transverse comoving distance at redshift ``z``
        corresponding to an angular separation of 1 radian. This is the same as
        the comoving distance if :math:`\Omega_k` is zero (as in the current
        concordance Lambda-CDM model).

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Comoving transverse distance in Mpc at each input redshift.

        Notes
        -----
        This quantity is also called the 'proper motion distance' in some texts.
        r   )"_comoving_transverse_distance_z1z2r   s     r$   comoving_transverse_distancez!FLRW.comoving_transverse_distance  s    , 66q!<<<r%   c                <   | j         }|                     ||          }|dk    r|S t          t          |                    }| j        }|dk    r*||z  t          j        ||j        z  |j        z            z  S ||z  t          ||j        z  |j        z            z  S )a	  Comoving transverse distance in Mpc between two redshifts.

        This value is the transverse comoving distance at redshift ``z2`` as
        seen from redshift ``z1`` corresponding to an angular separation of
        1 radian. This is the same as the comoving distance if :math:`\Omega_k`
        is zero (as in the current concordance Lambda-CDM model).

        Parameters
        ----------
        z1, z2 : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Comoving transverse distance in Mpc between input redshift.

        Notes
        -----
        This quantity is also called the 'proper motion distance' in some texts.
        r   )	rs   r   r	   absrS   rh   sinhrL   r   )rw   r  r  r   dcsqrtOk0dhs          r$   r  z'FLRW._comoving_transverse_distance_z1z2  s    , i))"b11!88Is3xx.."77<"''BH*<rx*G"H"HHH<#g&828&C"D"DDDr%   c                V    t          |          }|                     |          |dz   z  S )a  Angular diameter distance in Mpc at a given redshift.

        This gives the proper (sometimes called 'physical') transverse
        distance corresponding to an angle of 1 radian for an object
        at redshift ``z`` ([1]_, [2]_, [3]_).

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Angular diameter distance in Mpc at each input redshift.

        References
        ----------
        .. [1] Weinberg, 1972, pp 420-424; Weedman, 1986, pp 421-424.
        .. [2] Weedman, D. (1986). Quasar astronomy, pp 65-67.
        .. [3] Peebles, P. (1993). Principles of Physical Cosmology, pp 325-327.
        r&   r   r	  r   s     r$   angular_diameter_distancezFLRW.angular_diameter_distance  s,    . 1II0033q3w??r%   c                V    t          |          }|dz   |                     |          z  S )a  Luminosity distance in Mpc at redshift ``z``.

        This is the distance to use when converting between the bolometric flux
        from an object at redshift ``z`` and its bolometric luminosity [1]_.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            Luminosity distance in Mpc at each input redshift.

        See Also
        --------
        z_at_value : Find the redshift corresponding to a luminosity distance.

        References
        ----------
        .. [1] Weinberg, 1972, pp 420-424; Weedman, 1986, pp 60-62.
        r&   r  r   s     r$   luminosity_distancezFLRW.luminosity_distance  s,    0 1IIC4<<Q????r%   c                    t          |          t          |          }}t          j        ||k               r!t          j        d| d| dt
                     |                     ||          |dz   z  S )a  Angular diameter distance between objects at 2 redshifts.

        Useful for gravitational lensing, for example computing the angular
        diameter distance between a lensed galaxy and the foreground lens.

        Parameters
        ----------
        z1, z2 : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts. For most practical applications such as
            gravitational lensing, ``z2`` should be larger than ``z1``. The
            method will work for ``z2 < z1``; however, this will return
            negative distances.

        Returns
        -------
        d : `~astropy.units.Quantity`
            The angular diameter distance between each input redshift pair.
            Returns scalar if input is scalar, array else-wise.
        zSecond redshift(s) z2 (z%) is less than first redshift(s) z1 (z).r&   )r   rh   r   warningswarnr   r  r   s      r$   angular_diameter_distance_z1z2z#FLRW.angular_diameter_distance_z1z2  s    ( VBZZB6"r'?? 	M*" * *#%* * *"  
 66r2>>"s(KKr%   c               :    t          | j        d|          d         S )a6  Absorption distance at redshift ``z``.

        This is used to calculate the number of objects with some cross section
        of absorption and number density intersecting a sightline per unit
        redshift path ([1]_, [2]_).

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : float or ndarray
            Absorption distance (dimensionless) at each input redshift.
            Returns `float` if input scalar, `~numpy.ndarray` otherwise.

        References
        ----------
        .. [1] Hogg, D. (1999). Distance measures in cosmology, section 11.
               arXiv e-prints, astro-ph/9905116.
        .. [2] Bahcall, John N. and Peebles, P.J.E. 1969, ApJ, 156L, 7B
        r   )r   r   r   s     r$   absorption_distancezFLRW.absorption_distance  s    2 D7A>>qAAr%   c                    dt          j        t          |                     |          j                            z  dz   }t          j        |t
          j                  S )aF  Distance modulus at redshift ``z``.

        The distance modulus is defined as the (apparent magnitude - absolute
        magnitude) for an object at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        distmod : `~astropy.units.Quantity` ['length']
            Distance modulus at each input redshift, in magnitudes.

        See Also
        --------
        z_at_value : Find the redshift corresponding to a distance modulus.
        g      @g      9@)rh   log10r  r  rL   rQ   Quantitymag)rw   r   vals      r$   distmodzFLRW.distmod'  sJ    0 BHS!9!9!!<!<!BCCDDDtKz#qu%%%r%   c                ~   | j         }|dk    r#dt          z  |                     |          dz  z  S | j        j        }|                     |          j        }dt          z  |dz  z  d|z  z  t          j        dz  z  }||z  t          j	        d|||z  dz  z  z             z  }t          t          |                    |z  |z  }|dk    r:||dt          t          |                    z  t          j        |          z  z
  z  S ||dt          t          |                    z  t          j        |          z  z
  z  S )	a=  Comoving volume in cubic Mpc at redshift ``z``.

        This is the volume of the universe encompassed by redshifts less than
        ``z``. For the case of :math:`\Omega_k = 0` it is a sphere of radius
        `comoving_distance` but it is less intuitive if :math:`\Omega_k` is not.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        V : `~astropy.units.Quantity`
            Comoving volume in :math:`Mpc^3` at each input redshift.
        r   gUUUUUU?r'   g      @       @r)   r<   r&   )rs   r   r   rS   rL   r	  rQ   rR   rh   r	   r  arcsinharcsin)rw   r   r   r  dmterm1term2term3s           r$   comoving_volumezFLRW.comoving_volumeB  s+   " i!88r>D$:$:1$=$=$BBB"(..q117b2q5 C#I.9R"'!cR"WN&:":;;;SXX#b(77EC$s3xx..$82:e;L;L$LLMMEC$s3xx..$829U;K;K$KKLLr%   c                    |                      |          }| j        |dz  z  |                     |          t          j        z  z  S )a  Differential comoving volume at redshift z.

        Useful for calculating the effective comoving volume.
        For example, allows for integration over a comoving volume that has a
        sensitivity function that changes with redshift. The total comoving
        volume is given by integrating ``differential_comoving_volume`` to
        redshift ``z`` and multiplying by a solid angle.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        dV : `~astropy.units.Quantity`
            Differential comoving volume per redshift per steradian at each
            input redshift.
        r"  )r	  rS   r   rQ   	steradian)rw   r   r%  s      r$   differential_comoving_volumez!FLRW.differential_comoving_volumeb  s?    ( ..q11$C0DJJqMMQ[4PQQr%   c                v    |                      |                              t          j                  t          z  S )a  
        Separation in transverse comoving kpc corresponding to an arcminute at
        redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            The distance in comoving kpc corresponding to an arcmin at each
            input redshift.
        )r	  rP   rQ   kpc_radian_in_arcminr   s     r$   kpc_comoving_per_arcminzFLRW.kpc_comoving_per_arcminy  s.      003366qu==@QQQr%   c                v    |                      |                              t          j                  t          z  S )a  
        Separation in transverse proper kpc corresponding to an arcminute at
        redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        d : `~astropy.units.Quantity` ['length']
            The distance in proper kpc corresponding to an arcmin at each input
            redshift.
        )r  rP   rQ   r.  r/  r   s     r$   kpc_proper_per_arcminzFLRW.kpc_proper_per_arcmin  s.      --a0033AE::=NNNr%   c                v    t           |                     |                              t          j                  z  S )a  
        Angular separation in arcsec corresponding to a comoving kpc at
        redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        theta : `~astropy.units.Quantity` ['angle']
            The angular separation in arcsec corresponding to a comoving kpc at
            each input redshift.
        )_radian_in_arcsecr	  rP   rQ   r.  r   s     r$   arcsec_per_kpc_comovingzFLRW.arcsec_per_kpc_comoving  s-      !4#D#DQ#G#G#J#J15#Q#QQQr%   c                v    t           |                     |                              t          j                  z  S )a  
        Angular separation in arcsec corresponding to a proper kpc at redshift
        ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshift.

        Returns
        -------
        theta : `~astropy.units.Quantity` ['angle']
            The angular separation in arcsec corresponding to a proper kpc at
            each input redshift.
        )r4  r  rP   rQ   r.  r   s     r$   arcsec_per_kpc_properzFLRW.arcsec_per_kpc_proper  s-      !4#A#A!#D#D#G#G#N#NNNr%   )Q__name__
__module____qualname____doc__r   rA   rB   rC   rD   rE   rQ   mass_energyrF   rG   Kr5   r@   	validatorpropertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rp   r   r   r   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r	  r  r  r  r  r  r   r)  r,  r0  r2  r5  r7  __classcell__r|   s   @r$   r   r   E   sF       9 9v 
E
 
 
B
 )C   C 9M  D II  E
 93~  D 9'd-!-//  D )L  C ACi14Ze) e) e) e) e) e) e) e)T 	]
 
 ]
 
^  ^@ @ @ X@ O O XO   X   X   X   X   X ! ! X! % % X% ' ' X'   X   X = = ^=2T T T C C C2C C C2D D DBC C C(N N N(G G G$< < <./ / /. . .B5 B5 B5H. . . 1! 1! 1!f
 
 
@  6S S S(- - -*A A A*2 2 2*( ( (' ' '$& & &,C C C$ C C C&; ; ;&  &9 9 9" E E E,> > >2 2 2$= = =( 1%%%Y Y &%Y*\ \ \&= = =0E E EB@ @ @4@ @ @6L L L: B B B4& & &6M M M@R R R.R R R$O O O$R R R$O O O O O O Or%   c                       e Zd ZdZej                            d          Z fdZ fdZe	dd
            Z
dddd fdZed             Zd Z xZS )r   a  
    Mixin class for flat FLRW cosmologies. Do NOT instantiate directly.
    Must precede the base class in the multiple-inheritance so that this
    mixin's ``__init__`` proceeds the base class'.
    Note that all instances of ``FlatFLRWMixin`` are flat, but not all
    flat cosmologies are instances of ``FlatFLRWMixin``. As example,
    ``LambdaCDM`` **may** be flat (for the a specific set of parameter values),
    but ``FlatLambdaCDM`` **will** be flat.
    T)derivedc                    t                                                       d| j        j        v rt	          d          d S )NrC   z>subclasses of `FlatFLRWMixin` cannot have `Ode0` in `__init__`)r?   __init_subclass___init_signature
parameters	TypeError)clsr|   s    r$   rE  zFlatFLRWMixin.__init_subclass__  sG    !!###S(333P   43r%   c                     t                      j        |i | d| _        d| j        | j        z   | j        z   | j        z   z
  | _        d S )Nr7   r&   )r?   r@   rs   rH   r^   rq   rr   )rw   r"   kwr|   s      r$   r@   zFlatFLRWMixin.__init__  sM    $%"%%%	DI5
BTYNO


r%   rw   r-   returnr+   c           	          | j         j        j        di | j        d| j        i} | j         |j        i |j        }|j        dz   D ]$}t          |d|z   t          | |                     %|S )NrC   )r   _r>   )
__nonflatclass__rF  bind_partial_init_argumentsrC   r"   r#   __all_parameters__setattrgetattr)rw   bainstns       r$   nonflatzFlatFLRWMixin.nonflat  s     @T"2? 
 
"
 
)-
 
 
 %t$bg;;;(83 	5 	5AD#'74#3#34444r%   Nr:   
to_nonflatr:   Mapping | NonerZ  r   r#   r   c               <     t                      j        d||d|S )a8  Returns a copy of this object with updated parameters, as specified.

        This cannot be used to change the type of the cosmology, except for
        changing to the non-flat version of this cosmology.

        Parameters
        ----------
        meta : mapping or None (optional, keyword-only)
            Metadata that will update the current metadata.
        to_nonflat : bool or None, optional keyword-only
            Whether to change to the non-flat version of this cosmology.
        **kwargs
            Cosmology parameter (and name) modifications. If any parameter is
            changed and a new name is not given, the name will be set to "[old
            name] (modified)".

        Returns
        -------
        newcosmo : `~astropy.cosmology.Cosmology` subclass instance
            A new instance of this class with updated parameters as specified.
            If no arguments are given, then a reference to this object is
            returned instead of copy.

        Examples
        --------
        To make a copy of the ``Planck13`` cosmology with a different matter
        density (``Om0``), and a new name:

            >>> from astropy.cosmology import Planck13
            >>> Planck13.clone(name="Modified Planck 2013", Om0=0.35)
            FlatLambdaCDM(name="Modified Planck 2013", H0=67.77 km / (Mpc s),
              Om0=0.35, ...

        If no name is specified, the new name will note the modification.

            >>> Planck13.clone(Om0=0.35).name
            'Planck13 (modified)'

        The keyword 'to_nonflat' can be used to clone on the non-flat equivalent
        cosmology.

            >>> Planck13.clone(to_nonflat=True)
            LambdaCDM(name="Planck13", ...

            >>> Planck13.clone(H0=70, to_nonflat=True)
            LambdaCDM(name="Planck13 (modified)", H0=70.0 km / (Mpc s), ...

        With 'to_nonflat' `True`, ``Ode0`` can be modified.

            >>> Planck13.clone(to_nonflat=True, Ode0=1)
            LambdaCDM(name="Planck13 (modified)", H0=67.77 km / (Mpc s),
                      Om0=0.30712, Ode0=1.0, ...
        rY  r>   )r?   clone)rw   r:   rZ  r#   r|   s       r$   r]  zFlatFLRWMixin.clone  s)    p uww}H$:HHHHHr%   c                    dS )r   r&   r>   r   s    r$   r   zFlatFLRWMixin.Otot0%  s	     sr%   c                t    t          |t          t          j        f          rdnt          j        |d          S )a<  The total density parameter at redshift ``z``.

        Parameters
        ----------
        z : Quantity-like ['redshift'], array-like, or `~numbers.Number`
            Input redshifts.

        Returns
        -------
        Otot : ndarray or float
            Returns float if input scalar. Value of 1.
        r&   F)subok)r   r
   rh   r   	ones_liker   s     r$   r   zFlatFLRWMixin.Otot*  s6     a&"*!566XCCBLRW<X<X<X	
r%   )rw   r-   rL  r+   )r:   r[  rZ  r   r#   r   )r8  r9  r:  r;  r   rC   r]  rE  r@   r   rX  r?  r   r   r@  rA  s   @r$   r   r     s          9??4?((D    P P P P P    \ )-8I 8I 8I 8I 8I 8I 8I 8It   X
 
 
 
 
 
 
r%   )L
__future__r   r  abcr   mathr   r   r   r   r	   numbersr
   typingr   r   r   numpyrh   r   r   astropy.constants	constantsrN   astropy.unitsunitsrQ   astropy.cosmology.corer   r   astropy.cosmology.parameterr   r   r   astropy.cosmology.utilsr   r   "astropy.utils.compat.optional_depsr   astropy.utils.decoratorsr   astropy.utils.exceptionsr   __all____doctest_requires__collections.abcr   scipy.integrater   kmsrR   rP   rT   rV   rU   GcgsrL   rX   radarcsecr4  arcminr/  sigma_sbrO   r\   k_Br5   r=  rl   r+   r-   r   r   r>   r%   r$   <module>r     s@   # " " " " "        * * * * * * * * * * * * * *       . . . . . . . . . .             ! ! ! ! ! !       @ @ @ @ @ @ @ @         
 F E E E E E E E 8 8 8 8 8 8 1 1 1 1 1 1 7 7 7 7 7 7?
#gY'   (''''''  G$$$$$$$G G G DAC!%K(,,S13Y77 cffQUmmB().4YNN18,, YNN18,, u~
*
/
5
),,qtacz
"
" 
	(	(	('+?CCC
zO zO zO zO zO9 zO zO zOz+w
 w
 w
 w
 w
& w
 w
 w
 w
 w
r%   