
[c           @` sy  d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l Z d d l	 m
 Z
 d d l Z d d l Z d d l j Z d d l m Z m Z m Z d d l m Z d d	 l m Z d d
 l m Z m Z d d l m Z d d l m Z m  Z  d d l! m" Z" m# Z# d d d d d d d d d d d d d d d d d d d  g Z$ i  Z% i  Z& d! d"  Z' d d#  Z( d$ e f d%     YZ) d&   Z* d' e e j+ f d(     YZ, e j- e,  d) e) f d*     Y Z. d+ e. f d,     YZ/ d- e. f d.     YZ0 d/ e. f d0     YZ1 d1 e. f d2     YZ2 d3 e. f d4     YZ3 d5 e. f d6     YZ4 d7 e e j+ f d8     YZ5 e j- e5  d9 e) f d:     Y Z6 d; e6 f d<     YZ7 d= e6 f d>     YZ8 d? e8 f d@     YZ9 dA e8 f dB     YZ: dC e6 f dD     YZ; dE e; f dF     YZ< dG e; f dH     YZ= dI e6 f dJ     YZ> dK e6 f dL     YZ? dM e6 f dN     YZ@ d S(O   u   
In this module, we define the coordinate representation classes, which are
used to represent low-level cartesian, spherical, cylindrical, and other
coordinates.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   OrderedDicti   (   t   Anglet	   Longitudet   Latitude(   t   Distancei   (   t   six(   t   ShapedLikeNDArrayt   classproperty(   t   InheritDocstrings(   t   NUMPY_LT_1_12t   NUMPY_LT_1_14(   t   broadcast_arrayst   broadcast_tou    BaseRepresentationOrDifferentialu   BaseRepresentationu   CartesianRepresentationu   SphericalRepresentationu   UnitSphericalRepresentationu   RadialRepresentationu   PhysicsSphericalRepresentationu   CylindricalRepresentationu   BaseDifferentialu   CartesianDifferentialu   BaseSphericalDifferentialu   BaseSphericalCosLatDifferentialu   SphericalDifferentialu   SphericalCosLatDifferentialu   UnitSphericalDifferentialu   UnitSphericalCosLatDifferentialu   RadialDifferentialu   CylindricalDifferentialu   PhysicsSphericalDifferentialu    c      	   ` s   i d d 6| d 6} t  r d d l m } t j   } g  |  j j D]9 } | t j |  |  j   d | d d | d	 ^ qC     f d
   } i | d 6| d <| | d <n i  | d <t	 r t
 | d <n  t j |  |  S(   Nu   , u	   separatoru   prefixi    (   t   FloatFormatt	   precisionu	   precisiont   suppress_smallu   suppressc         ` s)   d j  d j d   t |     D   S(   Nu   ({})u   , c         s` s!   |  ] \ } } | |  Vq d  S(   N(    (   t   .0t   fieldt   format_function(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>=   s   (   t   formatt   joint   zip(   t   x(   t   format_functions(    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   fmt<   s    u   numpystru	   formatteru   style(   R   t   numpy.core.arrayprintR   t   npt   get_printoptionst   dtypet   namest
   atleast_1dt   ravelR   t   reprt   array2string(   t   valuest   prefixt   kwargsR   t   optst	   componentR   (    (   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _array2string/   s    I
c   	      C` s  |  j  d } | | k o% | k  n sE t d j | |    n  | d k  r^ | | 7} n  |  j } | | |  j d t } | | |  j d t } |  j } | |  d | | } t j g  |  | | f D] } | j	 |  j
 ^ q d | } | | d |  j d t S(   u	  
    Combine components ``x``, ``y``, ``z`` into a single Quantity array.

    Parameters
    ----------
    x, y, z : `~astropy.units.Quantity`
        The individual x, y, and z components.
    xyz_axis : int, optional
        The axis in the final array along which the x, y, z components
        should be stored (default: 0).

    Returns
    -------
    xyz : `~astropy.units.Quantity`
        With dimension 3 along ``xyz_axis``, i.e., using the default of ``0``,
        the shape will be ``(3,) + x.shape``.
    i   u&   xyz_axis {0} out of bounds [-{1}, {1})i    t   copyt   axist   unit(   i   (   t   ndimt
   IndexErrorR   t	   __class__R.   t   Falset   shapeR   t   concatenatet   reshapet   value(	   R   t   yt   zt   xyz_axist   result_ndimt   clst   sht   ct	   xyz_value(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _combine_xyzM   s    			4	t    BaseRepresentationOrDifferentialc           B` sI  e  Z d  Z d Z d   Z e d    Z e j d    Z	 e j d    Z
 e d    Z d   Z e d    Z e j d	    Z e j d
    Z d   Z d   Z d   Z d   Z d   Z d   Z e j e d   Z d   Z d   Z d   Z d   Z e d    Z e d    Z e d    Z d   Z  d   Z! RS(   u  3D coordinate representations and differentials.

    Parameters
    ----------
    comp1, comp2, comp3 : `~astropy.units.Quantity` or subclass
        The components of the 3D point or differential.  The names are the
        keys and the subclasses the values of the ``attr_classes`` attribute.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    iP  c   	      O` s  t  |  } |  j } g  } xf | D]^ } y/ | j | rF | j d  n | j |   Wq" t k
 r t d j |    q" Xq" W| r | j d  n | j d t  } | r t d j |    n  | rx2 | D]* } | | k r t d j |    q q Wt d j |    n  g  t | |  D]% \ } } |  j	 | | d | ^ q,} y t
 d t |  } Wni t k
 rt |  d	 k rd
 j |  } n d j | d	   d | d	 } t d j |    n Xx1 t | |  D]  \ } } t |  d | |  qWd  S(   Ni    u8   __init__() missing 1 required positional argument: {0!r}u   copyu   unexpected arguments: {0}u1   __init__() got multiple values for argument {0!r}u!   unexpected keyword arguments: {0}R,   t   suboki   u    and u   , u   , and u(   Input parameters {0} cannot be broadcastu   _(   t   listt
   componentst   appendt   popt   KeyErrort	   TypeErrorR   t   TrueR   t   attr_classesR   t
   ValueErrort   lenR   t   setattr(	   t   selft   argsR(   RC   t   attrsR*   R,   t   attrt   c_str(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __init__   s<    	/	'	8	c         C` sK   |  j  j   } | j d  r+ | d  } n | j d  rG | d  } n  | S(   u  Name of the representation or differential.

        In lower case, with any trailing 'representation' or 'differential'
        removed. (E.g., 'spherical' for
        `~astropy.coordinates.SphericalRepresentation` or
        `~astropy.coordinates.SphericalDifferential`.)
        u   representationiu   differentiali(   t   __name__t   lowert   endswith(   R;   t   name(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   get_name   s    	c         C` s   t     d S(   u[  Create a representation of this class from a supplied Cartesian one.

        Parameters
        ----------
        other : `CartesianRepresentation`
            The representation to turn into this class

        Returns
        -------
        representation : object of this class
            A new representation of this class's type.
        N(   t   NotImplementedError(   RM   t   other(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   from_cartesian   s    c         C` s   t     d S(   u   Convert the representation to its Cartesian form.

        Note that any differentials get dropped.

        Returns
        -------
        cartrepr : `CartesianRepresentation`
            The representation in Cartesian form.
        N(   RX   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   to_cartesian   s    c         C` s   t  |  j  S(   u=   A tuple with the in-order names of the coordinate components.(   t   tupleRI   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRC      s    c      	   ` sq   t    r$     f d   } n t j      } |  j d t g  |  j D] } | t |  |   ^ qO  S(   uE  Create a new representation or differential with ``method`` applied
        to the component data.

        In typical usage, the method is any of the shape-changing methods for
        `~numpy.ndarray` (``reshape``, ``swapaxes``, etc.), as well as those
        picking particular elements (``__getitem__``, ``take``, etc.), which
        are all defined in `~astropy.utils.misc.ShapedLikeNDArray`. It will be
        applied to the underlying arrays (e.g., ``x``, ``y``, and ``z`` for
        `~astropy.coordinates.CartesianRepresentation`), with the results used
        to create a new instance.

        Internally, it is also used to apply functions to the components
        (in particular, `~numpy.broadcast_to`).

        Parameters
        ----------
        method : str or callable
            If str, it is the name of a method that is applied to the internal
            ``components``. If callable, the function is applied.
        args : tuple
            Any positional arguments for ``method``.
        kwargs : dict
            Any keyword arguments for ``method``.
        c         ` s    |      S(   N(    (   t   array(   RN   R(   t   method(    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   <lambda>  s    R,   (   t   callablet   operatort   methodcallerR1   R2   RC   t   getattr(   RM   R^   RN   R(   t   apply_methodR*   (    (   RN   R(   R^   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _apply   s
    	c         C` s   t  |  |  j d  j S(   u  The shape of the instance and underlying arrays.

        Like `~numpy.ndarray.shape`, can be set to a new shape by assigning a
        tuple.  Note that if different instances share some but not all
        underlying data, setting the shape of one instance can make the other
        instance unusable.  Hence, it is strongly recommended to get new,
        reshaped instances with the ``reshape`` method.

        Raises
        ------
        AttributeError
            If the shape of any of the components cannot be changed without the
            arrays being copied.  For these cases, use the ``reshape`` method
            (which copies any arrays that cannot be reshaped in-place).
        i    (   Rc   RC   R3   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR3   	  s    c         C` s   g  } |  j  } x} |  j D]r } t |  |  } | j d k r y | | _  Wn. t k
 rz x | D] } | | _  qa W  q X| j |  q q Wd  S(   Ni   (   R3   RC   Rc   t   sizet   AttributeErrorRD   (   RM   R3   t   reshapedt   oldshapeR*   t   valt   val2(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR3     s    	c         G` s   t     d  S(   N(   RX   (   RM   t   opRN   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _scale_operation1  s    c         C` s   |  j  t j |  S(   N(   Rm   Ra   t   mul(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __mul__5  s    c         C` s   |  j  |  S(   N(   Ro   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __rmul__8  s    c         C` s   |  j  t j |  S(   N(   Rm   Ra   t   truediv(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __truediv__;  s    c         C` s   |  j  t j |  S(   N(   Rm   Ra   Rq   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __div__>  s    c         C` s   |  j  t j  S(   N(   Rm   Ra   t   neg(   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __neg__A  s    c         C` s
   |  j    S(   N(   R,   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __pos__E  s    c         C` s   t     d  S(   N(   RX   (   RM   Rl   RY   t   reverse(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _combine_operationJ  s    c         C` s   |  j  t j |  S(   N(   Rx   Ra   t   add(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __add__N  s    c         C` s   |  j  t j | d t S(   NRw   (   Rx   Ra   Ry   RH   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __radd__Q  s    c         C` s   |  j  t j |  S(   N(   Rx   Ra   t   sub(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __sub__T  s    c         C` s   |  j  t j | d t S(   NRw   (   Rx   Ra   R|   RH   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __rsub__W  s    c         C` s   g  |  j  D]! } t |  t |  |  f ^ q
 } t j |  j g  | D] \ } } | | j f ^ qD  } x! | D] \ } } | j | | <qo W| S(   u   Turn the coordinates into a record array with the coordinate values.

        The record array fields will have the component names.
        (   RC   t   strRc   R   t   emptyR3   R    R6   (   RM   R=   t	   coo_itemst   coot   result(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _values[  s
    17c         C` s2   t  g  |  j D] } | t |  |  j f ^ q  S(   u@   Return a dictionary with the units of the coordinate components.(   t   dictRC   Rc   R.   (   RM   R*   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _unitsh  s    c         C` s{   t  |  j j    } t |  d k r< | j   j   } n; d j d j g  |  j D] } |  j | j   ^ qR   } | S(   Ni   u   ({0})u   , (	   t   setR   R&   RK   RE   t	   to_stringR   R   RC   (   RM   t	   units_sett   unitstrR*   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _unitstrn  s    	,c         C` s   d j  t |  j  |  j  S(   Nu	   {0} {1:s}(   R   R+   R   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __str__y  s    c         C` s   d } t  |  j d | } d } t |  d d   rp d j d j g  |  j j   D] } t |  ^ qO   } n  |  j	 r d |  j	 n d } d	 j |  j
 j d j |  j  | | | |  S(
   Nu       R'   u    u   differentialsu!   
 (has differentials w.r.t.: {0})u   , u   in u   [dimensionless]u   <{0} ({1}) {2:s}
{3}{4}{5}>(   R+   R   Rc   t   NoneR   R   t   differentialst   keysR$   R   R1   RS   RC   (   RM   t	   prefixstrt   arrstrt   diffstrt   keyR   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   __repr__|  s    7("   RS   t
   __module__t   __doc__t   __array_priority__RR   t   classmethodRW   t   abct   abstractmethodRZ   R[   t   propertyRC   Re   R3   t   setterRm   Ro   Rp   Rr   Rs   Ru   Rv   R2   Rx   Rz   R{   R}   R~   R   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR@   v   s8   
	*	!											c         ` s   d       f d   } | S(   u  Make an attribute getter for use in a property.

    Parameters
    ----------
    component : str
        The name of the component that should be accessed.  This assumes the
        actual value is stored in an attribute of that name prefixed by '_'.
    u   _c         ` s   t  |     S(   N(   Rc   (   RM   (   R*   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   get_component  s    (    (   R*   R   (    (   R*   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _make_getter  s    
t   MetaBaseRepresentationc           B` s   e  Z d    Z RS(   c      	   C` s   t  t |   j | | |  |  j d k r/ d  Sd | k rJ t d   n  |  j   } | t k rz t d j |    n  |  t | <xN |  j	 D]C } t
 |  |  s t |  | t t |  d d j |   q q Wd  S(   Nu   BaseRepresentationu   attr_classesu<   Representations must have an "attr_classes" class attribute.u(   Representation class {0} already definedt   docu%   The '{0}' component of the points(s).(   t   superR   RR   RS   RX   RW   t   REPRESENTATION_CLASSESRJ   R   RI   t   hasattrRL   R   R   (   R;   RV   t   basest   dctt	   repr_nameR*   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s     	
	(   RS   R   RR   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s   t   BaseRepresentationc           B` s   e  Z d  Z i  Z d   Z d   Z d   Z e d    Z e d    Z	 d   Z
 d   Z d   Z d d	  Z d
   Z d   Z e d    Z d   Z d   Z e d  Z e j j d    Z d   Z d   Z d   Z d   Z d   Z RS(   uL  Base for representing a point in a 3D coordinate system.

    Parameters
    ----------
    comp1, comp2, comp3 : `~astropy.units.Quantity` or subclass
        The components of the 3D points.  The names are the keys and the
        subclasses the values of the ``attr_classes`` attribute.
    differentials : dict, `BaseDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single `BaseDifferential`
        subclass instance, or a dictionary with keys set to a string
        representation of the SI unit with which the differential (derivative)
        is taken. For example, for a velocity differential on a positional
        representation, the key would be ``'s'`` for seconds, indicating that
        the derivative is a time derivative.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.

    Notes
    -----
    All representation classes should subclass this base representation class,
    and define an ``attr_classes`` attribute, an `~collections.OrderedDict`
    which maps component names to the class that creates them. They must also
    define a ``to_cartesian`` method and a ``from_cartesian`` class method. By
    default, transformations are done via the cartesian system, but classes
    that want to define a smarter transformation path can overload the
    ``represent_as`` method. If one wants to use an associated differential
    class, one should also define ``unit_vectors`` and ``scale_factors``
    methods (see those methods for details). Finally, classes can also define a
    ``recommended_units`` dictionary, which maps component names to the units
    they are best presented to users in (this is used only in representations
    of coordinates, and may be overridden by frame classes).
    c         O` sA   | j  d d   } t t |   j | |   |  j |  |  _ d  S(   Nu   differentials(   RE   R   R   R   RR   t   _validate_differentialst   _differentials(   RM   RN   R(   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s    c         C` sV  | d k r t   } n[ t | t  rs t | t  rT t |  t  rT t d   n  | j |   } i | | 6} n  x | D] } y | | } Wn t k
 r t d   n X| j	 |   t | t  r t |  t  r n? | j |   } | | k rt d j
 t |  | |    n  | j |  j k rz t d j
 | j |  j    qz qz W| S(   u  
        Validate that the provided differentials are appropriate for this
        representation and recast/reshape as necessary and then return.

        Note that this does *not* set the differentials on
        ``self._differentials``, but rather leaves that for the caller.
        uv   To attach a RadialDifferential to a UnitSphericalRepresentation, you must supply a dictionary with an appropriate key.u9   'differentials' argument must be a dictionary-like objectuQ   For differential object '{0}', expected unit key = '{1}' but received key = '{2}'uW   Shape of differentials must be the same as the shape of the representation ({0} vs {1})N(   R   R   t
   isinstancet   BaseDifferentialt   RadialDifferentialt   UnitSphericalRepresentationRJ   t   _get_deriv_keyRG   t   _check_baseR   R$   R3   (   RM   R   R   t   difft   expected_key(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s2    
		c         C` s.   |  j  r* t d j | |  j j    n  d S(   u   
        Used to raise a consistent exception for any operation that is not
        supported when a representation has differentials attached.
        uJ   Operation '{0}' is not supported when differentials are attached to a {1}.N(   R   RG   R   R1   RS   (   RM   t   op_name(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _raise_if_has_differentials'  s    		c         C` s   t  |  j   g S(   N(   t   DIFFERENTIAL_CLASSESRW   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _compatible_differentials1  s    c         C` s   |  j  S(   u  A dictionary of differential class instances.

        The keys of this dictionary must be a string representation of the SI
        unit with which the differential (derivative) is taken. For example, for
        a velocity differential on a positional representation, the key would be
        ``'s'`` for seconds, indicating that the derivative is a time
        derivative.
        (   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   5  s    
c         C` s   t  d j t |      d S(   u  Cartesian unit vectors in the direction of each component.

        Given unit vectors :math:`\hat{e}_c` and scale factors :math:`f_c`,
        a change in one component of :math:`\delta c` corresponds to a change
        in representation of :math:`\delta c \times f_c \times \hat{e}_c`.

        Returns
        -------
        unit_vectors : dict of `CartesianRepresentation`
            The keys are the component names.
        u#   {} has not implemented unit vectorsN(   RX   R   t   type(   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   unit_vectorsD  s    	c         C` s   t  d j t |      d S(   u  Scale factors for each component's direction.

        Given unit vectors :math:`\hat{e}_c` and scale factors :math:`f_c`,
        a change in one component of :math:`\delta c` corresponds to a change
        in representation of :math:`\delta c \times f_c \times \hat{e}_c`.

        Returns
        -------
        scale_factors : dict of `~astropy.units.Quantity`
            The keys are the component names.
        u%   {} has not implemented scale factors.N(   RX   R   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   scale_factorsS  s    	c         C` sc  | d k r t   S|  j r2 | r2 t d   n t |  j  d k r t j |  r t | t  r i | t	 |  j j
    d 6} n@ t | j
    t |  j j
    k r t d j |  j   n  t   } x |  j D] } |  j | } y! | j | | d |  | | <Wq t k
 rZ| | | j k rTt d j | | | j    q[  q Xq W| S(   u   Re-represent the differentials to the specified classes.

        This returns a new dictionary with the same keys but with the
        attached differentials converted to the new differential classes.
        u5   No differentials associated with this representation!i   i    u   Desired differential classes must be passed in as a dictionary with keys equal to a string representation of the unit of the derivative for each differential stored with this representation object ({0})t   baseuZ   Desired differential class {0} is not compatible with the desired representation class {1}N(   R   R   R   RJ   RK   t   inspectt   isclasst
   issubclassR   RB   R   R   R   t   represent_ast	   ExceptionR   RG   R1   (   RM   t   new_rept   differential_classt	   new_diffst   kR   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _re_represent_differentialsb  s4     '			c         C` ss   | |  j  k r  | r  |  j   St | t j  rA t d   n  | j |  j    } |  j | |  | _	 | Sd S(   u  Convert coordinates to another representation.

        If the instance is of the requested class, it is returned unmodified.
        By default, conversion is done via cartesian coordinates.

        Parameters
        ----------
        other_class : `~astropy.coordinates.BaseRepresentation` subclass
            The type of representation to turn the coordinates into.
        differential_class : dict of `~astropy.coordinates.BaseDifferential`, optional
            Classes in which the differentials should be represented.
            Can be a single class if only a single differential is attached,
            otherwise it should be a `dict` keyed by the same keys as the
            differentials.
        uf   Input to a representation's represent_as must be a class, not a string. For strings, use frame objectsN(
   R1   t   without_differentialsR   R	   t   string_typesRJ   RZ   R[   R   R   (   RM   t   other_classR   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    
c         C` sp   | s
 |  Sg  |  j  D] } t |  |  ^ q } |  j d |  j j   d t |  } | j j | j |   | S(   uC  
        Create a new representation with the same positions as this
        representation, but with these new differentials.

        Differential keys that already exist in this object's differential dict
        are overwritten.

        Parameters
        ----------
        differentials : Sequence of `~astropy.coordinates.BaseDifferential`
            The differentials for the new representation to have.

        Returns
        -------
        newrepr
            A copy of this representation, but with the ``differentials`` as
            its differentials.
        R   R,   (	   RC   Rc   R1   R   R,   R2   R   t   updateR   (   RM   R   R*   RN   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   with_differentials  s    %	c         C` sE   |  j  s |  Sg  |  j D] } t |  |  ^ q } |  j d t |  S(   u
  Return a copy of the representation without attached differentials.

        Returns
        -------
        newrepr
            A shallow copy of this representation, without any differentials.
            If no differentials were present, no copy is made.
        R,   (   R   RC   Rc   R1   R2   (   RM   R*   RN   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    
	%c         C` s   | j  |   S(   u   Create a new instance of this representation from another one.

        Parameters
        ----------
        representation : `~astropy.coordinates.BaseRepresentation` instance
            The presentation that should be converted to this class.
        (   R   (   R;   t   representation(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   from_representation  s    	c         O` sh   t  t |   j | | |  } t g  |  j j   D]' \ } } | | j | | |  f ^ q1  | _ | S(   u  Create a new representation with ``method`` applied to the component
        data.

        This is not a simple inherit from ``BaseRepresentationOrDifferential``
        because we need to call ``._apply()`` on any associated differential
        classes.

        See docstring for `BaseRepresentationOrDifferential._apply`.

        Parameters
        ----------
        method : str or callable
            If str, it is the name of a method that is applied to the internal
            ``components``. If callable, the function is applied.
        args : tuple
            Any positional arguments for ``method``.
        kwargs : dict
            Any keyword arguments for ``method``.

        (   R   R   Re   R   R   t   items(   RM   R^   RN   R(   t   repR   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRe     s
    @c         G` s   |  j  | j  g  } xa |  j j   D]P \ } } t |  |  } t | t  r` | j |  q& | j | | |   q& Wy |  j |   SWn t	 k
 r t
 SXd S(   ue  Scale all non-angular components, leaving angular ones unchanged.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.mul`, `~operator.neg`, etc.
        *args
            Any arguments required for the operator (typically, what is to
            be multiplied with, divided by).
        N(   R   RS   RI   R   Rc   R   R   RD   R1   R   t   NotImplemented(   RM   Rl   RN   t   resultsR*   R;   R6   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRm     s    c         C` sL   |  j  | j  |  j   j | | |  } | t k r; t S|  j |  Sd S(   u  Combine two representation.

        By default, operate on the cartesian representations of both.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.add`, `~operator.sub`, etc.
        other : `~astropy.coordinates.BaseRepresentation` instance
            The other representation.
        reverse : bool
            Whether the operands should be reversed (e.g., as we got here via
            ``self.__rsub__`` because ``self`` is a subclass of ``other``).
        N(   R   RS   R[   Rx   R   RZ   (   RM   Rl   RY   Rw   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   )  s
    c         C` s   |  j  } t j  j |  |  y( x! |  j D] } | |  j | _  q) WWnK t k
 r t j  j |  |  x! |  j D] } | |  j | _  qq W  n Xd  S(   N(   R3   R@   t   fsetR   R   (   RM   R3   t
   orig_shapeR   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR3   A  s    	c         ` s5   t  j t j t j   f d     j j   D   S(   u  Vector norm.

        The norm is the standard Frobenius norm, i.e., the square root of the
        sum of the squares of all components with non-angular units.

        Note that any associated differentials will be dropped during this
        operation.

        Returns
        -------
        norm : `astropy.units.Quantity`
            Vector norm, with the same shape as the representation.
        c         3` s7   |  ]- \ } } t  | t  s t   |  d  Vq d S(   i   N(   R   R   Rc   (   R   R*   R;   (   RM   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>b  s   	(   R   t   sqrtt	   functoolst   reduceRa   Ry   RI   R   (   RM   (    (   RM   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   normS  s    c         O` s,   |  j  d  |  j |  j   j | |    S(   uB  Vector mean.

        Averaging is done by converting the representation to cartesian, and
        taking the mean of the x, y, and z components. The result is converted
        back to the same representation as the input.

        Refer to `~numpy.mean` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.

        Returns
        -------
        mean : representation
            Vector mean, in the same representation as that of the input.
        u   mean(   R   RZ   R[   t   mean(   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   f  s    c         O` s,   |  j  d  |  j |  j   j | |    S(   u0  Vector sum.

        Adding is done by converting the representation to cartesian, and
        summing the x, y, and z components. The result is converted back to the
        same representation as the input.

        Refer to `~numpy.sum` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.

        Returns
        -------
        sum : representation
            Vector sum, in the same representation as that of the input.
        u   sum(   R   RZ   R[   t   sum(   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   y  s    c         C` s   |  j    j |  S(   u  Dot product of two representations.

        The calculation is done by converting both ``self`` and ``other``
        to `~astropy.coordinates.CartesianRepresentation`.

        Note that any associated differentials will be dropped during this
        operation.

        Parameters
        ----------
        other : `~astropy.coordinates.BaseRepresentation`
            The representation to take the dot product with.

        Returns
        -------
        dot_product : `~astropy.units.Quantity`
            The sum of the product of the x, y, and z components of the
            cartesian representations of ``self`` and ``other``.
        (   R[   t   dot(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s)   |  j  d  |  j |  j   j |   S(   u]  Vector cross product of two representations.

        The calculation is done by converting both ``self`` and ``other``
        to `~astropy.coordinates.CartesianRepresentation`, and converting the
        result back to the type of representation of ``self``.

        Parameters
        ----------
        other : representation
            The representation to take the cross product with.

        Returns
        -------
        cross_product : representation
            With vectors perpendicular to both ``self`` and ``other``, in the
            same type of representation as ``self``.
        u   cross(   R   RZ   R[   t   cross(   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    N(   RS   R   R   t   recommended_unitsRR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   Re   Rm   R2   Rx   R@   R3   R   R   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s.   "		=	
			0!	!							t   CartesianRepresentationc           B` s   e  Z d  Z e d e j f d e j f d e j f g  Z d d d d d e d  Z	 d   Z
 d   Z d d  Z e e  Z e d	    Z d
   Z d   Z e d  Z d   Z d   Z d   Z d   Z RS(   u  
    Representation of points in 3D cartesian coordinates.

    Parameters
    ----------
    x, y, z : `~astropy.units.Quantity` or array
        The x, y, and z coordinates of the point(s). If ``x``, ``y``, and ``z``
        have different shapes, they should be broadcastable. If not quantity,
        ``unit`` should be set.  If only ``x`` is given, it is assumed that it
        contains an array with the 3 coordinates stored along ``xyz_axis``.
    unit : `~astropy.units.Unit` or str
        If given, the coordinates will be converted to this unit (or taken to
        be in this unit if not given.
    xyz_axis : int, optional
        The axis along which the coordinates are stored when a single array is
        provided rather than distinct ``x``, ``y``, and ``z`` (default: 0).

    differentials : dict, `CartesianDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single
        `CartesianDifferential` instance, or a dictionary of
        `CartesianDifferential` s with keys set to a string representation of
        the SI unit with which the differential (derivative) is taken. For
        example, for a velocity differential on a positional representation, the
        key would be ``'s'`` for seconds, indicating that the derivative is a
        time derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   xu   yu   zc         C` s  | d  k rZ | d  k rZ | d  k	 rH | d k rH t j | | d  } n  | \ } } } ni | d  k	 ru t d   nN | d  k r | d  k	 s | d  k	 r | d  k r t d j |  j j    n  | d  k	 r2t j | | d | d t	 } t j | | d | d t	 } t j | | d | d t	 } t
 } n  t t |   j | | | d | d | |  j j j |  j j j k o|  j j j k n st j d   n  d  S(   Ni    u|   xyz_axis should only be set if x, y, and z are in a single array passed in through x, i.e., y and z should not be not given.u+   x, y, and z are required to instantiate {0}R,   RA   R   u/   x, y, and z should have matching physical types(   R   R   t   rollaxisRJ   R   R1   RS   t   ut   QuantityRH   R2   R   R   RR   t   _xR.   t   physical_typet   _yt   _zt
   UnitsError(   RM   R   R7   R8   R.   R9   R   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s&    0		!+c      
   C` s   t  d t j |  j d t } t  d t j |  j d t } t d t | | | d t f d t | | | d t f d t | | | d t f f  S(   Ng      ?RA   g        u   xR,   u   yu   z(   R   R   t   oneR3   RH   R   R   R2   (   RM   t   lt   o(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` sD   t  d t j |  j d t } t d | f d | f d | f f  S(   Ng      ?RA   u   xu   yu   z(   R   R   R   R3   RH   R   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    i    c         C` s   t  |  j |  j |  j d | S(   uv  Return a vector array of the x, y, and z coordinates.

        Parameters
        ----------
        xyz_axis : int, optional
            The axis in the final array along which the x, y, z components
            should be stored (default: 0).

        Returns
        -------
        xyz : `~astropy.units.Quantity`
            With dimension 3 along ``xyz_axis``.
        R9   (   R?   R   R   R   (   RM   R9   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   get_xyz  s    c         C` s   | S(   N(    (   R;   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ     s    c         C` s   |  S(   N(    (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    c         ` s=  y   j  } Wn) t k
 r8 t j        j  } n X| d d
 k rX t d   n  |  j } |  j r | d  r   j | j  } nH t j	 d k r t j
 d   | j d t } n t j
 d   | j  } t j | | j d t } |  j rt   f d   |  j j   D  } n d } |  j d t d	 | |  S(   u"  
        Transform the cartesian coordinates using a 3x3 matrix.

        This returns a new representation and does not modify the original one.
        Any differentials attached to this representation will also be
        transformed.

        Parameters
        ----------
        matrix : `~numpy.ndarray`
            A 3x3 transformation matrix, such as a rotation matrix.


        Examples
        --------

        We can start off by creating a cartesian representation object:

            >>> from astropy import units as u
            >>> from astropy.coordinates import CartesianRepresentation
            >>> rep = CartesianRepresentation([1, 2] * u.pc,
            ...                               [2, 3] * u.pc,
            ...                               [3, 4] * u.pc)

        We now create a rotation matrix around the z axis:

            >>> from astropy.coordinates.matrix_utilities import rotation_matrix
            >>> rotation = rotation_matrix(30 * u.deg, axis='z')

        Finally, we can apply this transformation:

            >>> rep_new = rep.transform(rotation)
            >>> rep_new.xyz  # doctest: +FLOAT_CMP
            <Quantity [[ 1.8660254 , 3.23205081],
                       [ 1.23205081, 1.59807621],
                       [ 3.        , 4.        ]] pc>
        ii   uG   tried to do matrix multiplication with an array that doesn't end in 3x3u   1.14.0u   ...ij,j...->i...t   optimizeR,   c         3` s9   |  ]/ \ } } | | j  | j   j     f Vq d  S(   N(   RZ   R[   t	   transform(   R   R   t   d(   t   matrix(    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>i  s   R   (   i   i   N(   R3   Rg   R   R]   RJ   t   xyzt   isscalarR   R6   t   __version__t   einsumR2   R   R   R.   R   R   R   R   R1   (   RM   R   t   matrix_shapet   oldxyzt   newxyzR   (    (   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s*    (		c         ` s   |  j   j  y | j   } Wn t k
 r4 t SX| sG |  | f n	 | |  f \    |  j     f d     j D   S(   Nc         3` s0   |  ]& }  t    |  t   |   Vq d  S(   N(   Rc   (   R   R*   (   t   firstRl   t   second(    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>z  s   (   R   RS   R[   R   R   R1   RC   (   RM   Rl   RY   Rw   t   other_c(    (   R   Rl   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   p  s    c         O` s    |  j  d  |  j d | |  S(   uT  Vector mean.

        Returns a new CartesianRepresentation instance with the means of the
        x, y, and z components.

        Refer to `~numpy.mean` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.
        u   mean(   R   Re   (   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   ~  s    
c         O` s    |  j  d  |  j d | |  S(   uQ  Vector sum.

        Returns a new CartesianRepresentation instance with the sums of the
        x, y, and z components.

        Refer to `~numpy.sum` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.
        u   sum(   R   Re   (   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    
c         ` sh   y | j      Wn, t k
 r> t d j t |     n Xt j t j    f d    j	 D  S(   u  Dot product of two representations.

        Note that any associated differentials will be dropped during this
        operation.

        Parameters
        ----------
        other : representation
            If not already cartesian, it is converted.

        Returns
        -------
        dot_product : `~astropy.units.Quantity`
            The sum of the product of the x, y, and z components of ``self``
            and ``other``.
        uM   cannot only take dot product with another representation, not a {0} instance.c         3` s+   |  ]! } t   |  t    |  Vq d  S(   N(   Rc   (   R   R*   (   R   RM   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>  s   (
   R[   R   RG   R   R   R   R   Ra   Ry   RC   (   RM   RY   (    (   R   RM   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	c         C` s   |  j  d  y | j   } Wn, t k
 rK t d j t |     n X|  j |  j | j |  j | j |  j | j	 |  j	 | j |  j	 | j |  j | j	  S(   uZ  Cross product of two representations.

        Parameters
        ----------
        other : representation
            If not already cartesian, it is converted.

        Returns
        -------
        cross_product : `~astropy.coordinates.CartesianRepresentation`
            With vectors perpendicular to both ``self`` and ``other``.
        u   crossuO   cannot only take cross product with another representation, not a {0} instance.(
   R   R[   R   RG   R   R   R1   R7   R8   R   (   RM   RY   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	!N(   RS   R   R   R   R   R   RI   R   RH   RR   R   R   R   R   R   R   RZ   R[   R   R2   Rx   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s$   				T			R   c           B` s  e  Z d  Z e d e f d e f g  Z i e j d 6e j d 6Z	 e
 d    Z d e d  Z e d    Z e d    Z e d    Z d   Z e d	  Z d
   Z e d    Z d d  Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z  d   Z! RS(   u  
    Representation of points on a unit sphere.

    Parameters
    ----------
    lon, lat : `~astropy.units.Quantity` or str
        The longitude and latitude of the point(s), in angular units. The
        latitude should be between -90 and 90 degrees, and the longitude will
        be wrapped to an angle between 0 and 360 degrees. These can also be
        instances of `~astropy.coordinates.Angle`,
        `~astropy.coordinates.Longitude`, or `~astropy.coordinates.Latitude`.

    differentials : dict, `BaseDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single `BaseDifferential`
        instance (see `._compatible_differentials` for valid types), or a
        dictionary of of differential instances with keys set to a string
        representation of the SI unit with which the differential (derivative)
        is taken. For example, for a velocity differential on a positional
        representation, the key would be ``'s'`` for seconds, indicating that
        the derivative is a time derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   lonu   latc         C` s   t  S(   N(   t   SphericalRepresentation(   R;   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _dimensional_representation  s    c         C` s)   t  t |   j | | d | d | d  S(   NR   R,   (   R   R   RR   (   RM   t   lont   latR   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s    c         C` s   t  t t t t g S(   N(   t   UnitSphericalDifferentialt   UnitSphericalCosLatDifferentialt   SphericalDifferentialt   SphericalCosLatDifferentialR   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s   |  j  S(   u0   
        The longitude of the point(s).
        (   t   _lon(   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s   |  j  S(   u/   
        The latitude of the point(s).
        (   t   _lat(   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c      	   C` s   t  j |  j  t  j |  j  } } t  j |  j  t  j |  j  } } t d t | | d d t f d t | | | | | d t f f  S(   Nu   long        R,   u   lat(   R   t   sinR   t   cosR   R   R   R2   (   RM   t   sinlont   coslont   sinlatt   coslat(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   
  s    %%c         C` s`   t  d t j |  j d t } | r+ | n t j |  j  t j } t d | f d | f f  S(   Ng      ?RA   u   lonu   lat(	   R   R   t   radianR3   RH   R   R   R   R   (   RM   t   omit_coslatt   sf_latt   sf_lon(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    %c      	   C` su   t  j |  j  t  j |  j  } t  j |  j  t  j |  j  } t  j |  j  } t d | d | d | d t  S(   ug   
        Converts spherical polar coordinates to 3D rectangular cartesian
        coordinates.
        R   R7   R8   R,   (   R   R   R   R   R   R   R2   (   RM   R   R7   R8   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    ""c         C` s^   t  j | j | j  } t  j | j | j  } t  j | j |  } |  d | d | d t  S(   ug   
        Converts 3D rectangular cartesian coordinates to spherical polar
        coordinates.
        R   R   R,   (   R   t   hypotR   R7   t   arctan2R8   R2   (   R;   t   cartt   sR   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ   #  s    c      	   C` s   t  j |  r | r t | t  rU | d |  j d d t j |  j d d d t  St | t	  r | d |  j d |  j d	 d d t  Sn  t
 t |   j | |  S(
   Nt   phit   thetaiZ   t   rg      ?R,   R   R   t   distance(   R   R   R   t   PhysicsSphericalRepresentationR   R   t   degR   R2   R   R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   1  s    )
c         C` s3   |  j  d  |  j d |  j d |  j d d |  S(   Nu   multiplicationR   R   R  g      ?(   R   R   R   R   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRo   A  s    c         C` s3   |  j  d  |  j d |  j d |  j d d |  S(   Nu   divisionR   R   R  g      ?(   R   R   R   R   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRr   F  s    c         C` s5   |  j  d  |  j |  j d t j |  j d t S(   Nu   negationg     f@R,   (   R   R1   R   R   R  R   R2   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRu   K  s    c         C` s%   t  j t j |  j  t  j d t S(   u|  Vector norm.

        The norm is the standard Frobenius norm, i.e., the square root of the
        sum of the squares of all components with non-angular units, which is
        always unity for vectors on the unit sphere.

        Returns
        -------
        norm : `~astropy.units.Quantity`
            Dimensionless ones, with the same shape as the representation.
        R,   (   R   R   R   t   onesR3   t   dimensionless_unscaledR2   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   O  s    c         C` sO   |  j  | j  |  j   j | | |  } | t k r; t S|  j j |  Sd  S(   N(   R   RS   R[   Rx   R   R   RZ   (   RM   Rl   RY   Rw   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   ^  s
    c         O` s/   |  j  d  |  j j |  j   j | |    S(   u  Vector mean.

        The representation is converted to cartesian, the means of the x, y,
        and z components are calculated, and the result is converted to a
        `~astropy.coordinates.SphericalRepresentation`.

        Refer to `~numpy.mean` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.
        u   mean(   R   R   RZ   R[   R   (   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   g  s    	c         O` s/   |  j  d  |  j j |  j   j | |    S(   u  Vector sum.

        The representation is converted to cartesian, the sums of the x, y,
        and z components are calculated, and the result is converted to a
        `~astropy.coordinates.SphericalRepresentation`.

        Refer to `~numpy.sum` for full documentation of the arguments, noting
        that ``axis`` is the entry in the ``shape`` of the representation, and
        that the ``out`` argument cannot be used.
        u   sum(   R   R   RZ   R[   R   (   RM   RN   R(   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   v  s    	c         C` s,   |  j  d  |  j j |  j   j |   S(   uB  Cross product of two representations.

        The calculation is done by converting both ``self`` and ``other``
        to `~astropy.coordinates.CartesianRepresentation`, and converting the
        result back to `~astropy.coordinates.SphericalRepresentation`.

        Parameters
        ----------
        other : representation
            The representation to take the cross product with.

        Returns
        -------
        cross_product : `~astropy.coordinates.SphericalRepresentation`
            With vectors perpendicular to both ``self`` and ``other``.
        u   cross(   R   R   RZ   R[   R   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	N("   RS   R   R   R   R   R   RI   R   R  R   R   R   R   RH   RR   R   R   R   R   R   R2   R   R[   R   RZ   R   Ro   Rr   Ru   R   Rx   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s,   									t   RadialRepresentationc           B` s   e  Z d  Z e d e j f g  Z d e d  Z	 e
 d    Z d   Z d   Z d   Z e d    Z d   Z d	   Z e d
  Z RS(   u.  
    Representation of the distance of points from the origin.

    Note that this is mostly intended as an internal helper representation.
    It can do little else but being used as a scale in multiplication.

    Parameters
    ----------
    distance : `~astropy.units.Quantity`
        The distance of the point(s) from the origin.

    differentials : dict, `BaseDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single `BaseDifferential`
        instance (see `._compatible_differentials` for valid types), or a
        dictionary of of differential instances with keys set to a string
        representation of the SI unit with which the differential (derivative)
        is taken. For example, for a velocity differential on a positional
        representation, the key would be ``'s'`` for seconds, indicating that
        the derivative is a time derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   distancec         C` s&   t  t |   j | d | d | d  S(   NR,   R   (   R   R  RR   (   RM   R  R   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s    c         C` s   |  j  S(   u?   
        The distance from the origin to the point(s).
        (   t	   _distance(   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s    c         C` s   t  d j |  j    d S(   u?   Cartesian unit vectors are undefined for radial representation.u6   Cartesian unit vectors are undefined for {0} instancesN(   RX   R   R1   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	c         C` s2   t  d t j |  j d t } t d | f f  S(   Ng      ?RA   u   distance(   R   R   R   R3   RH   R   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s   t  d j |  j    d S(   u2   Cannot convert radial representation to cartesian.u)   cannot convert {0} instance to cartesian.N(   RX   R   R1   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    	c         C` s   |  d | j    d t  S(   uU   
        Converts 3D rectangular cartesian coordinates to radial coordinate.
        R  R,   (   R   R2   (   R;   R  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ     s    c         G` s    |  j  | j  | |  j |  S(   N(   R   RS   R  (   RM   Rl   RN   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRm     s    c         C` s   |  j  S(   u   Vector norm.

        Just the distance itself.

        Returns
        -------
        norm : `~astropy.units.Quantity`
            Dimensionless ones, with the same shape as the representation.
        (   R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    
c         C` s   t  S(   N(   R   (   RM   Rl   RY   Rw   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx     s    N(   RS   R   R   R   R   R   RI   R   RH   RR   R   R  R   R   R[   R   RZ   Rm   R   R2   Rx   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s   					R   c           B` s   e  Z d  Z e d e f d e f d e j f g  Z i e j	 d 6e j	 d 6Z
 e Z d e d  Z e d    Z e d    Z e d    Z e d    Z d	   Z e d
  Z d d  Z d   Z e d    Z d   Z RS(   u  
    Representation of points in 3D spherical coordinates.

    Parameters
    ----------
    lon, lat : `~astropy.units.Quantity`
        The longitude and latitude of the point(s), in angular units. The
        latitude should be between -90 and 90 degrees, and the longitude will
        be wrapped to an angle between 0 and 360 degrees. These can also be
        instances of `~astropy.coordinates.Angle`,
        `~astropy.coordinates.Longitude`, or `~astropy.coordinates.Latitude`.

    distance : `~astropy.units.Quantity`
        The distance to the point(s). If the distance is a length, it is
        passed to the :class:`~astropy.coordinates.Distance` class, otherwise
        it is passed to the :class:`~astropy.units.Quantity` class.

    differentials : dict, `BaseDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single `BaseDifferential`
        instance (see `._compatible_differentials` for valid types), or a
        dictionary of of differential instances with keys set to a string
        representation of the SI unit with which the differential (derivative)
        is taken. For example, for a velocity differential on a positional
        representation, the key would be ``'s'`` for seconds, indicating that
        the derivative is a time derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   lonu   latu   distancec         C` sY   t  t |   j | | | d | d | |  j j j d k rU |  j j t  |  _ n  d  S(   NR,   R   u   length(   R   R   RR   R  R.   R   t   viewR   (   RM   R   R   R  R   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s
    c         C` s   t  t t t t g S(   N(   R   R   R   R   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s   |  j  S(   u0   
        The longitude of the point(s).
        (   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    c         C` s   |  j  S(   u/   
        The latitude of the point(s).
        (   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   %  s    c         C` s   |  j  S(   u?   
        The distance from the origin to the point(s).
        (   R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR  ,  s    c      
   C` s   t  j |  j  t  j |  j  } } t  j |  j  t  j |  j  } } t d t | | d d t f d t | | | | | d t f d t | | | | | d t f f  S(   Nu   long        R,   u   latu   distance(   R   R   R   R   R   R   R   R2   (   RM   R  R  R  R  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   3  s    %%c         C` sv   |  j  t j } | r | n | t j |  j  } t d t j |  j d t	 } t
 d | f d | f d | f f  S(   Ng      ?RA   u   lonu   latu   distance(   R  R   R  R   R   R   R   R   R3   RH   R   (   RM   R  R  R  t   sf_distance(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   =  s    "	c      	   C` s   t  j |  r | r t | t  rX | d |  j d d t j |  j d |  j d t	  St | t
  r | d |  j d |  j d t	  Sn  t t |   j | |  S(   NR  R  iZ   R  R,   R   R   (   R   R   R   R  R   R   R  R   R  R2   R   R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   E  s    #"c      	   C` s   t  |  j t  r* |  j j t j  } n	 |  j } | t j |  j  t j |  j	  } | t j |  j  t j
 |  j	  } | t j
 |  j  } t d | d | d | d t  S(   ug   
        Converts spherical polar coordinates to 3D rectangular cartesian
        coordinates.
        R   R7   R8   R,   (   R   R  R   R  R   R   R   R   R   R   R   R   R2   (   RM   R   R   R7   R8   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[   T  s    	&&c      	   C` sy   t  j | j | j  } t  j | | j  } t  j | j | j  } t  j | j |  } |  d | d | d | d t  S(   ug   
        Converts 3D rectangular cartesian coordinates to spherical polar
        coordinates.
        R   R   R  R,   (   R   R	  R   R7   R8   R
  R2   (   R;   R  R  R  R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ   f  s
    c         C` s   t  j |  j  S(   u  Vector norm.

        The norm is the standard Frobenius norm, i.e., the square root of the
        sum of the squares of all components with non-angular units.  For
        spherical coordinates, this is just the absolute value of the distance.

        Returns
        -------
        norm : `astropy.units.Quantity`
            Vector norm, with the same shape as the representation.
        (   R   t   absR  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   u  s    N(   RS   R   R   R   R   R   R   R   RI   R  R   R   t   _unit_representationR   RH   RR   R   R   R   R   R  R   R2   R   R   R[   R   RZ   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s"   		
	R  c           B` s   e  Z d  Z e d e f d e f d e j f g  Z i e j d 6e j d 6Z	 d e d  Z e d    Z e d    Z e d    Z d   Z d	   Z d d
  Z d   Z e d    Z d   Z RS(   u9  
    Representation of points in 3D spherical coordinates (using the physics
    convention of using ``phi`` and ``theta`` for azimuth and inclination
    from the pole).

    Parameters
    ----------
    phi, theta : `~astropy.units.Quantity` or str
        The azimuth and inclination of the point(s), in angular units. The
        inclination should be between 0 and 180 degrees, and the azimuth will
        be wrapped to an angle between 0 and 360 degrees. These can also be
        instances of `~astropy.coordinates.Angle`.  If ``copy`` is False, `phi`
        will be changed inplace if it is not between 0 and 360 degrees.

    r : `~astropy.units.Quantity`
        The distance to the point(s). If the distance is a length, it is
        passed to the :class:`~astropy.coordinates.Distance` class, otherwise
        it is passed to the :class:`~astropy.units.Quantity` class.

    differentials : dict, `PhysicsSphericalDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single
        `PhysicsSphericalDifferential` instance, or a dictionary of of
        differential instances with keys set to a string representation of the
        SI unit with which the differential (derivative) is taken. For example,
        for a velocity differential on a positional representation, the key
        would be ``'s'`` for seconds, indicating that the derivative is a time
        derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   phiu   thetau   rc         C` s   t  t |   j | | | d | d | | rM |  j j d t j  |  _ n |  j j d t j d t t j	 |  j
 d t j k   s t j	 |  j
 d t j k  r t d j | j t j     n  |  j j j d k r |  j j t  |  _ n  d  S(	   NR,   R   ih  t   inplaceg        g     f@uF   Inclination angle(s) must be within 0 deg <= angle <= 180 deg, got {0}u   length(   R   R  RR   t   _phit   wrap_atR   R  RH   R   t   anyt   _thetaRJ   R   t   tot   degreet   _rR.   R   R  R   (   RM   R  R  R  R   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s    >	c         C` s   |  j  S(   u.   
        The azimuth of the point(s).
        (   R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s    c         C` s   |  j  S(   u0   
        The elevation of the point(s).
        (   R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s    c         C` s   |  j  S(   u?   
        The distance from the origin to the point(s).
        (   R"  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s    c      
   C` s   t  j |  j  t  j |  j  } } t  j |  j  t  j |  j  } } t d t | | d d t f d t | | | | | d t f d t | | | | | d t f f  S(   Nu   phig        R,   u   thetau   r(   R   R   R  R   R  R   R   R2   (   RM   t   sinphit   cosphit   sinthetat   costheta(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    %%c         C` sj   |  j  t j } t j |  j  } t d t j |  j d t	 } t
 d | | f d | f d | f f  S(   Ng      ?RA   u   phiu   thetau   r(   R  R   R  R   R   R  R   R   R3   RH   R   (   RM   R  R%  R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	c         C` s   t  j |  r | r t | t  rR | d |  j d d t j |  j d |  j  St | t	  r | d |  j d d t j |  j  Sn  t
 t |   j | |  S(   NR   R   iZ   R  (   R   R   R   R   R  R   R  R  R  R   R   R  R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    #
'c      	   C` s   t  |  j t  r* |  j j t j  } n	 |  j } | t j |  j  t j	 |  j
  } | t j |  j  t j |  j
  } | t j	 |  j  } t d | d | d | d t  S(   ug   
        Converts spherical polar coordinates to 3D rectangular cartesian
        coordinates.
        R   R7   R8   R,   (   R   R  R   R  R   R   R   R   R  R   R  R   R2   (   RM   R   R   R7   R8   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    	&&c      	   C` sy   t  j | j | j  } t  j | | j  } t  j | j | j  } t  j | | j  } |  d | d | d | d t  S(   ug   
        Converts 3D rectangular cartesian coordinates to spherical polar
        coordinates.
        R  R  R  R,   (   R   R	  R   R7   R8   R
  R2   (   R;   R  R  R  R  R  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ     s
    c         C` s   t  j |  j  S(   u  Vector norm.

        The norm is the standard Frobenius norm, i.e., the square root of the
        sum of the squares of all components with non-angular units.  For
        spherical coordinates, this is just the absolute value of the radius.

        Returns
        -------
        norm : `astropy.units.Quantity`
            Vector norm, with the same shape as the representation.
        (   R   R  R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    N(   RS   R   R   R   R   R   R   RI   R  R   R   RH   RR   R   R  R  R  R   R   R   R[   R   RZ   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR    s    				t   CylindricalRepresentationc           B` s   e  Z d  Z e d e j f d e f d e j f g  Z i e j d 6Z	 d e d  Z e d    Z e d    Z e d    Z d   Z d	   Z e d
    Z d   Z RS(   u  
    Representation of points in 3D cylindrical coordinates.

    Parameters
    ----------
    rho : `~astropy.units.Quantity`
        The distance from the z axis to the point(s).

    phi : `~astropy.units.Quantity` or str
        The azimuth of the point(s), in angular units, which will be wrapped
        to an angle between 0 and 360 degrees. This can also be instances of
        `~astropy.coordinates.Angle`,

    z : `~astropy.units.Quantity`
        The z coordinate(s) of the point(s)

    differentials : dict, `CylindricalDifferential`, optional
        Any differential classes that should be associated with this
        representation. The input must either be a single
        `CylindricalDifferential` instance, or a dictionary of of differential
        instances with keys set to a string representation of the SI unit with
        which the differential (derivative) is taken. For example, for a
        velocity differential on a positional representation, the key would be
        ``'s'`` for seconds, indicating that the derivative is a time
        derivative.

    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   rhou   phiu   zc         C` sY   t  t |   j | | | d | d | |  j j j |  j j  sU t j d   n  d  S(   NR,   R   u-   rho and z should have matching physical types(	   R   R'  RR   t   _rhoR.   t   is_equivalentR   R   R   (   RM   t   rhoR  R8   R   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   J  s
    c         C` s   |  j  S(   u?   
        The distance of the point(s) from the z-axis.
        (   R(  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR*  R  s    c         C` s   |  j  S(   u.   
        The azimuth of the point(s).
        (   R  (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR  Y  s    c         C` s   |  j  S(   u-   
        The height of the point(s).
        (   R   (   RM   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR8   `  s    c         C` s   t  j |  j  t  j |  j  } } t d |  j  } t d t | | d d t f d t | | d d t f d t d d | d t	 j
 d t f f  S(   Ng      ?u   rhoi    R,   u   phiu   zR.   (   R   R   R  R   R   R3   R   R   R2   R   R   (   RM   R#  R$  R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   g  s    %c         C` sT   |  j  t j } t d t j |  j d t } t d | f d | f d | f f  S(   Ng      ?RA   u   rhou   phiu   z(   R*  R   R  R   R   R3   RH   R   (   RM   R*  R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   o  s
    	c      	   C` sX   t  j | j | j  } t  j | j | j  } | j } |  d | d | d | d t  S(   ui   
        Converts 3D rectangular cartesian coordinates to cylindrical polar
        coordinates.
        R*  R  R8   R,   (   R   R	  R   R7   R
  R8   R2   (   R;   R  R*  R  R8   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ   v  s    	c      	   C` sZ   |  j  t j |  j  } |  j  t j |  j  } |  j } t d | d | d | d t  S(   ui   
        Converts cylindrical polar coordinates to 3D rectangular cartesian
        coordinates.
        R   R7   R8   R,   (   R*  R   R   R  R   R8   R   R2   (   RM   R   R7   R8   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    	N(   RS   R   R   R   R   R   R   RI   R  R   R   RH   RR   R   R*  R  R8   R   R   R   RZ   R[   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR'  &  s   			t   MetaBaseDifferentialc           B` s   e  Z d  Z d   Z RS(   u   Set default ``attr_classes`` and component getters on a Differential.

    For these, the components are those of the base representation prefixed
    by 'd_', and the class is `~astropy.units.Quantity`.
    c      	   C` s&  t  t |   j | | |  |  j d k r/ d  Sd | k rJ t d   n  t |  d  s |  j j } t g  | D] } d | t	 j
 f ^ qo  |  _ n  |  j   } | t k r t d j |    n  |  t | <xN |  j D]C } t |  |  s t |  | t t |  d	 d
 j |   q q Wd  S(   Nu   BaseDifferentialu   BaseSphericalDifferentialu   BaseSphericalCosLatDifferentialu   base_representationuN   Differential representations must have a"base_representation" class attribute.u   attr_classesu   d_u&   Differential class {0} already definedR   u$   Component '{0}' of the Differential.(   u   BaseDifferentialu   BaseSphericalDifferentialu   BaseSphericalCosLatDifferential(   R   R+  RR   RS   RX   R   t   base_representationRI   R   R   R   RW   R   RJ   R   RL   R   R   (   R;   RV   R   R   t   base_attr_classesR=   R   R*   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s*    	,	
	(   RS   R   R   RR   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR+    s   R   c           B` s   e  Z d  Z i  Z e d    Z d   Z e d    Z d   Z e d    Z	 d   Z
 e d    Z d   Z e d	  Z d
   Z d d  Z RS(   uj  A base class representing differentials of representations.

    These represent differences or derivatives along each component.
    E.g., for physics spherical coordinates, these would be
    :math:`\delta r, \delta \theta, \delta \phi`.

    Parameters
    ----------
    d_comp1, d_comp2, d_comp3 : `~astropy.units.Quantity` or subclass
        The components of the 3D differentials.  The names are the keys and the
        subclasses the values of the ``attr_classes`` attribute.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.

    Notes
    -----
    All differential representation classes should subclass this base class,
    and define an ``base_representation`` attribute with the class of the
    regular `~astropy.coordinates.BaseRepresentation` for which differential
    coordinates are provided. This will set up a default ``attr_classes``
    instance with names equal to the base component names prefixed by ``d_``,
    and all classes set to `~astropy.units.Quantity`, plus properties to access
    those, and a default ``__init__`` for initialization.
    c         C` s1   |  | j  k r- t d j |  | j    n  d  S(   NuQ   Differential class {0} is not compatible with the base (representation) class {1}(   R   RG   R   R1   (   R;   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    	c         C` s   |  j  |  xy | j D]b } t | |  } t |  d j |  d  } | r | j | j } t t j d |  j	 j  Sq Wt
 d   d S(   u   Given a base (representation instance), determine the unit of the
        derivative by removing the representation unit from the component units
        of this differential.
        u   d_{0}g      ?uO   Invalid representation-differential match! Not sure how we got into this state.N(   R   RC   Rc   R   R   R.   R   R   R   t   sit   RuntimeError(   RM   R   RV   t   compt   d_compt   d_unit(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s     c         C` s#   |  j  |  | j   | j   f S(   uX  Get unit vectors and scale factors from base.

        Parameters
        ----------
        base : instance of ``self.base_representation``
            The points for which the unit vectors and scale factors should be
            retrieved.

        Returns
        -------
        unit_vectors : dict of `CartesianRepresentation`
            In the directions of the coordinates of base.
        scale_factors : dict of `~astropy.units.Quantity`
            Scale factors for each of the coordinates

        Raises
        ------
        TypeError : if the base is not of the correct type
        (   R   R   R   (   R;   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _get_base_vectors  s    c         ` sM    j  |  \    t j t j     f d   t  j | j  D  S(   u  Convert the differential to 3D rectangular cartesian coordinates.

        Parameters
        ----------
        base : instance of ``self.base_representation``
             The points for which the differentials are to be converted: each of
             the components is multiplied by its unit vectors and scale factors.

        Returns
        -------
        This object as a `CartesianDifferential`
        c         3` s4   |  ]* \ } } t   |   |   | Vq d  S(   N(   Rc   (   R   t   d_cR=   (   t   base_et   base_sfRM   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>  s   (   R3  R   R   Ra   Ry   R   RC   (   RM   R   (    (   R5  R6  RM   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[   
  s    c         ` sA   |  j  |  \ }   |  d t    f d   t j |  D  S(   u  Convert the differential from 3D rectangular cartesian coordinates to
        the desired class.

        Parameters
        ----------
        other :
            The object to convert into this differential.
        base : instance of ``self.base_representation``
             The points for which the differentials are to be converted: each of
             the components is multiplied by its unit vectors and scale factors.

        Returns
        -------
        A new differential object that is this class' type.
        R,   c         3` s,   |  ]" \ } }  j  |   |  Vq d  S(   N(   R   (   R   R*   t   e(   R6  RY   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys	   <genexpr>.  s   (   R3  R2   R	   t	   iteritems(   R;   RY   R   R5  (    (   R6  RY   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ     s    c         C` sd   | |  j  k r |  S|  j |  } t | t  rS | j | j  } | j | |  S| j |  Sd S(   u  Convert coordinates to another representation.

        If the instance is of the requested class, it is returned unmodified.
        By default, conversion is done via cartesian coordinates.

        Parameters
        ----------
        other_class : `~astropy.coordinates.BaseRepresentation` subclass
            The type of representation to turn the coordinates into.
        base : instance of ``self.base_representation``, optional
            Base relative to which the differentials are defined.  If the other
            class is a differential representation, the base will be converted
            to its ``base_representation``.
        N(   R1   R[   R   R   R   R,  RZ   (   RM   R   R   t   self_cartesian(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   1  s    c         C` sI   t  | t  r- | j | j | j   } n | j   } |  j | |  S(   u  Create a new instance of this representation from another one.

        Parameters
        ----------
        representation : `~astropy.coordinates.BaseRepresentation` instance
            The presentation that should be converted to this class.
        base : instance of ``cls.base_representation``
            The base relative to which the differentials will be defined. If
            the representation is a differential itself, the base will be
            converted to its ``base_representation`` to help convert it.
        (   R   R   R[   R   R,  RZ   (   R;   R   R   t	   cartesian(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   K  s
    c         G` sA   g  |  j  D] } | t |  |  |  ^ q
 } |  j d t |  S(   u9  Scale all components.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.mul`, `~operator.neg`, etc.
        *args
            Any arguments required for the operator (typically, what is to
            be multiplied with, divided by).
        R,   (   RC   Rc   R1   R2   (   RM   Rl   RN   R=   t   scaled_attrs(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRm   `  s    .c         C` s   t  |  t |   rw | s' |  | f n	 | |  f \ } } |  j g  |  j D]' } | t | |  t | |   ^ qI   Sy |  j |  } Wn t k
 r t SX| j | | |  Sd S(   u  Combine two differentials, or a differential with a representation.

        If ``other`` is of the same differential type as ``self``, the
        components will simply be combined.  If ``other`` is a representation,
        it will be used as a base for which to evaluate the differential,
        and the result is a new representation.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.add`, `~operator.sub`, etc.
        other : `~astropy.coordinates.BaseRepresentation` instance
            The other differential or representation.
        reverse : bool
            Whether the operands should be reversed (e.g., as we got here via
            ``self.__rsub__`` because ``self`` is a subclass of ``other``).
        N(	   R   R   R1   RC   Rc   R[   RG   R   Rx   (   RM   Rl   RY   Rw   R   R   R=   R9  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   n  s    $	5c         C` s)   t  | t  r t St t |   j |  S(   N(   R   R   R   R   R   R}   (   RM   RY   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR}     s    c         C` s   |  j  |  j   S(   uX  Vector norm.

        The norm is the standard Frobenius norm, i.e., the square root of the
        sum of the squares of all components with non-angular units.

        Parameters
        ----------
        base : instance of ``self.base_representation``
            Base relative to which the differentials are defined. This is
            required to calculate the physical size of the differential for
            all but cartesian differentials.

        Returns
        -------
        norm : `astropy.units.Quantity`
            Vector norm, with the same shape as the representation.
        (   R[   R   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s    N(   RS   R   R   R   R   R   R   R3  R[   RZ   R   R   Rm   R2   Rx   R}   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR     s   					t   CartesianDifferentialc           B` sb   e  Z d  Z e Z d d d d e d  Z d d  Z e	 d d   Z
 d d  Z e e  Z RS(   u  Differentials in of points in 3D cartesian coordinates.

    Parameters
    ----------
    d_x, d_y, d_z : `~astropy.units.Quantity` or array
        The x, y, and z coordinates of the differentials. If ``d_x``, ``d_y``,
        and ``d_z`` have different shapes, they should be broadcastable. If not
        quantities, ``unit`` should be set.  If only ``d_x`` is given, it is
        assumed that it contains an array with the 3 coordinates stored along
        ``xyz_axis``.
    unit : `~astropy.units.Unit` or str
        If given, the differentials will be converted to this unit (or taken to
        be in this unit if not given.
    xyz_axis : int, optional
        The axis along which the coordinates are stored when a single array is
        provided instead of distinct ``d_x``, ``d_y``, and ``d_z`` (default: 0).
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` s  | d  k rZ | d  k rZ | d  k	 rH | d k rH t j | | d  } n  | \ } } } ni | d  k	 ru t d   nN | d  k r | d  k	 s | d  k	 r | d  k r t d j |  j j    n  | d  k	 r2t j | | d | d t	 } t j | | d | d t	 } t j | | d | d t	 } t
 } n  t t |   j | | | d | |  j j j |  j j  o|  j j j |  j j  st j d   n  d  S(   Ni    u   xyz_axis should only be set if d_x, d_y, and d_z are in a single array passed in through d_x, i.e., d_y and d_z should not be not given.u1   d_x, d_y, and d_z are required to instantiate {0}R,   RA   u.   d_x, d_y and d_z should have equivalent units.(   R   R   R   RJ   R   R1   RS   R   R   RH   R2   R   R<  RR   t   _d_xR.   R)  t   _d_yt   _d_zR   (   RM   t   d_xt   d_yt   d_zR.   R9   R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR     s&    		"c         C` s)   t  g  |  j D] } t |  |  ^ q   S(   N(   R   RC   Rc   (   RM   R   R=   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[     s    c         C` s)   |  g  | j  D] } t | |  ^ q   S(   N(   RC   Rc   (   R;   RY   R   R=   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ     s    i    c         C` s   t  |  j |  j |  j d | S(   uv  Return a vector array of the x, y, and z coordinates.

        Parameters
        ----------
        xyz_axis : int, optional
            The axis in the final array along which the x, y, z components
            should be stored (default: 0).

        Returns
        -------
        xyz : `~astropy.units.Quantity`
            With dimension 3 along ``xyz_axis``.
        R9   (   R?   R=  R>  R?  (   RM   R9   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt	   get_d_xyz  s    N(   RS   R   R   R   R,  R   RH   RR   R[   R   RZ   RC  R   t   d_xyz(    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR<    s   t   BaseSphericalDifferentialc           B` s,   e  Z d    Z e d    Z e d  Z RS(   c         C` s$   |  j  |  |  j t j | j  S(   u   Convert longitude differential d_lon to d_lon_coslat.

        Parameters
        ----------
        base : instance of ``cls.base_representation``
            The base from which the latitude will be taken.
        (   R   t   d_lonR   R   R   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _d_lon_coslat  s    c         C` s!   |  j  |  | t j | j  S(   uH  Convert longitude differential d_lon_coslat to d_lon.

        Parameters
        ----------
        d_lon_coslat : `~astropy.units.Quantity`
            Longitude differential that includes ``cos(lat)``.
        base : instance of ``cls.base_representation``
            The base from which the latitude will be taken.
        (   R   R   R   R   (   R;   t   d_lon_coslatR   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt
   _get_d_lon  s    c         ` s   t  | t  r% t  |  t |   s4 t  | t  r t |  j  t | j  B} | sb |  | f n	 | |  f \        f d   | D } t |   St t |   j  | |  S(   u  Combine two differentials, or a differential with a representation.

        If ``other`` is of the same differential type as ``self``, the
        components will simply be combined.  If both are different parts of
        a `~astropy.coordinates.SphericalDifferential` (e.g., a
        `~astropy.coordinates.UnitSphericalDifferential` and a
        `~astropy.coordinates.RadialDifferential`), they will combined
        appropriately.

        If ``other`` is a representation, it will be used as a base for which
        to evaluate the differential, and the result is a new representation.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.add`, `~operator.sub`, etc.
        other : `~astropy.coordinates.BaseRepresentation` instance
            The other differential or representation.
        reverse : bool
            Whether the operands should be reversed (e.g., as we got here via
            ``self.__rsub__`` because ``self`` is a subclass of ``other``).
        c         ` s:   i  |  ]0 }  t    | d   t   | d    |  q S(   g        (   Rc   (   R   R=   (   R   Rl   R   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys
   <dictcomp>)	  s   	(	   R   RE  R   R   R   RC   R   R   Rx   (   RM   Rl   RY   Rw   t   all_componentst   result_args(    (   R   Rl   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   	  s    $

(   RS   R   RG  R   RI  R2   Rx   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRE    s   	R   c           B` sV   e  Z d  Z e Z e d    Z e d  Z d   Z	 d d  Z e d d   Z RS(   u  Differential(s) of points on a unit sphere.

    Parameters
    ----------
    d_lon, d_lat : `~astropy.units.Quantity`
        The longitude and latitude of the differentials.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` s   t  S(   N(   R   (   R;   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _dimensional_differential=	  s    c         C` sP   t  t |   j | | d | |  j j j |  j j  sL t j d   n  d  S(   NR,   u-   d_lon and d_lat should have equivalent units.(	   R   R   RR   t   _d_lonR.   R)  t   _d_latR   R   (   RM   RF  t   d_latR,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   A	  s    c         C` su   t  | t  r | j } n1 t  | t  r6 | j } n t t |   j |  S| j t	  } | t t |   j |  S(   N(
   R   R   R  R  R  R   R   R[   R   R   (   RM   R   t   scale(    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[   G	  s    c         C` sA   t  | t  r( | |  j |  |  j  St t |   j | |  S(   N(   R   R   RG  RO  R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   R	  s    c         C` s   t  | t  r" |  | j | j  St  | t t f  r\ |  j | j |  } |  | | j  St  | t  r |  | j	 | j
  St t |   j | |  S(   N(   R   R   RF  RO  R   R   RI  RH  t   PhysicsSphericalDifferentialt   d_phit   d_thetaR   R   R   (   R;   R   R   RF  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   Z	  s    	N(   RS   R   R   R   R,  R   RL  RH   RR   R[   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   1	  s   		R   c           B` sD   e  Z d  Z e Z e Z e d  Z d d  Z
 e d d   Z RS(   uk  Differential(s) of points in 3D spherical coordinates.

    Parameters
    ----------
    d_lon, d_lat : `~astropy.units.Quantity`
        The differential longitude and latitude.
    d_distance : `~astropy.units.Quantity`
        The differential distance.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` sS   t  t |   j | | | d | |  j j j |  j j  sO t j d   n  d  S(   NR,   u-   d_lon and d_lat should have equivalent units.(	   R   R   RR   RM  R.   R)  RN  R   R   (   RM   RF  RO  t
   d_distanceR,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   z	  s    c         C` s   t  | t  r" | |  j |  j  St  | t  r> | |  j  St  | t  rl | |  j |  |  j |  j  St  | t  r | |  j |  |  j  St  | t	  r | |  j |  j |  j  St
 t |   j | |  Sd  S(   N(   R   R   RF  RO  R   RT  R   RG  R   RQ  R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   	  s    
c         C` s|   t  | t  r: |  j | j |  } |  | | j | j  St  | t  rc |  | j | j | j	  St
 t |   j | |  S(   N(   R   R   RI  RH  RO  RT  RQ  RR  RS  t   d_rR   R   R   (   R;   R   R   RF  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   	  s    
N(   RS   R   R   R   R,  R   t   _unit_differentialRH   RR   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   k	  s   t   BaseSphericalCosLatDifferentialc           B` sA   e  Z d  Z e d    Z d   Z e d    Z e d  Z RS(   u   Differtials from points on a spherical base representation.

    With cos(lat) assumed to be included in the longitude differential.
    c         C` s)   |  j  |  | j   | j d t  f S(   u  Get unit vectors and scale factors from (unit)spherical base.

        Parameters
        ----------
        base : instance of ``self.base_representation``
            The points for which the unit vectors and scale factors should be
            retrieved.

        Returns
        -------
        unit_vectors : dict of `CartesianRepresentation`
            In the directions of the coordinates of base.
        scale_factors : dict of `~astropy.units.Quantity`
            Scale factors for each of the coordinates.  The scale factor for
            longitude does not include the cos(lat) factor.

        Raises
        ------
        TypeError : if the base is not of the correct type
        R  (   R   R   R   RH   (   R;   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR3  	  s    c         C` s$   |  j  |  |  j t j | j  S(   u   Convert longitude differential with cos(lat) to one without.

        Parameters
        ----------
        base : instance of ``cls.base_representation``
            The base from which the latitude will be taken.
        (   R   RH  R   R   R   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRM  	  s    c         C` s!   |  j  |  | t j | j  S(   uH  Convert longitude differential d_lon to d_lon_coslat.

        Parameters
        ----------
        d_lon : `~astropy.units.Quantity`
            Value of the longitude differential without ``cos(lat)``.
        base : instance of ``cls.base_representation``
            The base from which the latitude will be taken.
        (   R   R   R   R   (   R;   RF  R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   _get_d_lon_coslat	  s    c         ` s   t  | t  r% t  |  t |   s4 t  | t  r t |  j  t | j  B} | sb |  | f n	 | |  f \        f d   | D } t |   St t |   j  | |  S(   u  Combine two differentials, or a differential with a representation.

        If ``other`` is of the same differential type as ``self``, the
        components will simply be combined.  If both are different parts of
        a `~astropy.coordinates.SphericalDifferential` (e.g., a
        `~astropy.coordinates.UnitSphericalDifferential` and a
        `~astropy.coordinates.RadialDifferential`), they will combined
        appropriately.

        If ``other`` is a representation, it will be used as a base for which
        to evaluate the differential, and the result is a new representation.

        Parameters
        ----------
        op : `~operator` callable
            Operator to apply (e.g., `~operator.add`, `~operator.sub`, etc.
        other : `~astropy.coordinates.BaseRepresentation` instance
            The other differential or representation.
        reverse : bool
            Whether the operands should be reversed (e.g., as we got here via
            ``self.__rsub__`` because ``self`` is a subclass of ``other``).
        c         ` s:   i  |  ]0 }  t    | d   t   | d    |  q S(   g        (   Rc   (   R   R=   (   R   Rl   R   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys
   <dictcomp>	  s   	(	   R   RW  R   R   R   RC   R   R   Rx   (   RM   Rl   RY   Rw   RJ  RK  (    (   R   Rl   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   	  s    $

(	   RS   R   R   R   R3  RM  RX  R2   Rx   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRW  	  s
   	R   c           B` sz   e  Z d  Z e Z e d e j f d e j f g  Z e	 d    Z
 e d  Z d   Z d d  Z e d d   Z RS(	   u!  Differential(s) of points on a unit sphere.

    Parameters
    ----------
    d_lon_coslat, d_lat : `~astropy.units.Quantity`
        The longitude and latitude of the differentials.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   d_lon_coslatu   d_latc         C` s   t  S(   N(   R   (   R;   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRL  

  s    c         C` sP   t  t |   j | | d | |  j j j |  j j  sL t j d   n  d  S(   NR,   u4   d_lon_coslat and d_lat should have equivalent units.(	   R   R   RR   RG  R.   R)  RN  R   R   (   RM   RH  RO  R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   
  s    c         C` su   t  | t  r | j } n1 t  | t  r6 | j } n t t |   j |  S| j t	  } | t t |   j |  S(   N(
   R   R   R  R  R  R   R   R[   R   R   (   RM   R   RP  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[   
  s    	c         C` sA   t  | t  r( | |  j |  |  j  St t |   j | |  S(   N(   R   R   RM  RO  R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   "
  s    c         C` s   t  | t  r" |  | j | j  St  | t t f  r\ |  j | j |  } |  | | j  St  | t  r |  j | j	 |  } |  | | j
  St t |   j | |  S(   N(   R   R   RH  RO  R   R   RX  RF  RQ  RR  RS  R   R   (   R;   R   R   RH  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   *
  s    	N(   RS   R   R   R   R,  R   R   R   RI   R   RL  RH   RR   R[   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   	  s   		R   c           B` st   e  Z d  Z e Z e Z e d e j	 f d e j	 f d e j	 f g  Z
 e d  Z d d  Z e d d   Z RS(   u  Differential(s) of points in 3D spherical coordinates.

    Parameters
    ----------
    d_lon_coslat, d_lat : `~astropy.units.Quantity`
        The differential longitude (with cos(lat) included) and latitude.
    d_distance : `~astropy.units.Quantity`
        The differential distance.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    u   d_lon_coslatu   d_latu
   d_distancec         C` sS   t  t |   j | | | d | |  j j j |  j j  sO t j d   n  d  S(   NR,   u4   d_lon_coslat and d_lat should have equivalent units.(	   R   R   RR   RG  R.   R)  RN  R   R   (   RM   RH  RO  RT  R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   N
  s    c         C` s   t  | t  r" | |  j |  j  St  | t  r> | |  j  St  | t  rl | |  j |  |  j |  j  St  | t  r | |  j |  |  j  St  | t	  r | |  j |  |  j |  j  St
 t |   j | |  S(   N(   R   R   RH  RO  R   RT  R   RM  R   RQ  R   R   R   (   RM   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   U
  s     c         C` s   t  | t  r: |  j | j |  } |  | | j | j  St  | t  ru |  j | j |  } |  | | j | j	  St
 t |   j | |  S(   N(   R   R   RX  RF  RO  RT  RQ  RR  RS  RU  R   R   R   (   R;   R   R   RH  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   f
  s    

N(   RS   R   R   R   R,  R   RV  R   R   R   RI   RH   RR   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   <
  s   R   c           B` sJ   e  Z d  Z e Z d   Z e d    Z e d d   Z	 e
 d  Z RS(   u   Differential(s) of radial distances.

    Parameters
    ----------
    d_distance : `~astropy.units.Quantity`
        The differential distance.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` s   |  j  | j t  j   S(   N(   RT  R   R   R[   (   RM   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[   
  s    c         C` s"   |  | j  | j t   d t S(   NR,   (   R   R   R   R2   (   R;   RY   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRZ   
  s    c         C` s[   t  | t t f  r" |  | j  St  | t  r> |  | j  St t |   j | |  Sd  S(   N(	   R   R   R   RT  RQ  RU  R   R   R   (   R;   R   R   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   
  s    	c         ` s   t  | |  j  r] | r. | j |  j    n |  j | j    | j      d t St  | t t f  r t |  j	  t | j	  B} | s |  | f n	 | |  f \        f d   | D } t
 |   St t |   j  | |  Sd  S(   NR,   c         ` s:   i  |  ]0 }  t    | d   t   | d    |  q S(   g        (   Rc   (   R   R=   (   R   Rl   R   (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pys
   <dictcomp>
  s   	(   R   R,  R  RT  R1   R2   RE  RW  R   RC   R   R   R   Rx   (   RM   Rl   RY   Rw   RJ  RK  (    (   R   Rl   R   sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRx   
  s    	$

N(   RS   R   R   R  R,  R[   R   RZ   R   R   R2   Rx   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   w
  s   		
RQ  c           B` s>   e  Z d  Z e Z e d  Z d d  Z e	 d d   Z
 RS(   u}  Differential(s) of 3D spherical coordinates using physics convention.

    Parameters
    ----------
    d_phi, d_theta : `~astropy.units.Quantity`
        The differential azimuth and inclination.
    d_r : `~astropy.units.Quantity`
        The differential radial distance.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` sS   t  t |   j | | | d | |  j j j |  j j  sO t j d   n  d  S(   NR,   u/   d_phi and d_theta should have equivalent units.(	   R   RQ  RR   t   _d_phiR.   R)  t   _d_thetaR   R   (   RM   RR  RS  RU  R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   
  s    c         C` s  t  | t  r) | |  j |  j |  j  St  | t  rL | |  j |  j  St  | t  r |  j |  |  j t j	 | j
  } | | |  j |  j  St  | t  r |  j |  |  j t j	 | j
  } | | |  j  St  | t  r | |  j  St t |   j | |  S(   N(   R   R   RR  RS  RU  R   R   R   R   R   R  R   R   R   RQ  R   (   RM   R   R   RH  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   
  s     c         C` s   t  | t  r) |  | j | j | j  St  | t  ru |  j |  | j t j	 | j
  } |  | | j | j  St t |   j | |  S(   N(   R   R   RF  RO  RT  R   R   RH  R   R   R  R   RQ  R   (   R;   R   R   RR  (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR   
  s    
N(   RS   R   R   R  R,  RH   RR   R   R   R   R   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRQ  
  s   t   CylindricalDifferentialc           B` s    e  Z d  Z e Z e d  Z RS(   u  Differential(s) of points in cylindrical coordinates.

    Parameters
    ----------
    d_rho : `~astropy.units.Quantity`
        The differential cylindrical radius.
    d_phi : `~astropy.units.Quantity`
        The differential azimuth.
    d_z : `~astropy.units.Quantity`
        The differential height.
    copy : bool, optional
        If `True` (default), arrays will be copied rather than referenced.
    c         C` sS   t  t |   j | | | d | |  j j j |  j j  sO t j d   n  d  S(   NR,   u+   d_rho and d_z should have equivalent units.(	   R   R[  RR   t   _d_rhoR.   R)  R?  R   R   (   RM   t   d_rhoRR  RB  R,   (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyRR   
  s    (   RS   R   R   R'  R,  R2   RR   (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyR[  
  s   (A   R   t
   __future__R    R   R   R   R   R   Ra   t   collectionsR   R   t   numpyR   t   astropy.unitst   unitsR   t   anglesR   R   R   t	   distancesR   t   externR	   t   utilsR
   R   t
   utils.miscR   t   utils.compatR   R   t   utils.compat.numpyR   R   t   __all__R   R   R+   R?   R@   R   t   ABCMetaR   t   add_metaclassR   R   R   R  R   R  R'  R+  R   R<  RE  R   R   RW  R   R   R   RQ  R[  (    (    (    sA   lib/python2.7/site-packages/astropy/coordinates/representation.pyt   <module>   sp   "	) 	  Pi(L>:6[@;4<