ó
šßÈ[c           @` s  d  d l  m Z m Z m Z m Z d  d l Z d d l m Z m	 Z	 m
 Z
 d d l m Z d d l m Z m Z d d l m Z m Z m Z d	 d
 d d d d d d d d d d g Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d  „  ƒ  YZ d! e f d" „  ƒ  YZ d# e f d$ „  ƒ  YZ e e _ e e _ e e _ e e j ƒ Z d% e _  e e j! ƒ Z" d& e" _  e e j# ƒ Z$ d' j% e j# j& ƒ e$ _  e e j' ƒ Z( d( j% e j' j& ƒ e( _  d S()   i    (   t   absolute_importt   unicode_literalst   divisiont   print_functionNi   (   t   CompositeUnitt
   UnitsErrort   dimensionless_unscaledi   (   t   magnitude_zero_points(   t   FunctionUnitBaset   FunctionQuantity(   t   dext   dBt   magu   LogUnitu   MagUnitu   DexUnitu   DecibelUnitu   LogQuantityu	   Magnitudeu   Decibelu   Dexu   STmagu   ABmagu   M_bolu   m_bolt   LogUnitc           B` st   e  Z d  Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z RS(   uï  Logarithmic unit containing a physical one

    Usually, logarithmic units are instantiated via specific subclasses
    such `MagUnit`, `DecibelUnit`, and `DexUnit`.

    Parameters
    ----------
    physical_unit : `~astropy.units.Unit` or `string`
        Unit that is encapsulated within the logarithmic function unit.
        If not given, dimensionless.

    function_unit :  `~astropy.units.Unit` or `string`
        By default, the same as the logarithmic unit set by the subclass.

    c         C` s   t  S(   N(   R
   (   t   self(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   _default_function_unit#   s    c         C` s   t  S(   N(   t   LogQuantity(   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   _quantity_class'   s    c         C` s   t  j |  j t j | ƒ ƒ S(   ua   Transformation from value in physical to value in logarithmic units.
        Used in equivalency.(   R
   t   tot   _function_unitt   npt   log10(   R   t   x(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   from_physical+   s    c         C` s   d |  j  j t | ƒ S(   ua   Transformation from value in logarithmic to value in physical units.
        Used in equivalency.i
   (   R   R   R
   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   to_physical0   s    c         C` s‘   y  t  | d | ƒ j |  j ƒ Wn. t k
 r4 t St k
 rP t d ƒ ‚ n Xt  | d t ƒ } t d |  j | g | | g ƒ } |  j	 | ƒ S(   u›  Add/subtract LogUnit to/from another unit, and adjust physical unit.

        self and other are multiplied by sign_self and sign_other, resp.

        We wish to do:   Â±lu_1 + Â±lu_2  -> lu_f          (lu=logarithmic unit)
                  and     pu_1^(Â±1) * pu_2^(Â±1) -> pu_f  (pu=physical unit)

        Raises
        ------
        UnitsError
            If function units are not equivalent.
        u   function_unitu=   Can only add/subtract logarithmic units ofof compatible type.u   physical_uniti   (
   t   getattrt   _toR   t   AttributeErrort   NotImplementedR   R   R   t   _physical_unitt   _copy(   R   t   othert	   sign_selft
   sign_othert   other_physical_unitt   physical_unit(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   _add_and_adjust_physical_unit8   s     		c         C` s   |  j  |  j d ƒ S(   Niÿÿÿÿ(   R   R#   (   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __neg__Y   s    c         C` s   |  j  | d 
d 
ƒ S(   Ni   (   R$   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __add__\   s    c         C` s   |  j  | d 
d 
ƒ S(   Ni   (   R$   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __radd__a   s    c         C` s   |  j  | d 
d ƒ S(   Ni   iÿÿÿÿ(   R$   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __sub__d   s    c         C` s   |  j  | d d 
ƒ S(   Niÿÿÿÿi   (   R$   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __rsub__g   s    (   t   __name__t
   __module__t   __doc__t   propertyR   R   R   R   R$   R%   R&   R'   R(   R)   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR      s   			!				t   MagUnitc           B` s5   e  Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   u  Logarithmic physical units expressed in magnitudes

    Parameters
    ----------
    physical_unit : `~astropy.units.Unit` or `string`
        Unit that is encapsulated within the magnitude function unit.
        If not given, dimensionless.

    function_unit :  `~astropy.units.Unit` or `string`
        By default, this is ``mag``, but this allows one to use an equivalent
        unit such as ``2 mag``.
    c         O` s0   t  j ƒ   t t |  ƒ j | | Ž  Wd  QXd  S(   N(   t   mag0t   enablet   superR.   t   __init__(   R   t   argst   kwargs(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR2   z   s    c         C` s   t  S(   N(   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR      s    c         C` s   t  S(   N(   t	   Magnitude(   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   ƒ   s    (   R*   R+   R,   R2   R-   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR.   m   s   	t   DexUnitc           B` s,   e  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   už  Logarithmic physical units expressed in magnitudes

    Parameters
    ----------
    physical_unit : `~astropy.units.Unit` or `string`
        Unit that is encapsulated within the magnitude function unit.
        If not given, dimensionless.

    function_unit :  `~astropy.units.Unit` or `string`
        By default, this is ``dex`, but this allows one to use an equivalent
        unit such as ``0.5 dex``.
    c         C` s   t  S(   N(   R
   (   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   –   s    c         C` s   t  S(   N(   t   Dex(   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   š   s    (   R*   R+   R,   R-   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR6   ˆ   s   t   DecibelUnitc           B` s,   e  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   u‘  Logarithmic physical units expressed in dB

    Parameters
    ----------
    physical_unit : `~astropy.units.Unit` or `string`
        Unit that is encapsulated within the decibel function unit.
        If not given, dimensionless.

    function_unit :  `~astropy.units.Unit` or `string`
        By default, this is ``dB``, but this allows one to use an equivalent
        unit such as ``2 dB``.
    c         C` s   t  S(   N(   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   ­   s    c         C` s   t  S(   N(   t   Decibel(   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   ±   s    (   R*   R+   R,   R-   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR8   Ÿ   s   R   c           B` s¾   e  Z d  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d d d d d „ Z d d d d d	 „ Z d d d
 „ Z d d d „ Z d d d „ Z e j e d „  d Dƒ ƒ BZ RS(   u  A representation of a (scaled) logarithm of a number with a unit

    Parameters
    ----------
    value : number, `~astropy.units.Quantity`, `~astropy.units.function.logarithmic.LogQuantity`, or sequence of convertible items.
        The numerical value of the logarithmic quantity. If a number or
        a `~astropy.units.Quantity` with a logarithmic unit, it will be
        converted to ``unit`` and the physical unit will be inferred from
        ``unit``.  If a `~astropy.units.Quantity` with just a physical unit,
        it will converted to the logarithmic unit, after, if necessary,
        converting it to the physical unit inferred from ``unit``.

    unit : string, `~astropy.units.UnitBase` or `~astropy.units.function.FunctionUnitBase` instance, optional
        For an `~astropy.units.function.FunctionUnitBase` instance, the
        physical unit will be taken from it; for other input, it will be
        inferred from ``value``. By default, ``unit`` is set by the subclass.

    dtype : `~numpy.dtype`, optional
        The ``dtype`` of the resulting Numpy array or scalar that will
        hold the value.  If not provided, is is determined automatically
        from the input value.

    copy : bool, optional
        If `True` (default), then the value is copied.  Otherwise, a copy will
        only be made if ``__array__`` returns a copy, if value is a nested
        sequence, or if a copy is needed to satisfy an explicitly given
        ``dtype``.  (The `False` option is intended mostly for internal use,
        to speed up initialization where a copy is known to have been made.
        Use with care.)

    Examples
    --------
    Typically, use is made of an `~astropy.units.function.FunctionQuantity`
    subclass, as in::

        >>> import astropy.units as u
        >>> u.Magnitude(-2.5)
        <Magnitude -2.5 mag>
        >>> u.Magnitude(10.*u.count/u.second)
        <Magnitude -2.5 mag(ct / s)>
        >>> u.Decibel(1.*u.W, u.DecibelUnit(u.mW))  # doctest: +FLOAT_CMP
        <Decibel 30. dB(mW)>

    c         C` sB   |  j  t | d t ƒ } |  j t | d | ƒ } |  j | | ƒ S(   Nu   unitu   _function_view(   t   unitR   R   t   _function_viewt	   _new_view(   R   R   t   new_unitt   result(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR&   ç   s    c         C` s   |  j  | ƒ S(   N(   R&   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR'   ð   s    c         C` sI   |  j  t | d t ƒ } |  j } | t | d | ƒ 7} |  j | ƒ |  S(   Nu   unitu   _function_view(   R:   R   R   R;   t	   _set_unit(   R   R   R=   t   function_view(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __iadd__ó   s
    	c         C` sB   |  j  t | d t ƒ } |  j t | d | ƒ } |  j | | ƒ S(   Nu   unitu   _function_view(   R:   R   R   R;   R<   (   R   R   R=   R>   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR(   û   s    c         C` s^   |  j  j t | d t ƒ ƒ } |  j j t | d | ƒ ƒ } | j | j ƒ } |  j | | ƒ S(   Nu   unitu   _function_view(   R:   R)   R   R   R;   R   t   function_unitR<   (   R   R   R=   R>   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR)     s    		c         C` sI   |  j  t | d t ƒ } |  j } | t | d | ƒ 8} |  j | ƒ |  S(   Nu   unitu   _function_view(   R:   R   R   R;   R?   (   R   R   R=   R@   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   __isub__  s
    	i    c         C` s2   |  j  t j | | d | d | d |  j j d ƒS(   Nt   outt   ddofR:   i   (   t   _wrap_functionR   t   varR:   RB   (   R   t   axist   dtypeRD   RE   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyRG     s    !c         C` s4   |  j  t j | | d | d | d |  j j t ƒ ƒS(   NRD   RE   R:   (   RF   R   t   stdR:   R   R   (   R   RH   RI   RD   RE   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyRJ     s    !c         C` s+   |  j  t j | d | d |  j j t ƒ ƒS(   NRD   R:   (   RF   R   t   ptpR:   R   R   (   R   RH   RD   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyRK   "  s    i   iÿÿÿÿc         C` s(   |  j  t j | | d |  j j t ƒ ƒS(   NR:   (   RF   R   t   diffR:   R   R   (   R   t   nRH   (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyRL   &  s    c         C` s(   |  j  t j | | d |  j j t ƒ ƒS(   NR:   (   RF   R   t   ediff1dR:   R   R   (   R   t   to_endt   to_begin(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyRN   *  s    c         c` s   |  ] } t  t | ƒ Vq d  S(   N(   R   R   (   t   .0t   function(    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pys	   <genexpr>/  s    u   varu   stdu   ptpu   diffu   ediff1dN(   u   varu   stdu   ptpu   diffu   ediff1d(   R*   R+   R,   R   t   _unit_classR&   R'   RA   R(   R)   RC   t   NoneRG   RJ   RK   RL   RN   R	   t   _supported_functionst   set(    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR   ¶   s    ,						
		R7   c           B` s   e  Z e Z RS(    (   R*   R+   R6   RS   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR7   3  s   R9   c           B` s   e  Z e Z RS(    (   R*   R+   R8   RS   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR9   7  s   R5   c           B` s   e  Z e Z RS(    (   R*   R+   R.   RS   (    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyR5   ;  s   u6   ST magnitude: STmag=-21.1 corresponds to 1 erg/s/cm2/Au7   AB magnitude: ABmag=-48.6 corresponds to 1 erg/s/cm2/Hzu@   Absolute bolometric magnitude: M_bol=0 corresponds to L_bol0={0}u@   Apparent bolometric magnitude: m_bol=0 corresponds to f_bol0={0}()   t
   __future__R    R   R   R   t   numpyR   t    R   R   R   R   R/   t   coreR   R	   t   unitsR
   R   R   t   __all__R   R.   R6   R8   R   R7   R9   R5   t   _function_unit_classt   STt   STmagR,   t   ABt   ABmagt   Bolt   M_bolt   formatt   sit   bolt   m_bol(    (    (    sA   lib/python2.7/site-packages/astropy/units/function/logarithmic.pyt   <module>   s:   "[}					