
[c           @` s
  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
 m Z m Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z m Z m  Z  d d l! m" Z" d d l m# Z$ d d l% m& Z& d d l% m' Z' m( Z( m) Z) m* Z* m+ Z+ d d d d g Z, e"   Z- d   Z. d   Z/ d e e j0 f d     YZ1 e
 d d d d f  Z2 d e2 f d     YZ3 e j4 e1  d e f d      Y Z5 d! e5 f d"     YZ6 d S(#   uR   
Framework and base classes for coordinate frames/"low-level" coordinate
classes.
i    (   t   absolute_importt   unicode_literalst   divisiont   print_functionN(   t
   namedtuplet   OrderedDictt   defaultdicti   (   t   override__dir__(   t   lazyproperty(   t   AstropyWarning(   t   six(   t   zip(   t   units(   t   OrderedDescriptorContainert   ShapedLikeNDArrayt   check_broadcasti   (   t   TransformGraph(   t   representation(   t	   Attribute(   t   TimeFrameAttributet   QuantityFrameAttributet   EarthLocationAttributet   CoordinateAttributet%   CartesianRepresentationFrameAttributeu   BaseCoordinateFrameu   frame_transform_graphu   GenericFrameu   RepresentationMappingc         C` sj   |  t  j k r t  j |  }  nG t |  t  sB t |  t  j  rf t d j |  t t  j     n  |  S(   uP   
    Return a valid representation class from ``value`` or raise exception.
    u_   Representation is {0!r} but must be a BaseRepresentation class or one of the string aliases {1}(	   t   rt   REPRESENTATION_CLASSESt
   isinstancet   typet
   issubclasst   BaseRepresentationt
   ValueErrort   formatt   list(   t   value(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   _get_repr_cls4   s    c         K` s   t  |   }  i |  d 6} x | j   D] \ } } | d k r\ t j j |  j   d  } nr | t j k r{ t j | } nS | d k	 r t | t  s t	 | t j
  r t d j | t t j     n  | | | <q& W| S(   u  Get valid representation and differential classes.

    Parameters
    ----------
    base : str or `~astropy.coordinates.BaseRepresentation` subclass
        class for the representation of the base coordinates.  If a string,
        it is looked up among the known representation classes.
    **differentials : dict of str or `~astropy.coordinates.BaseDifferentials`
        Keys are like for normal differentials, i.e., 's' for a first
        derivative in time, etc.  If an item is set to `None`, it will be
        guessed from the base class.

    Returns
    -------
    repr_classes : dict of subclasses
        The base class is keyed by 'base'; the others by the keys of
        ``diffferentials``.
    u   baseu[   Differential is {0!r} but must be a BaseDifferential class or one of the string aliases {1}N(   R"   t   itemsR   t   DIFFERENTIAL_CLASSESt   gett   get_namet   NoneR   R   R   t   BaseDifferentialR   R   R    (   t   baset   differentialst   repr_classest   namet   differential_cls(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   _get_repr_classesD   s    t	   FrameMetac           B` s    e  Z d    Z e d    Z RS(   c         C` s  d | k r$ | j  d  } t } n d  } t } d | k rT | j  d  } t } n d  } t } d | k r | j  d  } t }	 n d  } t }	 t t |   j |  | | |  }
 x d   |
 j D D] } | r d | k r | d } t } n  | rd | k r| d } t } n  |	 r=d | k r=| d } t }	 n  | r | r |	 r Pq q Wt d   |  j	 | d |  |  j	 | d |  |  j	 | d t
 j |   d	 | k r| j   | d	 <n  t t |   j |  | | |  S(
   Nu   default_representationu   default_differentialu"   frame_specific_representation_infoc         s` s   |  ] } | j  Vq d  S(   N(   t   __dict__(   t   .0t   c(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pys	   <genexpr>   s    u   _default_representationu   _default_differentialu#   _frame_specific_representation_infou_   Could not find all expected BaseCoordinateFrame class attributes.  Are you mis-using FrameMeta?u   name(   t   popt   TrueR'   t   Falset   superR/   t   __new__t   __mro__R   t   readonly_prop_factoryt   copyt   deepcopyt   lower(   t   mclsR,   t   basest   memberst   default_reprt   found_default_reprt   default_difft   found_default_difft	   repr_infot   found_repr_infot   tmp_clst   m(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR7   r   sR    			!
	
	
			c         ` s7   d |     f d   } | |    <t  |  |  | <d  S(   Nu   _c         ` s   t  |     S(   N(   t   getattr(   t   self(   t   private_attr(    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   getter   s    (   t   property(   R?   t   attrR!   RK   (    (   RJ   s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR9      s    

(   t   __name__t
   __module__R7   t   staticmethodR9   (    (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR/   q   s   	Cu   reprnameu	   framenameu   defaultunitt   RepresentationMappingc           B` s   e  Z d  Z d d  Z RS(   u  
    This `~collections.namedtuple` is used with the
    ``frame_specific_representation_info`` attribute to tell frames what
    attribute names (and default units) to use for a particular representation.
    ``reprname`` and ``framename`` should be strings, while ``defaultunit`` can
    be either an astropy unit, the string ``'recommended'`` (to use whatever
    the representation's ``recommended_units`` is), or None (to indicate that
    no unit mapping should be done).
    u   recommendedc         C` s   t  t |   j |  | | |  S(   N(   R6   RQ   R7   (   t   clst   reprnamet	   framenamet   defaultunit(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR7      s    (   RN   RO   t   __doc__R7   (    (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRQ      s   	t   BaseCoordinateFramec           B` s  e  Z d  Z d+ Z d+ Z i  Z e f Z e	   Z
 d   Z e d    Z e d    Z e d    Z e d    Z d   Z d   Z d   Z e d	    Z e d
    Z e d    Z d d  Z d+ d d  Z e d e d e d d  Z e d    Z e d    Z d d  Z d d  Z e e  Z  e e  Z! e" d  Z# e" d  Z$ d   Z% d e" d  Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d    Z, d!   Z- d"   Z. e/ d#    Z0 d$   Z1 d%   Z2 d&   Z3 d'   Z4 e d(    Z5 e d)    Z6 e d*    Z7 RS(,   ux  
    The base class for coordinate frames.

    This class is intended to be subclassed to create instances of specific
    systems.  Subclasses can implement the following attributes:

    * `default_representation`
        A subclass of `~astropy.coordinates.BaseRepresentation` that will be
        treated as the default representation of this frame.  This is the
        representation assumed by default when the frame is created.

    * `default_differential`
        A subclass of `~astropy.coordinates.BaseDifferential` that will be
        treated as the default differential class of this frame.  This is the
        differential class assumed by default when the frame is created.

    * `~astropy.coordinates.Attribute` class attributes
       Frame attributes such as ``FK4.equinox`` or ``FK4.obstime`` are defined
       using a descriptor class.  See the narrative documentation or
       built-in classes code for details.

    * `frame_specific_representation_info`
        A dictionary mapping the name or class of a representation to a list of
        `~astropy.coordinates.RepresentationMapping` objects that tell what
        names and default units should be used on this frame for the components
        of that representation.

    Parameters
    ----------
    representation : `BaseRepresentation` or None
        A representation object or `None` to have no data (or use the other
        arguments)
    *args, **kwargs
        Coordinates, with names that depend on the subclass.
    differential_cls : `BaseDifferential`, dict, optional
        A differential class or dictionary of differential classes (currently
        only a velocity differential with key 's' is supported). This sets
        the expected input differential class, thereby changing the expected
        keyword arguments of the data passed in. For example, passing
        ``differential_cls=CartesianDifferential`` will make the classes
        expect velocity data with the argument names ``v_x, v_y, v_z``.
    copy : bool, optional
        If `True` (default), make copies of the input coordinate arrays.
        Can only be passed in as a keyword argument.
    c         O` s   | j  d t  } g  |  _ | j  d d   } | j  d d   } | d  k	 sW | d  k	 r | d  k ro |  j } n  t j |  r t | t j	  r i | d 6} n | d  k r i d d 6} n  |  j
 | |  n  d  } d  } t |  } t |  d k rt | d t j  s| d d  k r| j  d  } t |  d k rOt d   n  | d  k	 r| j } | j d d   } | d  k rt |  d k s| d  k	 rt |  d k rt d	 j |    qqn|  j r|  j }	 i  }
 xg |  j j   D]V \ } } t |  d k r,| j  d  |
 | <q| | k r| j  |  |
 | <qqW|
 r|
 j d
 t  d  k rz|
 d
 =n  t |	 t j  rd
 |
 k r|	 j }	 n  |	 d | |
  } n  |  j d  } |  j d  } i  } xd | j   D]V \ } } t |  d k r| j  d  | | <q| | k r| j  |  | | <qqW| rt | d  rqd | k rq| j } n* t |  d k rd | k rt j } n  | d | |  } qn  t |  d k rt d j |  j j t |     n  | d  k r| d  k	 rt d   n  | r5| j  i | d 6 |  _! n	 | |  _! i  } x |  j"   j   D]u \ } } | | k r| j  |  } t# |  d | |  t$ |  |  | | <qWt# |  d | |  |  j j% |  qWW| rt d j t |     n  |  j! d  k rd   | j   D } | rt |  d k ry t& | j'     |  _( Wn& t k
 rrt d j |    n Xx1 | D] } t$ |  |  qzWq| j)   d |  _( qd |  _( nf d |  j! j k r|  j! j j |  j! j d j j t* f } n |  j! j j t* f } |  j! |  j+ d | <d  S(   Nu   copyu   representationu   differential_clsu   su   basei    uO   Cannot create a frame with both a representation and other positional argumentsi   u   Multiple differentials are associated with the representation object passed in to the frame initializer. Only a single velocity differential is supported. Got: {0}u   distanceR:   u   _unit_differentialu
   d_distanceu2   {0}.__init__ had {1} remaining unhandled argumentsuT   Cannot pass in differential component data without positional (representation) data.u   _u-   Coordinate frame got unexpected keywords: {0}c         S` s:   i  |  ]0 \ } } t  | d  d  d k r | j |  q S(   u   sizei   (   RH   t   shape(   R1   t   fnmR!   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pys
   <dictcomp>  s   	 	u3   non-scalar attributes with inconsistent shapes: {0}(    (,   R3   R4   t   _attr_names_with_defaultsR'   t   default_representationt   inspectt   isclassR   R   R(   t   set_representation_clsR    t   lenR   R   t	   TypeErrorR*   R%   R   R   R   t   representation_component_namesR#   t   SphericalRepresentationt   _unit_representationt   get_representation_clst"   get_representation_component_namest   hasattrt   _unit_differentialt   RadialDifferentialt	   __class__RN   t   with_differentialst   _datat   get_frame_attr_namest   setattrRH   t   appendR   t   valuest   _no_data_shapet   popitemR5   t   cache(   RI   t   argst   kwargsR:   R   R-   t   representation_datat   differential_datat   diffst   representation_clst   repr_kwargst   nmkwt   nmrept   diff_component_namest   diff_kwargsRo   RY   t   fdefaultR!   t   shapest   key(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __init__  s    	(				
	c         C` s
   t  t  S(   u  
        Cache for this frame, a dict.  It stores anything that should be
        computed from the coordinate data (*not* from the frame attributes).
        This can be used in functions to store anything that might be
        expensive to compute but might be re-used by some other function.
        E.g.::

            if 'user_data' in myframe.cache:
                data = myframe.cache['user_data']
            else:
                myframe.cache['user_data'] = data = expensive_func(myframe.lat)

        If in-place modifications are made to the frame data, the cache should
        be cleared::

            myframe.cache.clear()

        (   R   t   dict(   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRr     s    c         C` s.   |  j  d k r' t d j |     n  |  j  S(   u   
        The coordinate data for this object.  If this frame has no data, an
        `ValueError` will be raised.  Use `has_data` to
        check if data is present on this frame object.
        u6   The frame object "{0!r}" does not have associated dataN(   Rk   R'   R   R   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   data  s    	c         C` s   |  j  d k	 S(   uA   
        True if this frame has `data`, False otherwise.
        N(   Rk   R'   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   has_data  s    c         C` s   |  j  r |  j j S|  j S(   N(   R   R   RX   Rp   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRX     s    c         C` s   t  |  j  S(   N(   R_   R   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __len__  s    c         C` s   |  j  o |  j d k S(   Ni    (   R   t   size(   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __nonzero__  s    c         C` s   |  j  o |  j d k S(   Ni    (   R   R   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __bool__  s    c         C` s
   |  j  j S(   N(   R   R   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     s    c         C` s   |  j  o |  j j S(   N(   R   R   t   isscalar(   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     s    c         ` s   t    f d     j D  S(   Nc         3` s$   |  ] } | t    |  f Vq d  S(   N(   RH   (   R1   R,   (   RR   (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pys	   <genexpr>  s   (   R   t   frame_attributes(   RR   (    (   RR   s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRl     s    u   basec         C` sM   t  |  d  s/ i |  j d 6|  j d 6|  _ n  | d k	 rF |  j | S|  j S(   u.  The class used for part of this frame's data.

        Parameters
        ----------
        which : ('base', 's', `None`)
            The class of which part to return.  'base' means the class used to
            represent the coordinates; 's' the first derivative to time, i.e.,
            the class representing the proper motion and/or radial velocity.
            If `None`, return a dict with both.

        Returns
        -------
        representation : `~astropy.coordinates.BaseRepresentation` or `~astropy.coordinates.BaseDifferential`.
        u   _representationu   baseu   sN(   Rf   R[   t   default_differentialt   _representationR'   (   RI   t   which(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRd     s    c         C` s8   | d k r |  j d } n  t d | d |  |  _ d S(   u  Set representation and/or differential class for this frame's data.

        Parameters
        ----------
        base : str, `~astropy.coordinates.BaseRepresentation` subclass, optional
            The name or subclass to use to represent the coordinate data.
        s : `~astropy.coordinates.BaseDifferential` subclass, optional
            The differential subclass to use to represent any velocities,
            such as proper motion and radial velocity.  If equal to 'base',
            which is the default, it will be inferred from the representation.
            If `None`, the representation will drop any differentials.
        u   baseR)   t   sN(   R'   R   R.   (   RI   R)   R   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR^     s    t   fgett   fsett   docud  The representation class used for this frame's data.

        This will be a subclass from `~astropy.coordinates.BaseRepresentation`.
        Can also be *set* using the string name of the representation. If you
        wish to set an explicit differential class (rather than have it be
        inferred), use the ``set_represenation_cls`` method.
        c         C` s  i  } x t  t j j    t  t j j    D]w } i g  d 6g  d 6| | <xV | j j   D]E } | | d j |  | j j	 | d   } | | d j |  q] Wq/ Wx*|  j j   D]\ } } t | t j  r t |  } n  | | d } | | d } t g  | D] } | j | f ^ q }	 x} t | j j    D]f \ }
 } | |	 k rA|	 | } | j | |
 <t | j t j  o| j d k s| j | |
 <qqAqAWt |  | | d <t |  | | d <q W| S(   Nu   namesu   unitsu   recommended(   R    R   R   Ro   R$   t   attr_classest   keysRn   t   recommended_unitsR%   R'   t#   _frame_specific_representation_infoR#   R   R
   t   string_typesR"   R   RS   t	   enumerateRT   RU   t   tuple(   RR   t
   repr_attrst   repr_diff_clsR2   t   rec_unitt   mappingst   nmst   unsRG   t	   comptomapt   it   mapp(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   _get_representation_info5  s0    ("
c         C` s
   |  j    S(   u   
        A dictionary with the information of what attribute names for this frame
        apply to particular representations.
        (   R   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   representation_infoc  s    c         C` sv   t    } |  j |  } | d  k r( | S| j j   } |  j | d } x' t | |  D] \ } } | | | <qX W| S(   Nu   names(   R   Rd   R'   R   R   R   R   (   RI   R   t   outt   repr_or_diff_clst
   data_namest
   repr_namest	   repr_namet	   data_name(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRe   k  s    	c   	      C` s   t    } |  j |  } | d  k r( | S|  j | } | d } | d } x0 t | |  D] \ } } | rY | | | <qY qY W| S(   Nu   namesu   units(   R   Rd   R'   R   R   (	   RI   R   R   R   R   R   t
   repr_unitsR   t	   repr_unit(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt"   get_representation_component_unitsv  s    	

c         K` s   |  j  | r d n d |  S(   ur  
        Return a replica of the frame, optionally with new frame attributes.

        The replica is a new frame object that has the same data as this frame
        object and with frame attributes overriden if they are provided as extra
        keyword arguments to this method. If ``copy`` is set to `True` then a
        copy of the internal arrays will be made.  Otherwise the replica will
        use a reference to the original arrays when possible to save memory. The
        internal arrays are normally not changeable by the user so in most cases
        it should not be necessary to set ``copy`` to `True`.

        Parameters
        ----------
        copy : bool, optional
            If True, the resulting object is a copy of the data.  When False,
            references are used where  possible. This rule also applies to the
            frame attributes.

        Any additional keywords are treated as frame attributes to be set on the
        new frame object.

        Returns
        -------
        frameobj : same as this frame
            Replica of this object, but possibly with new frame attributes.
        u   copyu	   replicate(   t   _apply(   RI   R:   Rt   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt	   replicate  s    c         K` s&   d | d <|  j | r d n d |  S(   u  
        Return a replica without data, optionally with new frame attributes.

        The replica is a new frame object without data but with the same frame
        attributes as this object, except where overriden by extra keyword
        arguments to this method.  The ``copy`` keyword determines if the frame
        attributes are truly copied vs being references (which saves memory for
        cases where frame attributes are large).

        This method is essentially the converse of `realize_frame`.

        Parameters
        ----------
        copy : bool, optional
            If True, the resulting object has copies of the frame attributes.
            When False, references are used where  possible.

        Any additional keywords are treated as frame attributes to be set on the
        new frame object.

        Returns
        -------
        frameobj : same as this frame
            Replica of this object, but without data and possibly with new frame
            attributes.
        u
   _framedatau   copyu	   replicateN(   R'   R   (   RI   R:   Rt   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   replicate_without_data  s    
c         C` s   |  j  d d | d d S(   u  
        Generates a new frame *with new data* from another frame (which may or
        may not have data). Roughly speaking, the converse of
        `replicate_without_data`.

        Parameters
        ----------
        representation : BaseRepresentation
            The representation to use as the data for the new frame.

        Returns
        -------
        frameobj : same as this frame
            A new object with the same frame attributes as this one, but
            with the ``representation`` as the data.
        u	   replicatet
   _framedataRx   N(   R   R'   (   RI   R   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   realize_frame  s    c         ` s  t  | t  r. t j d t  | } d } n  t d | d |  } | d } d |  j j k rl | d } n- | d k s | d k r d } n t	 d   | r | j
 | j
 | f } n | j
 | f } |  j d j |  } | s| r|  j j | |      j d  n |  j j |    |  j j |  }	 |	 r| rt   f d     j D  }
 xD t   j |	 d	  D], \ } } | rs|
 | j |  |
 | <qsqsW  j d
 t |
    n  | r|  j j d } |  j j |  }	 |	 r| rt  f d    j D  } x t  j |	 d	  D] \ } } t  | t j t j f  rd| | j j k rdq%n* t  | t j  r| | j j k rq%n  | r%t  |  r%| | j |  | | <q%q%W j d
 t |     j j i  d 6 qn    |  j d | <n  |  j d | S(   u  
        Generate and return a new representation of this frame's `data`
        as a Representation object.

        Note: In order to make an in-place change of the representation
        of a Frame or SkyCoord object, set the ``representation``
        attribute of that object to the desired new representation, or
        use the ``set_representation_cls`` method to also set the differential.

        Parameters
        ----------
        base : subclass of BaseRepresentation or string
            The type of representation to generate.  Must be a *class*
            (not an instance), or the string name of the representation
            class.
        s : subclass of `~astropy.coordinates.BaseDifferential`, str, optional
            Class in which any velocities should be represented. Must be
            a *class* (not an instance), or the string name of the
            differential class.  If equal to 'base' (default), inferred from
            the base class.  If `None`, all velocity information is dropped.
        in_frame_units : bool, keyword only
            Force the representation units to match the specified units
            particular to this frame

        Returns
        -------
        newrep : BaseRepresentation-derived object
            A new representation object of this frame's `data`.

        Raises
        ------
        AttributeError
            If this object had no `data`

        Examples
        --------
        >>> from astropy import units as u
        >>> from astropy.coordinates import SkyCoord, CartesianRepresentation
        >>> coord = SkyCoord(0*u.deg, 0*u.deg)
        >>> coord.represent_as(CartesianRepresentation)  # doctest: +FLOAT_CMP
        <CartesianRepresentation (x, y, z) [dimensionless]
                (1., 0., 0.)>

        >>> coord.representation = CartesianRepresentation
        >>> coord  # doctest: +FLOAT_CMP
        <SkyCoord (ICRS): (x, y, z) [dimensionless]
            (1., 0., 0.)>
        un   The argument position for `in_frame_units` in `represent_as` has changed. Use as a keyword argument if needed.u   baseR)   R   u   su   Frame data has no associated differentials (i.e. the frame has no velocity data) - represent_as() only accepts a new representation.u   representationc         3` s$   |  ] } | t    |  f Vq d  S(   N(   RH   (   R1   t   comp(   R   (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pys	   <genexpr>;  s   u   unitsR:   c         3` s$   |  ] } | t    |  f Vq d  S(   N(   RH   (   R1   R   (   t   diff(    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pys	   <genexpr>J  s   N(   R   t   boolt   warningst   warnR	   R.   R   R*   R'   R`   RN   Rr   R%   t   represent_asR   R   t
   componentsR   t   toRi   R5   R   t   UnitSphericalDifferentialt   UnitSphericalCosLatDifferentialR   Rh   Rf   t   _differentialst   update(   RI   R)   R   t   in_frame_unitsR+   Rx   R-   t	   cache_keyt   cached_reprt	   new_attrst
   datakwargsR   t   new_attr_unitt	   data_difft
   diffkwargs(    (   R   R   s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     sj    6		
		#c         C` s8  d d l  m } |  j d	 k r. t d   n  t |  j d d	  r t |  d  r t | d  r t j	 |  j
 | j
 k  r t d   n  t j |  r |   } n  t | d  r | j } n  t j |  j | j  } | d	 k r+| |  j k r| j |  j  Sd } | | j |  j | j    n  | |  |  S(
   u  
        Transform this object's coordinate data to a new frame.

        Parameters
        ----------
        new_frame : class or frame object or SkyCoord object
            The frame to transform this coordinate frame into.

        Returns
        -------
        transframe
            A new object with the coordinate data represented in the
            ``newframe`` system.

        Raises
        ------
        ValueError
            If there is no possible transformation route.
        i   (   t   ConvertErroru%   Cannot transform a frame with no datau   differentialsu   obstimeu   You cannot transform a frame that has velocities to another frame at a different obstime. If you think this should (or should not) be possible, please comment at https://github.com/astropy/astropy/issues/6280u   _sky_coord_frameu    Cannot transform from {0} to {1}N(   t   errorsR   Rk   R'   R   RH   R   Rf   t   npt   anyt   obstimet   NotImplementedErrorR\   R]   t   _sky_coord_framet   frame_transform_grapht   get_transformRi   R   R   (   RI   t	   new_frameR   t   transt   msg(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   transform_tos  s&    !c         C` sa   t  j |  r | n | j } t j |  j |  } | d k rY | |  j k rR d St Sn t Sd S(   u  
        Determines if this coordinate frame can be transformed to another
        given frame.

        Parameters
        ----------
        new_frame : class or frame object
            The proposed frame to transform into.

        Returns
        -------
        transformable : bool or str
            `True` if this can be transformed to ``new_frame``, `False` if
            not, or the string 'same' if ``new_frame`` is the same system as
            this object but no transformation is defined.

        Notes
        -----
        A return value of 'same' means the transformation will work, but it will
        just give back a copy of this object.  The intended usage is::

            if coord.is_transformable_to(some_unknown_frame):
                coord2 = coord.transform_to(some_unknown_frame)

        This will work even if ``some_unknown_frame``  turns out to be the same
        frame class as ``coord``.  This is intended for cases where the frame
        is the same regardless of the frame attributes (e.g. ICRS), but be
        aware that it *might* also indicate that someone forgot to define the
        transformation between two objects of the same frame class but with
        different attributes.
        u   sameN(   R\   R]   Ri   R   R   R'   R5   R4   (   RI   R   t   new_frame_clsR   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   is_transformable_to  s    !c         C` s   | |  j  k S(   u  
        Determine whether or not a frame attribute has its value because it's
        the default value, or because this frame was created with that value
        explicitly requested.

        Parameters
        ----------
        attrnm : str
            The name of the attribute to check.

        Returns
        -------
        isdefault : bool
            True if the attribute ``attrnm`` has its value by default, False if
            it was specified at creation of this frame.
        (   RZ   (   RI   t   attrnm(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   is_frame_attr_default  s    c         C` s~   |  j  | j  k rX x? |  j   D]1 } t j t |  |  t | |  k  r t Sq Wt St | t  sv t	 d   n t Sd S(   ul  
        Checks if this object is the same frame as the ``other`` object.

        To be the same frame, two objects must be the same frame class and have
        the same frame attributes.  Note that it does *not* matter what, if any,
        data either object has.

        Parameters
        ----------
        other : BaseCoordinateFrame
            the other frame to check

        Returns
        -------
        isequiv : bool
            True if the frames are the same, False if not.

        Raises
        ------
        TypeError
            If ``other`` isn't a `BaseCoordinateFrame` or subclass.
        u?   Tried to do is_equivalent_frame on something that isn't a frameN(
   Ri   Rl   R   R   RH   R5   R4   R   RW   R`   (   RI   t   othert   frame_attr_name(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   is_equivalent_frame  s    c         C` si   |  j    } |  j   } | r0 d j |  } n  | rO d j |  j j | |  Sd j |  j j |  Sd  S(   Nu    ({0})u   <{0} Coordinate{1}: {2}>u   <{0} Frame{1}>(   t   _frame_attrs_reprt
   _data_reprR   Ri   RN   (   RI   t
   frameattrst	   data_repr(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __repr__
  s    
c         C` s  |  j  s d S|  j rt |  j t j  rO t |  j t j  rO |  j j } n	 |  j } d |  j j	 k r |  j
 d  } |  j j	 d } t | t j t j t j f  r | j } q n d } |  j | | d t } t |  } xJ |  j j   D] \ } } | j | |  } q Wn |  j } t |  j  } | j d | j j  ri| t | j j  d d !} n
 d | } d |  j j	 k r| j d  } d	 | d k r|t | j	 d  j d  }	 |	 d
 j d  rd d j |	 d
 j d  d  |	 d
 <n  x= |  j d  j   D]& \ }
 } |	 d
 j | |
  |	 d
 <qW|	 d j d  rf|	 d d  |	 d <n  d j |	  | d <n  d j |  } n  | S(   u7   Returns a string representation of the coordinate data.u    u   sR   u   <i   iu   Data:
u   
u   has differentialsi    u    i   u   >N(   R   R   R   R   Rb   R   R   t   UnitSphericalRepresentationRi   R*   Rd   R   R   Rh   R'   R   R4   t   reprRa   R#   t   replacet
   startswithRN   R_   t   splitt   joinRe   t   endswith(   RI   t   rep_clst   dif_clst   dif_dataR   R   t   nmpreft   nmreprt   data_repr_splt   diffreprt   frm_nmt   rep_nm(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     sJ    				 
+"c         C` s=   d j  g  |  j   D]# } | d t t |  |   ^ q  S(   uT   
        Returns a string representation of the frame's attributes, if any.
        u   , u   =(   R   Rl   t   strRH   (   RI   R   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR   Q  s    	c         ` s  d  k r  j  d  } n |  j r0 |  j n d } t j |  rT t d   n   j  d |  j  }  j  d |  j d   }     f d   } | d k	 r | |  } n  i | d 6| d 6} x |  j	   D] }	 |	 |  j
 k r  d k s d	 k r|	  k r |	 }
 n t |  |	  }
 t |
 d
 d  d k rQ| |
  }
 n*  d k si d k r{t j |
  }
 n  |
 | |	 <q q W|  j | |  S(   ux  Create a new instance, applying a method to the underlying 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 in the representation (e.g., ``x``,
        ``y``, and ``z`` for `~astropy.coordinates.CartesianRepresentation`),
        as well as to any frame attributes that have a shape, with the results
        used to create a new instance.

        Internally, it is also used to apply functions to the above parts
        (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``.
        u
   _framedatau   Class passed as data instead of a representation instance. If you called frame.representation, this returns the representation class. frame.data returns the instantiated object - you may want to  use this instead.u   representation_clsu   differential_clsu   sc         ` s   t  |  t  rE  d k r/ t |    r/ |  S|  j      SnR t   ra  |      S d k r t |    r |  St |         Sd  S(   Nu	   replicate(   R   R   Rf   R   t   callableRH   (   R!   (   Rs   Rt   t   method(    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   apply_method  s    u   representationu   copyu	   replicateu   sizei   u   flattenN(   R3   R   R   R'   R\   R]   R`   R   Rd   Rl   RZ   RH   R:   Ri   (   RI   R   Rs   Rt   R   Rx   R-   R   t   frattrsRM   R!   (    (   Rs   Rt   R   s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR   X  s2    		

$c         C` s,   t  |  j  } | t  |  j d   O} | S(   u   
        Override the builtin `dir` behavior to include representation
        names.

        TODO: dynamic representation transforms (i.e. include cylindrical et al.).
        u   s(   t   setRa   Re   (   RI   t
   dir_values(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __dir__  s    c         C` s   | j  d  r |  j |  S|  j } | | k ry |  j d k rJ |  j n  |  j |  j d t } t	 | | |  } | S|  j
 d  } | | k r |  j d k r |  j n  |  j d t |  j d   } t	 | j d | |  } | S|  j |  S(   u$  
        Allow access to attributes on the representation and differential as
        found via ``self.get_representation_component_names``.

        TODO: We should handle dynamic representation transforms here (e.g.,
        `.cylindrical`) instead of defining properties as below.
        u   _R   u   sN(   R   t   __getattribute__Ra   Rk   R'   R   R   R   R4   RH   Re   Rd   R*   (   RI   RM   R   t   rept   valt
   diff_names(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   __getattr__  s$    	

c         C` s   | j  d  s| t |  d  r| t   } x( |  j j   D] } | j | d  q7 W| | k ry t d j |    qy q| n  t t	 |   j
 | |  d  S(   Nu   _u   representation_infou   namesu"   Cannot set any frame attribute {0}(   R   Rf   R   R   Ro   R   t   AttributeErrorR   R6   RW   t   __setattr__(   RI   RM   R!   t   repr_attr_namest   representation_attr(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     s    	c         C` s   d d l  m } d d l m } |  j t j  } | j |   } | j t j  } | | j | j	 | j | j	  } | | d t
 j S(   u  
        Computes on-sky separation between this coordinate and another.

        .. note::

            If the ``other`` coordinate object is in a different frame, it is
            first transformed to the frame of this object. This can lead to
            unintutive behavior if not accounted for. Particularly of note is
            that ``self.separation(other)`` and ``other.separation(self)`` may
            not give the same answer in this case.

        Parameters
        ----------
        other : `~astropy.coordinates.BaseCoordinateFrame`
            The coordinate to get the separation to.

        Returns
        -------
        sep : `~astropy.coordinates.Angle`
            The on-sky separation between this and the ``other`` coordinate.

        Notes
        -----
        The separation is calculated using the Vincenty formula, which
        is stable at all locations, including poles and antipodes [1]_.

        .. [1] https://en.wikipedia.org/wiki/Great-circle_distance

        i   (   t   angular_separation(   t   Anglet   unit(   t   angle_utilitiesR   t   anglesR  R   R   R   R   t   lont   latt   ut   degree(   RI   R   R   R  t   self_unit_spht   other_transformedt   other_unit_spht   sep(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt
   separation  s    c         C` s   d d l  m } t |  j j t j  r7 t d   n  | j |   } t | j t j  rj t d   n  |  j j	   j
 t j  } | j j	   j
 t j  } | | | j    S(   u  
        Computes three dimensional separation between this coordinate
        and another.

        Parameters
        ----------
        other : `~astropy.coordinates.BaseCoordinateFrame`
            The coordinate system to get the distance to.

        Returns
        -------
        sep : `~astropy.coordinates.Distance`
            The real-space distance between these two coordinates.

        Raises
        ------
        ValueError
            If this or the other coordinate do not have distances.
        i   (   t   DistanceuC   This object does not have a distance; cannot compute 3d separation.uH   The other object does not have a distance; cannot compute 3d separation.(   t	   distancesR  R   R   Ri   R   R   R   R   t   without_differentialsR   t   CartesianRepresentationt   norm(   RI   R   R  t   other_in_self_systemt   self_cart	   other_car(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   separation_3d  s    c         C` s   |  j  d d t S(   ue   
        Shorthand for a cartesian representation of the coordinates in this
        object.
        u	   cartesianR   (   R   R4   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt	   cartesianE  s    	c         C` s   |  j  d d t S(   ue   
        Shorthand for a spherical representation of the coordinates in this
        object.
        u	   sphericalR   (   R   R4   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt	   sphericalP  s    	c         C` s   |  j  d d d t S(   u   
        Shorthand for a spherical representation of the positional data and a
        `SphericalCosLatDifferential` for the velocity data in this object.
        u	   sphericalu   sphericalcoslatR   (   R   R4   (   RI   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   sphericalcoslat[  s    	N(8   RN   RO   RV   R'   R[   R   t"   frame_specific_representation_infoR   t   _inherit_descriptors_R   R   R   R   Rr   RL   R   R   RX   R   R   R   R   R   t   classmethodRl   Rd   R^   R   R   R   Re   R   Ra   t   representation_component_unitsR5   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  (    (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyRW      s`   .							.		5	,		#		9		V	*		*	(t   GenericFramec           B` s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   uS  
    A frame object that can't store data but can hold any arbitrary frame
    attributes. Mostly useful as a utility for the high-level class to store
    intermediate frame attributes.

    Parameters
    ----------
    frame_attrs : dict
        A dictionary of attributes to be used as the frame attributes for this
        frame.
    c         C` sj   t    |  _ xA | j   D]3 \ } } t |  |  j | <t |  d | |  q Wt t |   j d   d  S(   Nu   _(	   R   R   R#   R   Rm   R6   R  R   R'   (   RI   t   frame_attrsR,   t   default(    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR   w  s
    c         C` s=   d | |  j  k r$ t |  d |  St d j |    d  S(   Nu   _u   no {0}(   R0   RH   R   R   (   RI   R,   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     s    c         C` sG   | |  j    k r* t d j |    n t t |   j | |  d  S(   Nu   can't set frame attribute '{0}'(   Rl   R   R   R6   R  R   (   RI   R,   R!   (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR     s    N(   RN   RO   RV   R'   R,   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyR  h  s
   		(7   RV   t
   __future__R    R   R   R   t   abcR:   R\   t   collectionsR   R   R   R   t   numpyR   t   utils.compat.miscR   t   utils.decoratorsR   t   utils.exceptionsR	   t   externR
   t   extern.six.movesR   t    R   R  t   utilsR   R   R   t   transformationsR   R   R   t
   attributesR   R   R   R   R   R   t   __all__R   R"   R.   t   ABCMetaR/   t   _RepresentationMappingBaseRQ   t   add_metaclassRW   R  (    (    (    s<   lib/python2.7/site-packages/astropy/coordinates/baseframe.pyt   <module>   sD   "(			-P    