ó
šßÈ[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 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 d d l m Z d „  Z d d g Z g  e j D] Z  e  f ^ qZ! e! j" d! ƒ e j# j$ d" e! ƒ d „  ƒ Z% e j# j$ d# e! ƒ d „  ƒ Z& e j# j$ d$ e! ƒ d „  ƒ Z' e j# j$ d% e! ƒ d „  ƒ Z( e j# j$ d& e! ƒ d „  ƒ Z) d e* f d „  ƒ  YZ+ d e* f d „  ƒ  YZ, d „  Z- d „  Z. d „  Z/ d  „  Z0 d S('   u,   Test sky projections defined in WCS Paper IIi    (   t   absolute_importt   unicode_literalst   divisiont   print_functionN(   t   assert_allcloset   assert_almost_equali   (   t   projections(   t   InputParameterErrori   (   t   units(   t   fits(   t   wcs(   t   get_pkg_data_filename(   t   ranget   zip(   t   assert_quantity_allclosec          C` s:   t  j ƒ  }  |  j d k s! t ‚ |  j d k s6 t ‚ d  S(   Ni   (   R   t   Sky2Pix_PlateCarreet   n_inputst   AssertionErrort	   n_outputs(   t
   projection(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_Projection_properties   s    iöÿÿÿi   u   XPHu   codec         C` s°  t  j j t  j t  j d d d d j |  ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} g  } xG t
 d ƒ D]9 } d j | d	 ƒ } | | k rm | j | | ƒ qm qm Wt j | ƒ } d
 d
 g | j _ d d g | j _ d	 d	 g | j _ | j j t g d	 ƒ } | j j | d d	 ƒ d }	 t t d |  ƒ }
 |
 | Œ  } | | d | d ƒ \ } } t t j | ƒ |	 d d … d f ƒ t t j | ƒ |	 d d … d	 f ƒ d S(   u,   Check astropy model eval against wcslib evalu   wcsu   testsu   mapsu   1904-66_{0}.hdrt   endcardt   paddingi   u   PV2_{0}i   g        i    u   worldu   pixcrdu   Sky2Pix_u   phiu   thetaN(   t   ost   patht   joint   pardirt   formatR   R	   t   Headert   fromfilet   FalseR   t   appendR
   t   WCSt   crvalt   crpixt   cdeltt   p2st   PIX_COORDINATESt   s2pt   getattrR   R   t   npt   asarray(   t   codet   wcs_mapt	   test_filet   headert   paramst   it   keyt   wt	   wcsliboutt   wcs_pixt   modelt   tinvt   xt   y(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_Sky2Pix'   s(    &c         C` s|  t  j j t  j t  j d d d d j |  ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} g  } xG t
 d ƒ D]9 } d j | d	 ƒ } | | k rm | j | | ƒ qm qm Wt j | ƒ } d
 d
 g | j _ d d g | j _ d	 d	 g | j _ | j j t g d	 ƒ } | d }	 | d }
 t t d |  ƒ } | | Œ  } | t Œ  \ } } t t j | ƒ |	 ƒ t t j | ƒ |
 ƒ d S(   u,   Check astropy model eval against wcslib evalu   wcsu   testsu   mapsu   1904-66_{0}.hdrR   R   i   u   PV2_{0}i   g        i    u   phiu   thetau   Pix2Sky_N(   R   R   R   R   R   R   R	   R   R   R   R   R   R
   R    R!   R"   R#   R$   R%   R'   R   R   R(   R)   (   R*   R+   R,   R-   R.   R/   R0   R1   R2   t   wcs_phit	   wcs_thetaR4   t   tanprjt   phit   theta(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_Pix2SkyC   s*    

c         C` sº  t  j j t  j t  j d d d d j |  ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} g  } xG t
 d ƒ D]9 } d j | d	 ƒ } | | k rm | j | | ƒ qm qm Wt j | ƒ } d
 d
 g | j _ d d g | j _ d	 d	 g | j _ | j j t g d	 ƒ } | j j | d d	 ƒ d }	 t t d |  ƒ }
 |
 | Œ  } | | d t j | d t j ƒ \ } } t | |	 d d … d f t j ƒ t | |	 d d … d	 f t j ƒ d S(   u,   Check astropy model eval against wcslib evalu   wcsu   testsu   mapsu   1904-66_{0}.hdrR   R   i   u   PV2_{0}i   g        i    u   worldu   pixcrdu   Sky2Pix_u   phiu   thetaN(   R   R   R   R   R   R   R	   R   R   R   R   R   R
   R    R!   R"   R#   R$   R%   R&   R'   R   t   ut   degR   (   R*   R+   R,   R-   R.   R/   R0   R1   R2   R3   R4   R5   R6   R7   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_Sky2Pix_unit`   s(    +$c         C` s  t  j j t  j t  j d d d d j |  ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} g  } xG t
 d ƒ D]9 } d j | d	 ƒ } | | k rm | j | | ƒ qm qm Wt j | ƒ } d
 d
 g | j _ d d g | j _ d	 d	 g | j _ | j j t g d	 ƒ } | d }	 | d }
 t t d |  ƒ } | | Œ  } | t t j Œ  \ } } t | |	 t j ƒ t | |
 t j ƒ | t t j j t j ƒ Œ  \ } } t | |	 t j ƒ t | |
 t j ƒ | t t j j t j ƒ Œ  \ } } t | |	 t j ƒ t | |
 t j ƒ d S(   u,   Check astropy model eval against wcslib evalu   wcsu   testsu   mapsu   1904-66_{0}.hdrR   R   i   u   PV2_{0}i   g        i    u   phiu   thetau   Pix2Sky_N(   R   R   R   R   R   R   R	   R   R   R   R   R   R
   R    R!   R"   R#   R$   R%   R'   R   R?   R@   R   t   tot   radt   arcmin(   R*   R+   R,   R-   R.   R/   R0   R1   R2   R9   R:   R4   R;   R<   R=   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_Pix2Sky_unit|   s6    

%%c         C` sf   t  t d |  ƒ } | ƒ  } | d d ƒ \ } } t  t d |  ƒ } | ƒ  } | d d ƒ \ } } d S(   u0   Check astropy model eval with default parametersu   Sky2Pix_i-   u   Pix2Sky_i    N(   R'   R   (   R*   R4   R5   R6   R7   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_projection_defaultŸ   s    		t   TestZenithalPerspectivec           B` s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   u$   Test Zenithal Perspective projectionc         C` s  d } t  j j t  j t  j d d d d j | ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} t
 j | ƒ |  _ t j d d g ƒ |  j j
 _ t j d d g ƒ |  j j
 _ t j d	 d	 g ƒ |  j j
 _ g  |  j j
 j ƒ  D] } | d
 ^ qß |  _ t j |  j Œ  |  _ d  S(   Nu   AZPu   wcsu   testsu   mapsu   1904-66_{0}.hdrR   R   g        g      ð?i   (   R   R   R   R   R   R   R	   R   R   R   R
   R    t   wazpR(   t   arrayR"   R!   R#   t   get_pvt   pv_kwR   t   Pix2Sky_ZenithalPerspectivet   azp(   t   selft   IDR+   R,   R-   t   kw(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   setup_class±   s    ,c         C` s}   |  j  j j d d g g d ƒ } | d } | d } |  j d d ƒ \ } } t t j | ƒ | ƒ t t j | ƒ | ƒ d  S(   Niöÿÿÿi   i   u   phiu   theta(   RH   R
   R$   RM   R   R(   R)   (   RN   R2   R9   R:   R<   R=   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_AZP_p2s¾   s    !

c         C` s´   |  j  j j d d g g d ƒ } |  j  j j | d d ƒ d } |  j j | d | d ƒ \ } } t t j | ƒ | d  d  … d f ƒ t t j | ƒ | d  d  … d f ƒ d  S(	   Niöÿÿÿi   i   u   worldu   pixcrdu   phiu   thetai    (	   RH   R
   R$   R&   RM   t   inverseR   R(   R)   (   RN   R2   R3   R6   R7   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_AZP_s2pÆ   s
    ! #&(   t   __name__t
   __module__t   __doc__RQ   RR   RT   (    (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyRG   ®   s   		t   TestCylindricalPerspectivec           B` s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   u'   Test cylindrical perspective projectionc         C` s  d } t  j j t  j t  j d d d d j | ƒ ƒ } t | ƒ } t j j | d t	 d t	 ƒ} t
 j | ƒ |  _ t j d d g ƒ |  j j
 _ t j d d g ƒ |  j j
 _ t j d	 d	 g ƒ |  j j
 _ g  |  j j
 j ƒ  D] } | d
 ^ qß |  _ t j |  j Œ  |  _ d  S(   Nu   CYPu   wcsu   testsu   mapsu   1904-66_{0}.hdrR   R   g        g      ð?i   (   R   R   R   R   R   R   R	   R   R   R   R
   R    RH   R(   RI   R"   R!   R#   RJ   RK   R   t   Pix2Sky_CylindricalPerspectiveRM   (   RN   RO   R+   R,   R-   RP   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyRQ   Ñ   s    ,c         C` s}   |  j  j j d d g g d ƒ } | d } | d } |  j d d ƒ \ } } t t j | ƒ | ƒ t t j | ƒ | ƒ d  S(   Niöÿÿÿi   i   u   phiu   theta(   RH   R
   R$   RM   R   R(   R)   (   RN   R2   R9   R:   R<   R=   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_CYP_p2sÞ   s    !

c         C` s´   |  j  j j d d g g d ƒ } |  j  j j | d d ƒ d } |  j j | d | d ƒ \ } } t t j | ƒ | d  d  … d f ƒ t t j | ƒ | d  d  … d f ƒ d  S(	   Niöÿÿÿi   i   u   worldu   pixcrdu   phiu   thetai    (	   RH   R
   R$   R&   RM   RS   R   R(   R)   (   RN   R2   R3   R6   R7   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_CYP_s2pæ   s
    ! #&(   RU   RV   RW   RQ   RZ   R[   (    (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyRX   Î   s   		c          C` sÊ   t  j d d d g d d g g d d d g ƒ }  d d g d d g d d g d d g g } t | Œ  \ } } t j |  | | ƒ ƒ j } t j | d d g d d g d d g d d g g k ƒ sÆ t ‚ d  S(   Nt   matrixi   i    t   translationi   i   i   (   R   t   AffineTransformation2DR   R(   t   vstackt   Tt   allR   (   R4   t   rectR6   R7   t   new_rect(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_AffineTransformation2Dî   s    	'*c          C` sî   t  j d d d g d d g g ƒ }  t j t ƒ  |  j Wd  QXt  j d d d g d d g g d d d	 g ƒ } d
 d
 g d d
 g d
 d g d d g g } t | Œ  \ } } | j | | | ƒ Œ  \ } } t | | g | | g d d ƒd  S(   NR\   i   g333333ó?g333333@gffffff@g333333@R]   g333333"@g¸…ëQ8$@i    i   t   atolg»½×Ùß|Û=(   R   R^   t   pytestt   raisesR   RS   R   R   (   t   model1t   model2Rb   R6   R7   t   x_newt   y_new(    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt#   test_AffineTransformation2D_inverseý   s    		'*c          C` s›   t  j d ƒ j d ƒ }  t j d d ƒ } | |  d  d  … d f |  d  d  … d f ƒ \ } } t | d d d	 d
 d g ƒ t | d d d d d g ƒ d  S(   Ni
   i   i   i   i    i   g        gÁÉ‘)z;@g,6œè©ô@gª–Û€@g’®™|³]!@gð×	ÔSÀgÊB*{×RÀg­RÕ_
ˆRÀg,ôÁ262RÀgyÃkÍÕQÀ(   i   i   (   R(   t   aranget   reshapeR   t   Sky2Pix_ZenithalPerspectiveR   (   t   coordsR4   R<   R=   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_c_projection_striding  s    5c    	      C` sÕ   d \ }  } t  j d d |  ƒ } t  j d d | ƒ } t  j | | ƒ \ } } t j ƒ  } | | | ƒ \ } } t | d d d d d g d d d	 d
 d g g ƒ t | d d d d d g d d d d d g g ƒ d  S(   Ni   i   i    i   g        g     €V@g     €f@g5ï×¾d@g®ªÉë-c@g?LgÌ)äa@g     à`@gß?« pV@g¤È95 `V@gÁ\¤³ PV@gEÎ©@V@gl¾¾”	>V@g6	œtt8V@gÕ?0V@g®:‚%V@(   i   i   (   R(   t   linspacet   meshgridR   t   Pix2Sky_TANR   (	   t   nxt   nyR6   R7   t   xvt   yvR4   R<   R=   (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   test_c_projections_shaped$  s    (   u   XPH(   u   code(   u   code(   u   code(   u   code(   u   code(1   RW   t
   __future__R    R   R   R   R   Rf   t   numpyR(   t   numpy.testingR   R   t    R   t
   parametersR   R   R?   t   ioR	   R
   t
   utils.dataR   t   extern.six.movesR   R   t   tests.helperR   R   R%   t	   projcodesR6   t   parst   removet   markt   parametrizeR8   R>   RA   RE   RF   t   objectRG   RX   Rd   Rl   Rq   Ry   (    (    (    sF   lib/python2.7/site-packages/astropy/modeling/tests/test_projections.pyt   <module>   s8   "	#  			