
[c           @` s^  d  d l  m Z m Z m Z m Z d d l m Z d d l m Z d  d l	 Z	 d  d l
 m Z m Z m Z m Z m Z d  d l m Z m Z d  d l Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m  Z  d d l m! Z! d d d d d d d d d d g
 e! j" Z# i d g d 6Z$ e j% e j& e j' j( d e j&  Z) e j& j( e j*  Z+ d d e e j, j- d Z. e d  d! Z/ e d" d! Z0 d# e j1 j- e j2 j- d$ Z3 e j4 j( e j5 e j6  Z7 d% e8 f d&     YZ9 d' e: f d(     YZ; e j< e  d) e; f d*     Y Z= d+ e= f d,     YZ> d- e> f d.     YZ? d/ e= f d0     YZ@ d1 e@ f d2     YZA d3 e= f d4     YZB d5 eB f d6     YZC d7 e= f d8     YZD d9 e= f d:     YZE d$ d;  ZF d<   ZG x1e! j" D]&ZH eI e! eH  ZJ eJ d= re? eJ d> eJ d? d@ eJ dA dB eJ dC dD e jK eJ dE e j5  dF eH dG eJ dH ZL dI ZM eM jN eH eJ dJ  eL _O nz e> eJ d> eJ d? eJ dK d@ eJ dA dB eJ dC dD e jK eJ dE e j5  dF eH dG eJ dH ZL dL ZM eM jN eH eJ dJ  eL _O eP e	 jQ eR eH eL  qW[H [J [L dM e  f dN     YZS d S(O   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t   six(   t   mapN(   t   sqrtt   pit   expt   logt   floor(   t   ABCMetat   abstractmethodi   (   t   scalar_inv_efuncs(   t	   constants(   t   units(   t
   isiterable(   t	   signature(   t   ScienceState(   t
   parametersu   FLRWu	   LambdaCDMu   FlatLambdaCDMu   wCDMu   FlatwCDMu   Flatw0waCDMu   w0waCDMu   wpwaCDMu   w0wzCDMu   default_cosmologyu   scipy.integrateu   *g      ?g      @g       @i  g      @i   g      N@gMbp?i   t   CosmologyErrorc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   V   s   t	   Cosmologyc           B` s   e  Z d  Z RS(   uI    Placeholder for when a more general Cosmology class is
    implemented. (   R   R   t   __doc__(    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   Z   s   t   FLRWc           B` s  e  Z d  Z d d e j d e j  dA dA d  Z d   Z 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 e
 d    Z e
 d    Z e
 d    Z e
 d    Z d   Z e d    Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d    Z% d!   Z& d"   Z' d#   Z( d$   Z) d%   Z* d&   Z+ d'   Z, d(   Z- d)   Z. d*   Z/ d+   Z0 d,   Z1 d-   Z2 d.   Z3 d/   Z4 d0   Z5 d1   Z6 d2   Z7 d3   Z8 d4   Z9 d5   Z: d6   Z; d7   Z< d8   Z= d9   Z> d:   Z? d;   Z@ d<   ZA d=   ZB d>   ZC d?   ZD d@   ZE RS(B   u   A class describing an isotropic and homogeneous
    (Friedmann-Lemaitre-Robertson-Walker) cosmology.

    This is an abstract base class -- you can't instantiate
    examples of this class, but must work with one of its
    subclasses such as `LambdaCDM` or `wCDM`.

    Parameters
    ----------

    H0 : float or scalar `~astropy.units.Quantity`
        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 `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Notes
    -----
    Class instances are static -- you can't change the values
    of the parameters.  That is, all of the attributes above are
    read only.
    i    gRQ@g        c	         C` s  t  |  |  _ |  j d k  r- t d   n  t  |  |  _ | d  k	 r t  |  |  _ |  j d k  ru t d   n  |  j |  j k r t d   n  |  j |  j |  _ n d  |  _ d  |  _ t  |  |  _ |  j d k  r t d   n  | |  _ t	 j
 | d t	 j d t j  |  _ |  j j s3t d   n  t	 j
 | d t	 j t	 j t	 j d t j  |  _ |  j j st d	   n  |  j j d
 |  _ t j |  j j t	 j  |  _ |  j j t }	 t	 j
 t |	 t	 j  |  _ t |	 d }
 t	 j
 |
 t	 j t	 j d  |  _  t! t" |  j   |  _# t$ |  _% |  j# d k r|  j j d k r|  j |  j# |  _& t' | t	 j
  st d   n  | j t	 j( d t	 j)   } | j r| j d k r|  j# |  _* d |  _+ qt, |  _% d |  _* |  j# |  _+ | j t j- |  j#  |  _. q| j j/   d k  r4t d   n  | j j0   d k ra|  j# |  _* d |  _+ qt, |  _% t1 |  |  j# k rd } t |   n  t1 t j2 | j d k  d  |  _* |  j# |  j* |  _+ t j2 | j d k  d } | | |  _. n  |  j j d k rt3 |  j j d |  j  j |  _4 d |  j |  _5 |  j% r|  j. t6 |  j5 } | j |  _7 |  j7 j8   |  _9 |  j4 |  j: d  |  _; qd |  j |  j4 |  _; n* d |  _4 t	 j
 d t	 j  |  _5 d |  _; d |  j |  j |  j4 |  j; |  _< |  j= |  _> d |  _? d  S(   Ng        u"   Matter density can not be negativeu$   Baryonic density can not be negativeu<   Baryonic density can not be larger than total matter densityu1   Effective number of neutrinos can not be negativet   unitt   dtypeu   Tcmb0 is a non-scalar quantityu   H0 is a non-scalar quantityg      Y@i   i   i    u   m_nu must be a Quantityt   equivalenciesu,   Invalid (negative) neutrino mass encounteredu$   Unexpected number of neutrino massesi   grv}+?gC?g      ?(    (@   t   floatt   _Om0t
   ValueErrort   _Ode0t   Nonet   _Ob0t   _Odm0t   _Nefft   namet   ut   Quantityt   Kt   npt   _Tcmb0t   isscalart   kmt   st   Mpct   _H0t   valuet   _ht   constt   ct   tot   _hubble_distancet   H0units_to_invst
   sec_to_Gyrt   Gyrt   _hubble_timet   critdens_constt   gt   cmt   _critical_density0t   intR
   t   _nneutrinost   Falset
   _massivenut   _neff_per_nut
   isinstancet   eVt   mass_energyt   _nmasslessnut   _nmassivenut   Truet   onest   _massivenu_masst   mint   maxt   lent   nonzerot   a_B_c2t   _Ogamma0t   _Tnu0t   kB_evKt   _nu_yt   tolistt
   _nu_y_listt   nu_relative_densityt   _Onu0t   _Ok0t	   inv_efunct   _inv_efunc_scalart   _inv_efunc_scalar_args(   t   selft   H0t   Om0t   Ode0t   Tcmb0t   Nefft   m_nut   Ob0R%   t   H0_st   cd0valuet   errstrt   wt   nu_y(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   __init__   s    			$2#	!				%			%c         C` s?   |  j  d k r" d j |  j j  Sd j |  j j |  j   Sd S(   u*    Helper function for constructing __repr__u   {0}(u   {0}(name="{1}", N(   R%   R!   t   formatt	   __class__R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt	   _namelead+  s    c      
   C` sI   d } | j  |  j   |  j |  j |  j |  j |  j |  j t |  j	   S(   Nu[   {0}H0={1:.3g}, Om0={2:.3g}, Ode0={3:.3g}, Tcmb0={4:.4g}, Neff={5:.3g}, m_nu={6}, Ob0={7:s})(
   Rj   Rl   R/   R   R    R*   R$   Rb   t   _float_or_noneR"   (   R\   t   retstr(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   __repr__3  s    !c         C` s   |  j  S(   uB    Return the Hubble constant as an `~astropy.units.Quantity` at z=0(   R/   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR]   >  s    c         C` s   |  j  S(   u5    Omega matter; matter density/critical density at z=0(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR^   C  s    c         C` s   |  j  S(   u?    Omega dark energy; dark energy density/critical density at z=0(   R    (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR_   H  s    c         C` s   |  j  S(   u>    Omega baryon; baryonic matter density/critical density at z=0(   R"   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRc   M  s    c         C` s   |  j  S(   u?    Omega dark matter; dark matter density/critical density at z=0(   R#   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Odm0R  s    c         C` s   |  j  S(   uQ    Omega curvature; the effective curvature density/critical density
        at z=0(   RX   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Ok0W  s    c         C` s   |  j  S(   u;    Temperature of the CMB as `~astropy.units.Quantity` at z=0(   R*   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR`   ]  s    c         C` s   |  j  S(   uK    Temperature of the neutrino background as `~astropy.units.Quantity` at z=0(   RQ   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Tnu0b  s    c         C` s   |  j  S(   u%    Number of effective neutrino species(   R$   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRa   g  s    c         C` s   |  j  j d k r t S|  j S(   u@    Does this cosmology have at least one massive neutrino species?i    (   RQ   R0   R@   RA   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   has_massive_nul  s    c         C` s   |  j  j d k r d S|  j sG t j t j |  j  t j	 d t j
 S|  j d k ru t j |  j t j	 d t j
 St j t j |  j  |  j j  } t j | t j	 d t j
 S(   u    Mass of neutrino speciesi    R   N(   RQ   R0   R!   RA   R&   R'   R)   t   zerosRF   RD   R   RJ   t   append(   R\   t   numass(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRb   s  s    	

c         C` s   |  j  S(   u:    Dimensionless Hubble constant: h = H_0 / 100 [km/sec/Mpc](   R1   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   h  s    c         C` s   |  j  S(   u)    Hubble time as `~astropy.units.Quantity`(   R9   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   hubble_time  s    c         C` s   |  j  S(   u-    Hubble distance as `~astropy.units.Quantity`(   R5   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   hubble_distance  s    c         C` s   |  j  S(   u5    Critical density as `~astropy.units.Quantity` at z=0(   R=   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   critical_density0  s    c         C` s   |  j  S(   u<    Omega gamma; the density/critical density of photons at z=0(   RP   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Ogamma0  s    c         C` s   |  j  S(   u;    Omega nu; the density/critical density of neutrinos at z=0(   RW   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Onu0  s    c         K` s   t  |  d k r |  St |  j  j j   } i  } xZ | D]R } y t |  |  } | | | <Wq; t k
 r d } t | j |    q; Xq; WxF | D]> } | | k r d } t | j |    n  | | | | <q W|  j |   S(   u|   Returns a copy of this object, potentially with some changes.

        Returns
        -------
        newcos : Subclass of FLRW
        A new instance of this class with the specified changes.

        Notes
        -----
        This assumes that the values of all constructor arguments
        are available as properties, which is true of all the provided
        subclasses but may not be true of user-provided ones.  You can't
        change the type of class, so this can't be used to change between
        flat and non-flat.  If no modifications are requested, then
        a reference to this object is returned.

        Examples
        --------
        To make a copy of the Planck13 cosmology with a different Omega_m
        and a new name:

        >>> from astropy.cosmology import Planck13
        >>> newcos = Planck13.clone(name="Modified Planck 2013", Om0=0.35)
        i    u   Object did not have property corresponding to constructor argument '{}'; perhaps it is a user provided subclass that does not do souD   User provided argument '{}' not found in constructor for this object(	   RM   R   Ri   R   t   keyst   getattrt   AttributeErrorRj   Rk   (   R\   t   kwargst   arglistt   argdictt   argt   valRf   t   newarg(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   clone  s"    c         C` s   t  d   d S(   u6   The dark energy equation of state.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.
        u   w(z) is not implementedN(   t   NotImplementedError(   R\   t   z(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg     s    c         C` sB   t  |  r t j |  } n  |  j d | d |  j |  d S(   u   Return the density parameter for non-relativistic matter
        at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        Notes
        -----
        This does not include neutrinos, even if non-relativistic
        at the redshift of interest; see `Onu`.
        g      ?i   i   (   R   R)   t   asarrayR   RY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Om  s    c         C` s`   |  j  d k r t d   n  t |  r< t j |  } n  |  j  d | d |  j |  d S(   u   Return the density parameter for baryonic matter at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        Raises
        ------
        ValueError
          If Ob0 is None.
        u)   Baryon density not set for this cosmologyg      ?i   i   N(   R"   R!   R   R   R)   R   RY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Ob  s
    c         C` s`   |  j  d k r t d   n  t |  r< t j |  } n  |  j  d | d |  j |  d S(   u5   Return the density parameter for dark matter at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        Raises
        ------
        ValueError
          If Ob0 is None.
        Notes
        -----
        This does not include neutrinos, even if non-relativistic
        at the redshift of interest.
        uS   Baryonic density not set for this cosmology, unclear meaning of dark matter densityg      ?i   i   N(   R#   R!   R   R   R)   R   RY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Odm,  s
    c         C` s   t  |  rO t j |  } |  j d k rb t j t j |  j d t j Sn |  j d k rb d S|  j d | d |  j |  d S(   uN   Return the equivalent density parameter for curvature
        at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Ok : ndarray, or float if input scalar
          The equivalent density parameter for curvature at each redshift.
        i    R   g        g      ?i   (	   R   R)   R   RX   Rt   t
   asanyarrayt   shapeR   RY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   OkK  s    %c         C` s   t  |  rO t j |  } |  j d k rb t j t j |  j d t j Sn |  j d k rb d S|  j |  j |  |  j	 |  d S(   ua   Return the density parameter for dark energy at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Ode : ndarray, or float if input scalar
          The density of non-relativistic matter relative to the critical
          density at each redshift.
        i    R   g        i   (
   R   R)   R   R    Rt   R   R   R   t   de_density_scaleRY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Odee  s    %c         C` sB   t  |  r t j |  } n  |  j d | d |  j |  d S(   uW   Return the density parameter for photons at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Ogamma : ndarray, or float if input scalar
          The energy density of photons relative to the critical
          density at each redshift.
        g      ?i   i   (   R   R)   R   RP   RY   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Ogamma  s    c         C` s|   t  |  rO t j |  } |  j d k rb t j t j |  j d t j Sn |  j d k rb d S|  j |  |  j	 |  S(   u,   Return the density parameter for neutrinos at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Onu : ndarray, or float if input scalar
          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.
        i    R   g        (
   R   R)   R   RW   Rt   R   R   R   R   RV   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Onu  s    %c         C` s-   t  |  r t j |  } n  |  j d | S(   u   Return the CMB temperature at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Tcmb : `~astropy.units.Quantity`
          The temperature of the CMB in K.
        g      ?(   R   R)   R   R*   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Tcmb  s    c         C` s-   t  |  r t j |  } n  |  j d | S(   u    Return the neutrino temperature at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        Tnu : `~astropy.units.Quantity`
          The temperature of the cosmic neutrino background in K.
        g      ?(   R   R)   R   RQ   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   Tnu  s    c   	      C` s   d } |  j  sY t j |  r) | |  j S| |  j t j t j |  j d t j Sn  d } d } d } t j |  } |  j	 d t j
 | d d } d | | | | } | j d  |  j } | |  j | S(	   uV   Neutrino density function relative to the energy density in
        photons.

        Parameters
        ----------
        z : array like
           Redshift

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

        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.
        gC?R   gHzG?g'|?gTN?g      ?t   axisi(   RA   R)   R+   R$   RI   R   R   R   R   RS   t   expand_dimst   sumRF   RB   (	   R\   R   t   prefact   pt   invpt   kt	   curr_nu_yt   rel_mass_pert   rel_mass(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRV     s    0	
& c         C` s!   t  |  d } d |  j |  S(   u1    Internal convenience function for w(z) integral.g      ?(   R   Rg   (   R\   t   ln1pzR   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   _w_integrand  s    c      	   C` s   d d l  m } t |  r{ t j |  } t j g  | D]) } | |  j d t d |   d ^ q8  } t j d |  S| |  j d t d |   d } t d |  Sd S(   u"   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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)

        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.
        i    (   t   quadi   i   N(	   t   scipy.integrateR   R   R)   R   t   arrayR   R	   R   (   R\   R   R   t   redshiftt   ival(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   #  s    '	6#c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } t j
 | d | | | | | | |  j |   S(   u   Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H(z) = H_0 E`.

        It is not necessary to override this method, but if de_density_scale
        takes a particularly simple form, it may be advantageous to.
        i   g      ?i   (   R   R)   R   R   R    RX   RA   RP   RV   RW   R   R   (   R\   R   R^   R_   Rq   t   Ort   zp1(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   efuncU  s    	
!c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } | d | | | | | | |  j
 |  d S(   u  Inverse of efunc.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the inverse Hubble constant.
        i   g      ?i   g      (   R   R)   R   R   R    RX   RA   RP   RV   RW   R   (   R\   R   R^   R_   Rq   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRY   w  s    	
c         C` s!   |  j  } |  j | |  d | S(   u#   Integrand of the lookback time.

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

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

        References
        ----------
        Eqn 30 from Hogg 1999.
        g      ?(   R[   RZ   (   R\   R   t   args(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   _lookback_time_integrand_scalar  s    	c         C` s=   t  |  r" d t j |  } n
 d | } |  j |  | S(   u:   Integrand of the lookback time.

        Parameters
        ----------
        z : float or array-like
          Input redshift.

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

        References
        ----------
        Eqn 30 from Hogg 1999.
        g      ?(   R   R)   R   RY   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   lookback_time_integrand  s    
c         C` s%   |  j  } d | d |  j | |  S(   u2   Integrand of the absorption distance.

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

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

        References
        ----------
        See Hogg 1999 section 11.
        g      ?i   (   R[   RZ   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   _abs_distance_integrand_scalar  s    	c         C` sA   t  |  r" d t j |  } n
 d | } | d |  j |  S(   uD   Integrand of the absorption distance.

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

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

        References
        ----------
        See Hogg 1999 section 11.
        g      ?i   (   R   R)   R   RY   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   abs_distance_integrand  s    
c         C` s   |  j  |  j |  S(   u   Hubble parameter (km/s/Mpc) at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        H : `~astropy.units.Quantity`
          Hubble parameter at each input redshift.
        (   R/   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   H  s    c         C` s*   t  |  r t j |  } n  d d | S(   uA   Scale factor at redshift ``z``.

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

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        a : ndarray, or float if input scalar
          Scale factor at each input redshift.
        g      ?(   R   R)   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   scale_factor  s    c         ` s6   d d l  m      f d   }  j t | |  S(   u   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 : array-like
          Input redshifts.  Must be 1D or scalar

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

        See Also
        --------
        z_at_value : Find the redshift corresponding to a lookback time.
        i    (   R   c         ` s      j  d |   d S(   Ni    (   R   (   t   red(   R   R\   (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   <lambda>(  s    (   R   R   R9   t   vectorize_if_needed(   R\   R   t   f(    (   R   R\   s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   lookback_time  s    c         C` s    |  j  |  t j j t j  S(   u  
        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 : array-like
          Input redshifts.  Must be 1D or scalar

        Returns
        -------
        d : `~astropy.units.Quantity`
          Lookback distance in Mpc
        (   R   R2   R3   R4   R&   R.   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   lookback_distance+  s    c         ` s6   d d l  m      f d   }  j t | |  S(   u   Age of the universe in Gyr at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

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

        See Also
        --------
        z_at_value : Find the redshift corresponding to an age.
        i    (   R   c         ` s      j  |  t j  d S(   Ni    (   R   R)   t   inf(   R   (   R   R\   (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   Q  s   	(   R   R   R9   R   (   R\   R   R   (    (   R   R\   s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   age>  s    c         C` s   |  j  |  j |  d S(   u"   Critical density in grams per cubic cm at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        rho : `~astropy.units.Quantity`
          Critical density in g/cm^3 at each input redshift.
        i   (   R=   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   critical_densityU  s    c         C` s   |  j  d |  S(   u   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 : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          Comoving distance in Mpc to each input redshift.
        i    (   t   _comoving_distance_z1z2(   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   comoving_distancee  s    c         ` s9   d d l  m      f d   }  j t | | |  S(   u   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 : array-like, shape (N,)
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          Comoving distance in Mpc between each input redshift.
        i    (   R   c         ` s       j  |  | d  j d S(   NR   i    (   RZ   R[   (   t   z1t   z2(   R   R\   (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s   (   R   R   R5   R   (   R\   R   R   R   (    (   R   R\   s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   z  s    c         C` s   |  j  d |  S(   u   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 omega_k is zero (as in
        the current concordance lambda CDM model).

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

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

        Notes
        -----
        This quantity also called the 'proper motion distance' in some
        texts.
        i    (   t"   _comoving_transverse_distance_z1z2(   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   comoving_transverse_distance  s    c         C` s   |  j  } |  j | |  } | d k r+ | St t |   } |  j } | d k ru | | t j | | j | j  S| | t j | | j | j  Sd S(   u  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 omega_k is zero (as in the current
        concordance lambda CDM model).

        Parameters
        ----------
        z1, z2 : array-like, shape (N,)
          Input redshifts.  Must be 1D or scalar.

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

        Notes
        -----
        This quantity is also called the 'proper motion distance' in
        some texts.

        i    N(	   RX   R   R   t   absR5   R)   t   sinhR0   t   sin(   R\   R   R   Rq   t   dct   sqrtOk0t   dh(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    		#c         C` s3   t  |  r t j |  } n  |  j |  d | S(   uB   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``.

        Weinberg, 1972, pp 421-424; Weedman, 1986, pp 65-67; Peebles,
        1993, pp 325-327.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          Angular diameter distance in Mpc at each input redshift.
        g      ?(   R   R)   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   angular_diameter_distance  s    c         C` s3   t  |  r t j |  } n  d | |  j |  S(   u   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.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

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

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

        References
        ----------
        Weinberg, 1972, pp 420-424; Weedman, 1986, pp 60-62.
        g      ?(   R   R)   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   luminosity_distance  s    c         C` s6   t  j |  } t  j |  } |  j | |  d | S(   u   Angular diameter distance between objects at 2 redshifts.
        Useful for gravitational lensing.

        Parameters
        ----------
        z1, z2 : array-like, shape (N,)
          Input redshifts. z2 must be large than z1.

        Returns
        -------
        d : `~astropy.units.Quantity`, shape (N,) or single if input scalar
          The angular diameter distance between each input redshift
          pair.

        g      ?(   R)   R   R   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   angular_diameter_distance_z1z2
  s    c         ` s/   d d l  m      f d   } t | |  S(   up   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.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : float or ndarray
          Absorption distance (dimensionless) at each input redshift.

        References
        ----------
        Hogg 1999 Section 11. (astro-ph/9905116)
        Bahcall, John N. and Peebles, P.J.E. 1969, ApJ, 156L, 7B
        i    (   R   c         ` s      j  d |   d S(   Ni    (   R   (   R   (   R   R\   (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   7  s    (   R   R   R   (   R\   R   R   (    (   R   R\   s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   absorption_distance  s    c         C` s<   d t  j t |  j |  j   d } t j | t j  S(   u   Distance modulus at redshift ``z``.

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

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

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

        See Also
        --------
        z_at_value : Find the redshift corresponding to a distance modulus.
        g      @g      9@(   R)   t   log10R   R   R0   R&   R'   t   mag(   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   distmod:  s    )c         C` s  |  j  } | d k r. d
 t |  j |  d S|  j j } |  j |  j } d t | d d | t j d } | | t j	 d | | | d  } t	 t
 |   | | } | d k r | | d t	 t
 |   t j |  S| | d t	 t
 |   t j |  Sd	 S(   u   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 omega_k = 0 it is a sphere of radius
        `comoving_distance` but it is less intuitive
        if omega_k is not 0.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        V : `~astropy.units.Quantity`
          Comoving volume in :math:`Mpc^3` at each input redshift.
        i    g      @g      @i   g       @i   i   g      ?NgUUUUUU?(   RX   R   R   R5   R0   R   R&   R.   R)   R   R   t   arcsinht   arcsin(   R\   R   Rq   R   t   dmt   term1t   term2t   term3(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   comoving_volumeV  s    	%')c         C` sN   |  j  } |  j |  } d | } | | | d t j |  j |  t j  S(   u  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 : array-like
          Input redshifts.

        Returns
        -------
        dV : `~astropy.units.Quantity`
          Differential comoving volume per redshift per steradian at
          each input redshift.g      ?g       @(   R5   R   R&   R'   R   t	   steradian(   R\   R   R   t   daR   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   differential_comoving_volumex  s
    	
!c         C` s$   |  j  |  j t j  t t j S(   u   Separation in transverse comoving kpc corresponding to an
        arcminute at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          The distance in comoving kpc corresponding to an arcmin at each
          input redshift.
        (   R   R4   R&   t   kpct   arcmin_in_radianst   arcmin(   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   kpc_comoving_per_arcmin  s    c         C` s$   |  j  |  j t j  t t j S(   u   Separation in transverse proper kpc corresponding to an
        arcminute at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          The distance in proper kpc corresponding to an arcmin at each
          input redshift.
        (   R   R4   R&   R   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   kpc_proper_per_arcmin  s    c         C` s$   t  j |  j |  j t  j  t S(   u   Angular separation in arcsec corresponding to a comoving kpc
        at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        theta : `~astropy.units.Quantity`
          The angular separation in arcsec corresponding to a comoving kpc
          at each input redshift.
        (   R&   t   arcsecR   R4   R   t   arcsec_in_radians(   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   arcsec_per_kpc_comoving  s    c         C` s$   t  j |  j |  j t  j  t S(   u   Angular separation in arcsec corresponding to a proper kpc at
        redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        theta : `~astropy.units.Quantity`
          The angular separation in arcsec corresponding to a proper kpc
          at each input redshift.
        (   R&   R   R   R4   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   arcsec_per_kpc_proper  s    N(F   R   R   R   R&   R'   RD   R!   Ri   Rl   Ro   t   propertyR]   R^   R_   Rc   Rp   Rq   R`   Rr   Ra   Rs   Rb   Rw   Rx   Ry   Rz   R{   R|   R   R   Rg   R   R   R   R   R   R   R   R   R   RV   R   R   R   RY   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   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   _   s~   5!			=										G	
	2	"															%						"				t	   LambdaCDMc           B` sY   e  Z d  Z d d e j d e j  d	 d	 d  Z d   Z d   Z	 d   Z
 d   Z RS(
   ut  FLRW cosmology with a cosmological constant and curvature.

    This has no additional attributes beyond those of FLRW.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

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

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import LambdaCDM
    >>> cosmo = LambdaCDM(H0=70, Om0=0.3, Ode0=0.7)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    i    gRQ@g        c	   	      C` s   t  j |  | | | | | | d | d | |  j j d k rg t j |  _ |  j |  j |  j	 f |  _
 n |  j s t j |  _ |  j |  j |  j	 |  j |  j f |  _
 n? t j |  _ |  j |  j |  j	 |  j |  j |  j |  j f |  _
 d  S(   NR%   Rc   i    (   R   Ri   R*   R0   R   t   lcdm_inv_efunc_norelRZ   R   R    RX   R[   RA   t   lcdm_inv_efunc_nomnuRP   RW   t   lcdm_inv_efuncRB   RF   RU   (	   R\   R]   R^   R_   R`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi     s    $	c         C` s=   t  j |  r d Sd t  j t  j |  j d t  j Sd S(   uE  Returns dark energy equation of state at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.  Here this is
        :math:`w(z) = -1`.
        g      R   N(   R)   R+   RI   R   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg   '  s    c         C` s9   t  j |  r d St  j t  j |  j d t  j Sd S(   u   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        Notes
        -----
        The scaling factor, I, is defined by :math:`\rho(z) = \rho_0 I`,
        and in this case is given by :math:`I = 1`.
        g      ?R   N(   R)   R+   RI   R   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   B  s    c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } t j
 | d | | | | | |  S(   u   Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H(z) = H_0 E`.
        g      ?i   (   R   R)   R   R   R    RX   RA   RP   RV   RW   R   (   R\   R   R^   R_   Rq   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   Z  s    	
c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } | d | | | | | | d S(   u   Function used to calculate :math:`\frac{1}{H_z}`.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The inverse redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H_z = H_0 /
        E`.
        i   g      ?i   g      (
   R   R)   R   R   R    RX   RA   RP   RV   RW   (   R\   R   R^   R_   Rq   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRY   z  s    	
N(   R   R   R   R&   R'   RD   R!   Ri   Rg   R   R   RY   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s   4!			 t   FlatLambdaCDMc           B` sP   e  Z d  Z d d e j d e j  d d d  Z d   Z d   Z	 d   Z
 RS(	   u  FLRW cosmology with a cosmological constant and no curvature.

    This has no additional attributes beyond those of FLRW.

    Parameters
    ----------
    H0 : float or `~astropy.units.Quantity`
        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.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import FlatLambdaCDM
    >>> cosmo = FlatLambdaCDM(H0=70, Om0=0.3)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    i    gRQ@g        c         C` s   t  j |  | | d | | | d | d | d |  j |  j |  j |  _ d |  _ |  j j d k r t	 j
 |  _ |  j |  j f |  _ ns |  j s t	 j |  _ |  j |  j |  j |  j f |  _ n9 t	 j |  _ |  j |  j |  j |  j |  j |  j f |  _ d  S(   Ng        R%   Rc   g      ?i    (   R   Ri   R   RP   RW   R    RX   R*   R0   R   t   flcdm_inv_efunc_norelRZ   R[   RA   t   flcdm_inv_efunc_nomnut   flcdm_inv_efuncRB   RF   RU   (   R\   R]   R^   R`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi     s     $		c         C` s   t  |  r t j |  } n  |  j |  j } } |  j rW |  j d |  j |  } n |  j |  j } d | } t j	 | d | | | |  S(   u   Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H(z) = H_0 E`.
        i   g      ?i   (
   R   R)   R   R   R    RA   RP   RV   RW   R   (   R\   R   R^   R_   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    	
c         C` s   t  |  r t j |  } n  |  j |  j } } |  j rW |  j d |  j |  } n |  j |  j } d | } | d | | | | d S(   u  Function used to calculate :math:`\frac{1}{H_z}`.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The inverse redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H_z = H_0 / E`.
        g      ?i   g      (	   R   R)   R   R   R    RA   RP   RV   RW   (   R\   R   R^   R_   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRY     s    	
c      	   C` sC   d } | j  |  j   |  j |  j |  j |  j |  j t |  j   S(   NuM   {0}H0={1:.3g}, Om0={2:.3g}, Tcmb0={3:.4g}, Neff={4:.3g}, m_nu={5}, Ob0={6:s})(	   Rj   Rl   R/   R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo     s    N(   R   R   R   R&   R'   RD   R!   Ri   R   RY   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s   /!	 	t   wCDMc           B` st   e  Z d  Z d d d e j d e j  d d d  Z e d    Z	 d   Z
 d   Z d	   Z d
   Z d   Z RS(   u=  FLRW cosmology with a constant dark energy equation of state
    and curvature.

    This has one additional attribute beyond those of FLRW.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

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

    w0 : float, optional
        Dark energy equation of state at all redshifts. This is
        pressure/density for dark energy in units where c=1. A cosmological
        constant has w0=-1.0.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import wCDM
    >>> cosmo = wCDM(H0=70, Om0=0.3, Ode0=0.7, w0=-0.9)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      i    gRQ@g        c
   
      C` s  t  j |  | | | | | | d |	 d | t |  |  _ |  j j d k r| t j |  _ |  j	 |  j
 |  j |  j f |  _ n |  j s t j |  _ |  j	 |  j
 |  j |  j |  j |  j f |  _ nE t j |  _ |  j	 |  j
 |  j |  j |  j |  j |  j |  j f |  _ d  S(   NR%   Rc   i    (   R   Ri   R   t   _w0R*   R0   R   t   wcdm_inv_efunc_norelRZ   R   R    RX   R[   RA   t   wcdm_inv_efunc_nomnuRP   RW   t   wcdm_inv_efuncRB   RF   RU   (
   R\   R]   R^   R_   t   w0R`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi   c  s"    $	c         C` s   |  j  S(   u    Dark energy equation of state(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   |  s    c         C` sC   t  j |  r |  j S|  j t  j t  j |  j d t  j Sd S(   uF  Returns dark energy equation of state at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.  Here this is
        :math:`w(z) = w_0`.
        R   N(   R)   R+   R   RI   R   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg     s    c         C` s5   t  |  r t j |  } n  d | d d |  j S(   u   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        Notes
        -----
        The scaling factor, I, is defined by :math:`\rho(z) = \rho_0 I`,
        and in this case is given by
        :math:`I = \left(1 + z\right)^{3\left(1 + w_0\right)}`
        g      ?g      @(   R   R)   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    c         C` s   t  |  r t j |  } n  |  j |  j |  j |  j f \ } } } } |  j rn |  j d |  j	 |  } n |  j |  j
 } d | } t j | d | | | | | | | d d |  S(   u   Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H(z) = H_0 E`.
        g      ?i   g      @(   R   R)   R   R   R    RX   R   RA   RP   RV   RW   R   (   R\   R   R^   R_   Rq   R   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    *	
!c         C` s   t  |  r t j |  } n  |  j |  j |  j |  j f \ } } } } |  j rn |  j d |  j	 |  } n |  j |  j
 } d | } | d | | | | | | | d d | d S(   u   Function used to calculate :math:`\frac{1}{H_z}`.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The inverse redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H_z = H_0 / E`.
        g      ?i   g      @g      (   R   R)   R   R   R    RX   R   RA   RP   RV   RW   (   R\   R   R^   R_   Rq   R   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRY     s    *	
c         C` sO   d } | j  |  j   |  j |  j |  j |  j |  j |  j |  j t	 |  j
  	 S(   Nug   {0}H0={1:.3g}, Om0={2:.3g}, Ode0={3:.3g}, w0={4:.3g}, Tcmb0={5:.4g}, Neff={6:.3g}, m_nu={7}, Ob0={8:s})(   Rj   Rl   R/   R   R    R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo     s    N(   R   R   R   R&   R'   RD   R!   Ri   R   R   Rg   R   R   RY   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   '  s   :$				t   FlatwCDMc           B` sS   e  Z d  Z d d d e j d e j  d	 d	 d  Z d   Z d   Z	 d   Z
 RS(
   u  FLRW cosmology with a constant dark energy equation of state
    and no spatial curvature.

    This has one additional attribute beyond those of FLRW.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

    w0 : float, optional
        Dark energy equation of state at all redshifts. This is
        pressure/density for dark energy in units where c=1. A cosmological
        constant has w0=-1.0.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import FlatwCDM
    >>> cosmo = FlatwCDM(H0=70, Om0=0.3, w0=-0.9)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      i    gRQ@g        c	   	      C` s  t  j |  | | d | | | | d | d | d |  j |  j |  j |  _ d |  _ |  j j d k r t	 j
 |  _ |  j |  j |  j f |  _ n |  j s t	 j |  _ |  j |  j |  j |  j |  j f |  _ n? t	 j |  _ |  j |  j |  j |  j |  j |  j |  j f |  _ d  S(   Ng        R%   Rc   g      ?i    (   R   Ri   R   RP   RW   R    RX   R*   R0   R   t   fwcdm_inv_efunc_norelRZ   R   R[   RA   t   fwcdm_inv_efunc_nomnut   fwcdm_inv_efuncRB   RF   RU   (	   R\   R]   R^   R   R`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi   0  s$    !		c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } t j
 | d | | | | | d d |  S(   u   Function used to calculate H(z), the Hubble parameter.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H(z) = H_0 E`.
        g      ?i   g      @i   (   R   R)   R   R   R    R   RA   RP   RV   RW   R   (   R\   R   R^   R_   R   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   K  s    	
c         C` s   t  |  r t j |  } n  |  j |  j |  j } } } |  j ra |  j d |  j |  } n |  j |  j	 } d | } | d | | | | | d d | d S(   u   Function used to calculate :math:`\frac{1}{H_z}`.

        Parameters
        ----------
        z : array-like
          Input redshifts.

        Returns
        -------
        E : ndarray, or float if input scalar
          The inverse redshift scaling of the Hubble constant.

        Notes
        -----
        The return value, E, is defined such that :math:`H_z = H_0 / E`.
        g      ?i   g      @g      (
   R   R)   R   R   R    R   RA   RP   RV   RW   (   R\   R   R^   R_   R   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRY   i  s    	
c      
   C` sI   d } | j  |  j   |  j |  j |  j |  j |  j |  j t |  j	   S(   NuY   {0}H0={1:.3g}, Om0={2:.3g}, w0={3:.3g}, Tcmb0={4:.4g}, Neff={5:.3g}, m_nu={6}, Ob0={7:s})(
   Rj   Rl   R/   R   R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo     s    !N(   R   R   R   R&   R'   RD   R!   Ri   R   RY   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s   6$		t   w0waCDMc           B` st   e  Z d  Z d d d d e j d e j  d d d  Z e d    Z	 e d    Z
 d   Z d	   Z d
   Z RS(   u~	  FLRW cosmology with a CPL dark energy equation of state and curvature.

    The equation for the dark energy equation of state uses the
    CPL form as described in Chevallier & Polarski Int. J. Mod. Phys.
    D10, 213 (2001) and Linder PRL 90, 91301 (2003):
    :math:`w(z) = w_0 + w_a (1-a) = w_0 + w_a z / (1+z)`.

    Parameters
    ----------
    H0 : float or `~astropy.units.Quantity`
        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.

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

    w0 : float, optional
        Dark energy equation of state at z=0 (a=1). This is pressure/density
        for dark energy in units where c=1.

    wa : float, optional
        Negative derivative of the dark energy equation of state with respect
        to the scale factor. A cosmological constant has w0=-1.0 and wa=0.0.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import w0waCDM
    >>> cosmo = w0waCDM(H0=70, Om0=0.3, Ode0=0.7, w0=-0.9, wa=0.2)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      g        i    gRQ@c         C` s,  t  j |  | | | | | | d |
 d |	 t |  |  _ t |  |  _ |  j j d k r t j |  _	 |  j
 |  j |  j |  j |  j f |  _ n |  j s t j |  _	 |  j
 |  j |  j |  j |  j |  j |  j f |  _ nK t j |  _	 |  j
 |  j |  j |  j |  j |  j |  j |  j |  j f	 |  _ d  S(   NR%   Rc   i    (   R   Ri   R   R   t   _waR*   R0   R   t   w0wacdm_inv_efunc_norelRZ   R   R    RX   R[   RA   t   w0wacdm_inv_efunc_nomnuRP   RW   t   w0wacdm_inv_efuncRB   RF   RU   (   R\   R]   R^   R_   R   t   waR`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi     s&    $	c         C` s   |  j  S(   u%    Dark energy equation of state at z=0(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    c         C` s   |  j  S(   u>    Negative derivative of dark energy equation of state w.r.t. a(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    c         C` s8   t  |  r t j |  } n  |  j |  j | d | S(   un  Returns dark energy equation of state at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.  Here this is
        :math:`w(z) = w_0 + w_a (1 - a) = w_0 + w_a \frac{z}{1+z}`.
        g      ?(   R   R)   R   R   R   (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg     s    c         C` s^   t  |  r t j |  } n  d | } | d d |  j |  j t j d |  j | |  S(   uL   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

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

        .. math::

          I = \left(1 + z\right)^{3 \left(1 + w_0 + w_a\right)}
          \exp \left(-3 w_a \frac{z}{1+z}\right)

        g      ?i   i   i(   R   R)   R   R   R   R   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   	  s
    
c         C` sU   d } | j  |  j   |  j |  j |  j |  j |  j |  j |  j |  j	 t
 |  j  
 S(   Nus   {0}H0={1:.3g}, Om0={2:.3g}, Ode0={3:.3g}, w0={4:.3g}, wa={5:.3g}, Tcmb0={6:.4g}, Neff={7:.3g}, m_nu={8}, Ob0={9:s})(   Rj   Rl   R/   R   R    R   R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo   -	  s
    N(   R   R   R   R&   R'   RD   R!   Ri   R   R   R   Rg   R   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s   >	$		t   Flatw0waCDMc           B` sD   e  Z d  Z d d d d e j d e j  d d d  Z d   Z RS(   u	  FLRW cosmology with a CPL dark energy equation of state and no
    curvature.

    The equation for the dark energy equation of state uses the
    CPL form as described in Chevallier & Polarski Int. J. Mod. Phys.
    D10, 213 (2001) and Linder PRL 90, 91301 (2003):
    :math:`w(z) = w_0 + w_a (1-a) = w_0 + w_a z / (1+z)`.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

    w0 : float, optional
        Dark energy equation of state at z=0 (a=1). This is pressure/density
        for dark energy in units where c=1.

    wa : float, optional
        Negative derivative of the dark energy equation of state with respect
        to the scale factor. A cosmological constant has w0=-1.0 and wa=0.0.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import Flatw0waCDM
    >>> cosmo = Flatw0waCDM(H0=70, Om0=0.3, w0=-0.9, wa=0.2)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      g        i    gRQ@c
   
      C` s8  t  j |  | | d d | d | d | d | d | d |	 d | d	 |  j |  j |  j |  _ d |  _ |  j j d
 k r t	 j
 |  _ |  j |  j |  j |  j f |  _ n |  j s t	 j |  _ |  j |  j |  j |  j |  j |  j f |  _ nE t	 j |  _ |  j |  j |  j |  j |  j |  j |  j |  j f |  _ d  S(   Ng        R   R   R`   Ra   Rb   R%   Rc   g      ?i    (   R   Ri   R   RP   RW   R    RX   R*   R0   R   t   fw0wacdm_inv_efunc_norelRZ   R   R   R[   RA   t   fw0wacdm_inv_efunc_nomnut   fw0wacdm_inv_efuncRB   RF   RU   (
   R\   R]   R^   R   R   R`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi   u	  s&    '		c      
   C` sI   d } | j  |  j   |  j |  j |  j |  j |  j |  j t |  j	   S(   NuY   {0}H0={1:.3g}, Om0={2:.3g}, w0={3:.3g}, Tcmb0={4:.4g}, Neff={5:.3g}, m_nu={6}, Ob0={7:s})(
   Rj   Rl   R/   R   R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo   	  s    !N(	   R   R   R   R&   R'   RD   R!   Ri   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   7	  s   <	$t   wpwaCDMc        	   B` s   e  Z d  Z d d d d d e j d e j  d d d  Z e d    Z	 e d    Z
 e d    Z d	   Z d
   Z d   Z RS(   u
  FLRW cosmology with a CPL dark energy equation of state, a pivot
    redshift, and curvature.

    The equation for the dark energy equation of state uses the
    CPL form as described in Chevallier & Polarski Int. J. Mod. Phys.
    D10, 213 (2001) and Linder PRL 90, 91301 (2003), but modified
    to have a pivot redshift as in the findings of the Dark Energy
    Task Force (Albrecht et al. arXiv:0901.0721 (2009)):
    :math:`w(a) = w_p + w_a (a_p - a) = w_p + w_a( 1/(1+zp) - 1/(1+z) )`.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

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

    wp : float, optional
        Dark energy equation of state at the pivot redshift zp. This is
        pressure/density for dark energy in units where c=1.

    wa : float, optional
        Negative derivative of the dark energy equation of state with respect
        to the scale factor. A cosmological constant has wp=-1.0 and wa=0.0.

    zp : float, optional
        Pivot redshift -- the redshift where w(z) = wp

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import wpwaCDM
    >>> cosmo = wpwaCDM(H0=70, Om0=0.3, Ode0=0.7, wp=-0.9, wa=0.2, zp=0.4)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      g        i    gRQ@c         C` sU  t  j |  | | | | | |	 d | d |
 t |  |  _ t |  |  _ t |  |  _ d d |  j } |  j j d k r t j	 |  _
 |  j |  j |  j |  j | |  j f |  _ n |  j st j |  _
 |  j |  j |  j |  j |  j |  j | |  j f |  _ nN t j |  _
 |  j |  j |  j |  j |  j |  j |  j |  j | |  j f
 |  _ d  S(   NR%   Rc   g      ?i    (   R   Ri   R   t   _wpR   t   _zpR*   R0   R   t   wpwacdm_inv_efunc_norelRZ   R   R    RX   R[   RA   t   wpwacdm_inv_efunc_nomnuRP   RW   t   wpwacdm_inv_efuncRB   RF   RU   (   R\   R]   R^   R_   t   wpR   t   zpR`   Ra   Rb   Rc   R%   t   apiv(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi   	  s*    $	c         C` s   |  j  S(   u7    Dark energy equation of state at the pivot redshift zp(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR  	  s    c         C` s   |  j  S(   u>    Negative derivative of dark energy equation of state w.r.t. a(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   
  s    c         C` s   |  j  S(   u$    The pivot redshift, where w(z) = wp(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR  	
  s    c         C` sM   t  |  r t j |  } n  d d |  j } |  j |  j | d d | S(   u  Returns dark energy equation of state at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.  Here this is
        :math:`w(z) = w_p + w_a (a_p - a)` where :math:`a = 1/1+z`
        and :math:`a_p = 1 / 1 + z_p`.
        g      ?(   R   R)   R   R   R   R   (   R\   R   R  (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg   
  s    c         C` ss   t  |  r t j |  } n  d | } d d |  j } | d d |  j | |  j t j d |  j | |  S(   ur   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

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

        .. math::

          a_p = \frac{1}{1 + z_p}

          I = \left(1 + z\right)^{3 \left(1 + w_p + a_p w_a\right)}
          \exp \left(-3 w_a \frac{z}{1+z}\right)
        g      ?g      @g      (   R   R)   R   R   R   R   R   (   R\   R   R   R  (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   +
  s    
c         C` s[   d } | j  |  j   |  j |  j |  j |  j |  j |  j |  j |  j	 |  j
 t |  j   S(   Nu   {0}H0={1:.3g}, Om0={2:.3g}, Ode0={3:.3g}, wp={4:.3g}, wa={5:.3g}, zp={6:.3g}, Tcmb0={7:.4g}, Neff={8:.3g}, m_nu={9}, Ob0={10:s})(   Rj   Rl   R/   R   R    R   R   R   R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo   L
  s
    N(   R   R   R   R&   R'   RD   R!   Ri   R   R  R   R  Rg   R   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   	  s   E			!t   w0wzCDMc           B` st   e  Z d  Z d d d d e j d e j  d d d  Z e d    Z	 e d    Z
 d   Z d	   Z d
   Z RS(   u	  FLRW cosmology with a variable dark energy equation of state
    and curvature.

    The equation for the dark energy equation of state uses the
    simple form: :math:`w(z) = w_0 + w_z z`.

    This form is not recommended for z > 1.

    Parameters
    ----------

    H0 : float or `~astropy.units.Quantity`
        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.

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

    w0 : float, optional
        Dark energy equation of state at z=0. This is pressure/density for
        dark energy in units where c=1.

    wz : float, optional
        Derivative of the dark energy equation of state with respect to z.
        A cosmological constant has w0=-1.0 and wz=0.0.

    Tcmb0 : float or scalar `~astropy.units.Quantity`, 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 : `~astropy.units.Quantity`, optional
        Mass of each neutrino species. 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, optional
        Name for this cosmological object.

    Examples
    --------
    >>> from astropy.cosmology import w0wzCDM
    >>> cosmo = w0wzCDM(H0=70, Om0=0.3, Ode0=0.7, w0=-0.9, wz=0.2)

    The comoving distance in Mpc at redshift z:

    >>> z = 0.5
    >>> dc = cosmo.comoving_distance(z)
    g      g        i    gRQ@c         C` s,  t  j |  | | | | | | d |
 d |	 t |  |  _ t |  |  _ |  j j d k r t j |  _	 |  j
 |  j |  j |  j |  j f |  _ n |  j s t j |  _	 |  j
 |  j |  j |  j |  j |  j |  j f |  _ nK t j |  _	 |  j
 |  j |  j |  j |  j |  j |  j |  j |  j f	 |  _ d  S(   NR%   Rc   i    (   R   Ri   R   R   t   _wzR*   R0   R   t   w0wzcdm_inv_efunc_norelRZ   R   R    RX   R[   RA   t   w0wzcdm_inv_efunc_nomnuRP   RW   t   w0wzcdm_inv_efuncRB   RF   RU   (   R\   R]   R^   R_   R   t   wzR`   Ra   Rb   Rc   R%   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRi   
  s&    $	c         C` s   |  j  S(   u%    Dark energy equation of state at z=0(   R   (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   
  s    c         C` s   |  j  S(   u9    Derivative of the dark energy equation of state w.r.t. z(   R  (   R\   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR  
  s    c         C` s0   t  |  r t j |  } n  |  j |  j | S(   uW  Returns dark energy equation of state at redshift ``z``.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

        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.  Here this is given by
        :math:`w(z) = w_0 + w_z z`.
        (   R   R)   R   R   R  (   R\   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRg   
  s    c         C` sZ   t  |  r t j |  } n  d | } | d d |  j |  j t j d |  j |  S(   u?   Evaluates the redshift dependence of the dark energy density.

        Parameters
        ----------
        z : array-like
          Input redshifts.

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

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

        .. math::

          I = \left(1 + z\right)^{3 \left(1 + w_0 - w_z\right)}
          \exp \left(-3 w_z z\right)
        g      ?g      @g      (   R   R)   R   R   R  R   (   R\   R   R   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR   
  s
    
c         C` sU   d } | j  |  j   |  j |  j |  j |  j |  j |  j |  j |  j	 t
 |  j  
 S(   Nur   {0}H0={1:.3g}, Om0={2:.3g}, Ode0={3:.3g}, w0={4:.3g}, wz={5:.3g} Tcmb0={6:.4g}, Neff={7:.3g}, m_nu={8}, Ob0={9:s})(   Rj   Rl   R/   R   R    R   R  R*   R$   Rb   Rm   R"   (   R\   Rn   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRo   
  s    N(   R   R   R   R&   R'   RD   R!   Ri   R   R   R  Rg   R   Ro   (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR  V
  s   @			c         C` s8   |  d k r t |   Sd j |  d | } | j |   S(   uA    Helper function to format a variable that can be a float or Noneu   {0:.{digits}g}t   digitsN(   R!   t   strRj   (   t   xR  t   fmtstr(    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyRm      s    
c         G` s6   t  t t |   r( t j |   |   S|  |   Sd S(   u7    Helper function to vectorize functions on array inputsN(   t   anyR   R   R)   t	   vectorize(   t   funcR  (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR     s    u   flatu   H0u   Om0R`   u   Tcmb0Ra   u   NeffRb   u   m_nuR%   Rc   u   Ob0u1   {} instance of FlatLambdaCDM cosmology

(from {})u	   referenceu   Ode0u-   {} instance of LambdaCDM cosmology

(from {})t   default_cosmologyc           B` s2   e  Z d  Z d Z e d    Z e d    Z RS(   uT  
    The default cosmology to use.  To change it::

        >>> from astropy.cosmology import default_cosmology, WMAP7
        >>> with default_cosmology.set(WMAP7):
        ...     # WMAP7 cosmology in effect

    Or, you may use a string::

        >>> with default_cosmology.set('WMAP7'):
        ...     # WMAP7 cosmology in effect
    u   WMAP9c         C` sh   |  d k r d } nO y t t j t |   } Wn2 t k
 rc d j |  t j  } t	 |   n X| S(   u4    Return a cosmology instance from a string.
        u
   no_defaultu-   Unknown cosmology '{}'. Valid cosmologies:
{}N(
   R!   R~   t   syst   modulesR   R   Rj   R   t	   availableR   (   R   t   cosmoR-   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   get_cosmology_from_string@  s    	c         C` sW   | d  k r d } n  t | t j  r4 |  j |  St | t  rG | St d   d  S(   Nu   Planck15u9   default_cosmology must be a string or Cosmology instance.(   R!   RC   R   t   string_typesR  R   t	   TypeError(   t   clsR0   (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   validateO  s    	(   R   R   R   t   _valuet   staticmethodR  t   classmethodR  (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyR  1  s   (T   t
   __future__R    R   R   R   t   externR   t   extern.six.movesR   R  t   mathR   R   R   R	   R
   t   abcR   R   t   numpyR)   t    R   R   R2   R   R&   t   utilsR   t   utils.compat.funcsigsR   t   utils.stateR   R   R  t   __all__t   __doctest_requires__R,   R-   R.   R4   R6   R8   R7   t   GR0   R:   R   R   t   sigma_sbR3   RO   t   k_BRD   R(   RR   t	   ExceptionR   t   objectR   t   add_metaclassR   R   R   R   R   R   R   R   R  Rm   R   t   keyR~   t   parR'   R  t   docstrRj   R   t   setattrR  R   R  (    (    (    s5   lib/python2.7/site-packages/astropy/cosmology/core.pyt   <module>   s|   "(	''     c	

	