
    IR-eߵ                     	   d Z ddlZddlmZmZ ddlZddlmZ	 ddlm
Z
 ddlmZ ddlmZmZ dd	lmZmZ g d
ZdgZ ee          Zd eD             Zg d e edj         eddg ee                               z   Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z  G d dee           Z! G d dee           Z" G d d ee           Z# G d! d"ee           Z$ G d# d$ee           Z% G d% d&ee           Z& G d' d(ee           Z' G d) d*ee           Z( G d+ d,ee           Z) G d- d.ee           Z* G d/ d0ee           Z+ G d1 d2ee           Z, G d3 d4ee           Z- G d5 d6ee           Z. G d7 d8ee           Z/ G d9 d:ee           Z0 G d; d<e          Z1 G d= d>ee1          Z2 G d? d@ee1          Z3 G dA dBee1          Z4 G dC dDee1          Z5 G dE dFee1          Z6 G dG dHee1          Z7 G dI dJee1          Z8 G dK dLee1          Z9 G dM dNe          Z: G dO dPee:          Z; G dQ dRee:          Z< G dS dTee:          Z= G dU dVee:          Z> G dW dXee:          Z? G dY dZee:          Z@ G d[ d\ee:          ZA G d] d^ee:          ZB G d_ d`e          ZC G da dbeeC          ZD G dc ddeeC          ZE G de dfeeC          ZF G dg dheeC          ZG G di djeeC          ZH G dk dleeC          ZI G dm dneeC          ZJ G do dpeeC          ZK G dq dre          ZL G ds dteeL          ZM G du dveeL          ZN G dw dxeeL          ZO G dy dzeeL          ZP G d{ d|e          ZQ G d} d~eeQ          ZR G d deeQ          ZS G d deeQ          ZT G d deeQ          ZU G d deeQ          ZV G d deeQ          ZW G d de          ZX G d deeX          ZY G d deeX          ZZ G d deeX          Z[ G d deeX          Z\ G d de          Z]eD ]\  Z^Z_ e`            de^z             e`            de_z   <    e`            de^z             e`            de_z   <    e`            de^z             e`            de^z            _a         e`            de^z             e`            de^z            _a        dS )aK  
Implements projections--particularly sky projections defined in WCS Paper II
[1]_.

All angles are set and and displayed in degrees but internally computations are
performed in radians. All functions expect inputs and outputs degrees.

References
----------
.. [1] Calabretta, M.R., Greisen, E.W., 2002, A&A, 395, 1077 (Paper II)
    N)chainproduct)units)wcs   )Model)InputParameterError	Parameter)_to_orig_unit
_to_radian))ZenithalPerspectiveAZP)SlantZenithalPerspectiveSZP)GnomonicTAN)StereographicSTG)SlantOrthographicSIN)ZenithalEquidistantARC)ZenithalEqualAreaZEA)AiryAIR)CylindricalPerspectiveCYP)CylindricalEqualAreaCEA)PlateCarreeCAR)MercatorMER)SansonFlamsteedSFL)	ParabolicPAR)
MolleweideMOL)HammerAitoffAIT)ConicPerspectiveCOP)ConicEqualAreaCOE)ConicEquidistantCOD)ConicOrthomorphicCOO)BonneEqualAreaBON)	PolyconicPCO)TangentialSphericalCubeTSC)COBEQuadSphericalCubeCSC)QuadSphericalCubeQSC)HEALPixHPX)HEALPixPolarXPHZPNc                     g | ]\  }}|S  rE   ).0_codes      <lib/python3.11/site-packages/astropy/modeling/projections.py
<listcomp>rJ   @   s    111gaT111    )
ProjectionPix2SkyProjectionSky2PixProjectionZenithalCylindricalPseudoCylindricalConicPseudoConicQuadCuber?   AffineTransformation2D	projcodesrG   Pix2SkySky2Pixc                   ,     e Zd ZdZ fdZ fdZ xZS )_ParameterDSai  
    Same as `Parameter` but can indicate its modified status via the ``dirty``
    property. This flag also gets set automatically when a parameter is
    modified.

    This ability to track parameter's modified status is needed for automatic
    update of WCSLIB's prjprm structure (which may be a more-time intensive
    operation) *only as required*.

    c                 H     t                      j        |i | d| _        d S NT)super__init__dirtyselfargskwargs	__class__s      rI   r^   z_ParameterDS.__init___   s*    $)&)))


rK   c                 X    t                                          |           d| _        d S r\   )r]   validater_   )ra   valuerd   s     rI   rf   z_ParameterDS.validatec   s&    


rK   )__name__
__module____qualname____doc__r^   rf   __classcell__rd   s   @rI   rZ   rZ   S   s[        	 	            rK   rZ   c                        e Zd ZdZdej        z  ej        z  ZdZ	 fdZ
eej        d                         Zed             Zd Zd Zd	 Z xZS )
rL   z#Base class for all sky projections.   Fc                 j     t                      j        |i | t          j                    | _        d S N)r]   r^   r   Prjprm_prjr`   s      rI   r^   zProjection.__init__q   s0    $)&)))JLL			rK   c                     dS )zT
        Inverse projection--all projection models must provide an inverse.
        NrE   ra   s    rI   inversezProjection.inverseu   s      rK   c                 8    |                                   | j        S )zWCSLIB ``prjprm`` structure.)_update_prjrs   ru   s    rI   prjprmzProjection.prjprm|   s     	yrK   c                    | j         sdS g }d}| j         D ]J}t          | |          }|                    t          |j                             ||j        z  }d|_        K|r+dg|R | j        _        | j                                         dS dS )a  
        A default updater for projection's pv.

        .. warning::
            This method assumes that PV0 is never modified. If a projection
            that uses PV0 is ever implemented in this module, that projection
            class should override this method.

        .. warning::
            This method assumes that the order in which PVi values (i>0)
            are to be assigned is identical to the order of model parameters
            in ``param_names``. That is, pv[1] = model.parameters[0], ...

        NF)	param_namesgetattrappendfloatrg   r_   rs   pvset)ra   r   r_   pparams        rI   rx   zProjection._update_prj   s      	F! 	  	 AD!$$EIIeEK(()))U[ EEKK 	9"99DILIMMOOOOO	 	rK   c                 8    | j         | j        | j        | j        dS )N)r   fixedtiedbounds)
parametersr   r   r   ru   s    rI   __getstate__zProjection.__getstate__   s%    ZIk	
 
 	
rK   c                 F    |                     d          } | j        |i |S )Nr   )popr^   )ra   stateparamss      rI   __setstate__zProjection.__setstate__   s(    3t}f....rK   )rh   ri   rj   rk   udegnppir0
_separabler^   propertyabcabstractmethodrv   ry   rx   r   r   rl   rm   s   @rI   rL   rL   h   s        -- 
quru	BJ! ! ! ! !    X
   X
  >
 
 
/ / / / / / /rK   rL   c                        e Zd ZdZdZdZdZdZ fdZ fdZ	e
d             Ze
d             Zd Ze
d	             Z xZS )
rM   z'Base class for all Pix2Sky projections.   Tc                     | j                             d          d         }t          |         | _        t	                                          |           S NrG   r   namesplit_PROJ_NAME_CODE_MAPprj_coder]   __new__clsrb   rc   	long_namerd   s       rI   r   zPix2SkyProjection.__new__   =    HNN3''*	*95wws###rK   c                      t                      j        |i | | j        | j        _        |                                  | j        s| j                                         d| _        d| _	        d S )Nxyphitheta
r]   r^   r   rs   rH   rx   r{   r   inputsoutputsr`   s      rI   r^   zPix2SkyProjection.__init__   sj    $)&)))	 	 IMMOOO 'rK   c                 b    | j         d         t          j        | j         d         t          j        iS Nr   r   r   r   r   ru   s    rI   input_unitszPix2SkyProjection.input_units   !    At{1~qu==rK   c                 b    | j         d         t          j        | j         d         t          j        iS r   r   r   r   ru   s    rI   return_unitszPix2SkyProjection.return_units   !    QQ??rK   c                 `    |                                   | j                            ||          S rq   )rx   rs   prjx2s)ra   r   r   rb   rc   s        rI   evaluatezPix2SkyProjection.evaluate   s,    y1%%%rK   c                 >      fd j         D             }  j        | S )Nc                 :    g | ]}t          |          j        S rE   r|   rg   rF   r   ra   s     rI   rJ   z-Pix2SkyProjection.inverse.<locals>.<listcomp>   &    GGGUgdE""(GGGrK   r{   _inv_clsra   r   s   ` rI   rv   zPix2SkyProjection.inverse   .    GGGGd6FGGGt}b!!rK   rh   ri   rj   rk   n_inputs	n_outputs_input_units_strict _input_units_allow_dimensionlessr   r^   r   r   r   r   rv   rl   rm   s   @rI   rM   rM      s        11HI'+$$ $ $ $ $
( ( ( ( ( > > X> @ @ X@& & & " " X" " " " "rK   rM   c                        e Zd ZdZdZdZdZdZ fdZ fdZ	e
d             Ze
d             Zd Ze
d	             Z xZS )
rN   z'Base class for all Sky2Pix projections.r   Tc                     | j                             d          d         }t          |         | _        t	                                          |           S r   r   r   s       rI   r   zSky2PixProjection.__new__   r   rK   c                      t                      j        |i | | j        | j        _        |                                  | j        s| j                                         d| _        d| _	        d S )Nr   r   r   r`   s      rI   r^   zSky2PixProjection.__init__   sj    $)&)))	 	 IMMOOO&!rK   c                 b    | j         d         t          j        | j         d         t          j        iS r   r   ru   s    rI   r   zSky2PixProjection.input_units   r   rK   c                 b    | j         d         t          j        | j         d         t          j        iS r   r   ru   s    rI   r   zSky2PixProjection.return_units   r   rK   c                 `    |                                   | j                            ||          S rq   )rx   rs   prjs2x)ra   r   r   rb   rc   s        rI   r   zSky2PixProjection.evaluate   s,    yU+++rK   c                 >      fd j         D             }  j        | S )Nc                 :    g | ]}t          |          j        S rE   r   r   s     rI   rJ   z-Sky2PixProjection.inverse.<locals>.<listcomp>  r   rK   r   r   s   ` rI   rv   zSky2PixProjection.inverse  r   rK   r   rm   s   @rI   rN   rN      s        11HI'+$$ $ $ $ $
" " " " " > > X> @ @ X@, , , " " X" " " " "rK   rN   c                       e Zd ZdZdS )rO   a  Base class for all Zenithal projections.

    Zenithal (or azimuthal) projections map the sphere directly onto a
    plane.  All zenithal projections are specified by defining the
    radius as a function of native latitude, :math:`R_\theta`.

    The pixel-to-sky transformation is defined as:

    .. math::
        \phi &= \arg(-y, x) \\
        R_\theta &= \sqrt{x^2 + y^2}

    and the inverse (sky-to-pixel) is defined as:

    .. math::
        x &= R_\theta \sin \phi \\
        y &= R_\theta \cos \phi
    Nrh   ri   rj   rk   rE   rK   rI   rO   rO     s           rK   rO   c                   ^    e Zd ZdZ edd          Z edeed          Zd Z	e	e_
        dS )	Pix2Sky_ZenithalPerspectiveu  
    Zenithal perspective projection - pixel to sky.

    Corresponds to the ``AZP`` projection in FITS WCS.

    .. math::
        \phi &= \arg(-y \cos \gamma, x) \\
        \theta &= \left\{\genfrac{}{}{0pt}{}{\psi - \omega}{\psi + \omega + 180^{\circ}}\right.

    where:

    .. math::
        \psi &= \arg(\rho, 1) \\
        \omega &= \sin^{-1}\left(\frac{\rho \mu}{\sqrt{\rho^2 + 1}}\right) \\
        \rho &= \frac{R}{\frac{180^{\circ}}{\pi}(\mu + 1) + y \sin \gamma} \\
        R &= \sqrt{x^2 + y^2 \cos^2 \gamma}

    Parameters
    ----------
    mu : float
        Distance from point of projection to center of sphere
        in spherical radii, μ.  Default is 0.

    gamma : float
        Look angle γ in degrees.  Default is 0°.

            5Distance from point of projection to center of spheredefaultdescriptionu(   Look angle γ in degrees (Default = 0°)r   gettersetterr   c                 r    t          j        t          j        |d                    rt          d          d S Ng      z:Zenithal perspective projection is not defined for mu = -1r   anyequalr	   ra   rg   s     rI   _mu_validatorz)Pix2Sky_ZenithalPerspective._mu_validatorD  ?    6"(5$''(( 	%L  	 	rK   Nrh   ri   rj   rk   rZ   mur   r   gammar   
_validatorrE   rK   rI   r   r     sr         8 
!X
 
 
B L>	  E   "BMMMrK   r   c                   ^    e Zd ZdZ edd          Z edeed          Zd Z	e	e_
        dS )	Sky2Pix_ZenithalPerspectiveuF  
    Zenithal perspective projection - sky to pixel.

    Corresponds to the ``AZP`` projection in FITS WCS.

    .. math::
        x &= R \sin \phi \\
        y &= -R \sec \gamma \cos \theta

    where:

    .. math::
        R = \frac{180^{\circ}}{\pi} \frac{(\mu + 1) \cos \theta}
            {(\mu + \sin \theta) + \cos \theta \cos \phi \tan \gamma}

    Parameters
    ----------
    mu : float
        Distance from point of projection to center of sphere
        in spherical radii, μ. Default is 0.

    gamma : float
        Look angle γ in degrees. Default is 0°.

    r   r   r   u&   Look angle γ in degrees (Default=0°)r   c                 r    t          j        t          j        |d                    rt          d          d S r   r   r   s     rI   r   z)Sky2Pix_ZenithalPerspective._mu_validatorr  r   rK   Nr   rE   rK   rI   r   r   M  sr         4 
!X
 
 
B L<	  E   "BMMMrK   r   c                   |    e Zd ZdZ edd          Z edeed          Z edeed          Z	d	 Z
e
e_        d
S ) Pix2Sky_SlantZenithalPerspectiveu  
    Slant zenithal perspective projection - pixel to sky.

    Corresponds to the ``SZP`` projection in FITS WCS.

    Parameters
    ----------
    mu : float
        Distance from point of projection to center of sphere
        in spherical radii, μ.  Default is 0.

    phi0 : float
        The longitude φ₀ of the reference point, in degrees.  Default
        is 0°.

    theta0 : float
        The latitude θ₀ of the reference point, in degrees.  Default
        is 90°.

    r   r   r   uC   The longitude φ₀ of the reference point in degrees (Default=0°)r        V@uC   The latitude θ₀ of the reference point, in degrees (Default=0°)c                 r    t          j        t          j        |d                    rt          d          d S r   r   r   s     rI   r   z.Pix2Sky_SlantZenithalPerspective._mu_validator  r   rK   Nrh   ri   rj   rk   rZ   r   r   r   phi0theta0r   r   rE   rK   rI   r   r   {  s         * 
!X
 
 
B <Y	  D \Y	  F   "BMMMrK   r   c                   |    e Zd ZdZ edd          Z edeed          Z edeed          Z	d Z
e
e_        d	S )
 Sky2Pix_SlantZenithalPerspectiveu  
    Zenithal perspective projection - sky to pixel.

    Corresponds to the ``SZP`` projection in FITS WCS.

    Parameters
    ----------
    mu : float
        distance from point of projection to center of sphere
        in spherical radii, μ.  Default is 0.

    phi0 : float
        The longitude φ₀ of the reference point, in degrees.  Default
        is 0°.

    theta0 : float
        The latitude θ₀ of the reference point, in degrees.  Default
        is 90°.

    r   r   r   u5   The longitude φ₀ of the reference point in degreesr   u5   The latitude θ₀ of the reference point, in degreesc                 r    t          j        t          j        |d                    rt          d          d S r   r   r   s     rI   r   z.Sky2Pix_SlantZenithalPerspective._mu_validator  r   rK   Nr   rE   rK   rI   r   r     s         * 
!X
 
 
B <K	  D \K	  F   "BMMMrK   r   c                       e Zd ZdZdS )Pix2Sky_Gnomonicz
    Gnomonic projection - pixel to sky.

    Corresponds to the ``TAN`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        \theta = \tan^{-1}\left(\frac{180^{\circ}}{\pi R_\theta}\right)
    Nr   rE   rK   rI   r   r             	 	 	 	rK   r   c                       e Zd ZdZdS )Sky2Pix_Gnomonicz
    Gnomonic Projection - sky to pixel.

    Corresponds to the ``TAN`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        R_\theta = \frac{180^{\circ}}{\pi}\cot \theta
    Nr   rE   rK   rI   r   r     r   rK   r   c                       e Zd ZdZdS )Pix2Sky_Stereographica  
    Stereographic Projection - pixel to sky.

    Corresponds to the ``STG`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        \theta = 90^{\circ} - 2 \tan^{-1}\left(\frac{\pi R_\theta}{360^{\circ}}\right)
    Nr   rE   rK   rI   r   r     r   rK   r   c                       e Zd ZdZdS )Sky2Pix_Stereographica
  
    Stereographic Projection - sky to pixel.

    Corresponds to the ``STG`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        R_\theta = \frac{180^{\circ}}{\pi}\frac{2 \cos \theta}{1 + \sin \theta}
    Nr   rE   rK   rI   r   r      r   rK   r   c                   F    e Zd ZdZ edd          Z edd          ZdS )Pix2Sky_SlantOrthographicu  
    Slant orthographic projection - pixel to sky.

    Corresponds to the ``SIN`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    The following transformation applies when :math:`\xi` and
    :math:`\eta` are both zero.

    .. math::
        \theta = \cos^{-1}\left(\frac{\pi}{180^{\circ}}R_\theta\right)

    The parameters :math:`\xi` and :math:`\eta` are defined from the
    reference point :math:`(\phi_c, \theta_c)` as:

    .. math::
        \xi &= \cot \theta_c \sin \phi_c \\
        \eta &= - \cot \theta_c \cos \phi_c

    Parameters
    ----------
    xi : float
        Obliqueness parameter, ξ.  Default is 0.0.

    eta : float
        Obliqueness parameter, η.  Default is 0.0.

    r   zObliqueness parameterr   Nrh   ri   rj   rk   rZ   xietarE   rK   rI   r  r    sD         < 
c/F	G	G	GB
,s0G
H
H
HCCCrK   r  c                   B    e Zd ZdZ ed          Z ed          ZdS )Sky2Pix_SlantOrthographica*  
    Slant orthographic projection - sky to pixel.

    Corresponds to the ``SIN`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    The following transformation applies when :math:`\xi` and
    :math:`\eta` are both zero.

    .. math::
        R_\theta = \frac{180^{\circ}}{\pi}\cos \theta

    But more specifically are:

    .. math::
        x &= \frac{180^\circ}{\pi}[\cos \theta \sin \phi + \xi(1 - \sin \theta)] \\
        y &= \frac{180^\circ}{\pi}[\cos \theta \cos \phi + \eta(1 - \sin \theta)]

    r   r   Nr  rE   rK   rI   r  r  0  s>         * 
c	"	"	"B
,s
#
#
#CCCrK   r  c                       e Zd ZdZdS )Pix2Sky_ZenithalEquidistantz
    Zenithal equidistant projection - pixel to sky.

    Corresponds to the ``ARC`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        \theta = 90^\circ - R_\theta
    Nr   rE   rK   rI   r	  r	  J  r   rK   r	  c                       e Zd ZdZdS )Sky2Pix_ZenithalEquidistantz
    Zenithal equidistant projection - sky to pixel.

    Corresponds to the ``ARC`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        R_\theta = 90^\circ - \theta
    Nr   rE   rK   rI   r  r  W  r   rK   r  c                       e Zd ZdZdS )Pix2Sky_ZenithalEqualAreaa  
    Zenithal equidistant projection - pixel to sky.

    Corresponds to the ``ZEA`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        \theta = 90^\circ - 2 \sin^{-1} \left(\frac{\pi R_\theta}{360^\circ}\right)
    Nr   rE   rK   rI   r  r  d  r   rK   r  c                       e Zd ZdZdS )Sky2Pix_ZenithalEqualAreaa^  
    Zenithal equidistant projection - sky to pixel.

    Corresponds to the ``ZEA`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        R_\theta &= \frac{180^\circ}{\pi} \sqrt{2(1 - \sin\theta)} \\
                 &= \frac{360^\circ}{\pi} \sin\left(\frac{90^\circ - \theta}{2}\right)
    Nr   rE   rK   rI   r  r  q  s        
 
 
 
rK   r  c                   *    e Zd ZdZ ed          ZdS )Pix2Sky_AiryuA  
    Airy projection - pixel to sky.

    Corresponds to the ``AIR`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    Parameters
    ----------
    theta_b : float
        The latitude :math:`\theta_b` at which to minimize the error,
        in degrees.  Default is 90°.
    r   r  Nrh   ri   rj   rk   rZ   theta_brE   rK   rI   r  r    s,          l4(((GGGrK   r  c                   ,    e Zd ZdZ edd          ZdS )Sky2Pix_AiryuR  
    Airy - sky to pixel.

    Corresponds to the ``AIR`` projection in FITS WCS.

    See `Zenithal` for a definition of the full transformation.

    .. math::
        R_\theta = -2 \frac{180^\circ}{\pi}\left(\frac{\ln(\cos \xi)}{\tan \xi} +
            \frac{\ln(\cos \xi_b)}{\tan^2 \xi_b} \tan \xi \right)

    where:

    .. math::
        \xi &= \frac{90^\circ - \theta}{2} \\
        \xi_b &= \frac{90^\circ - \theta_b}{2}

    Parameters
    ----------
    theta_b : float
        The latitude :math:`\theta_b` at which to minimize the error,
        in degrees.  Default is 90°.

    r   z6The latitude at which to minimize the error,in degreesr   Nr  rE   rK   rI   r  r    s6         2 lL  GGGrK   r  c                       e Zd ZdZdZdS )rP   zBase class for Cylindrical projections.

    Cylindrical projections are so-named because the surface of
    projection is a cylinder.
    TNrh   ri   rj   rk   r   rE   rK   rI   rP   rP     s          JJJrK   rP   c                   j    e Zd ZdZ ed          Z ed          Zd Zee_        d Z	e	e_        dS )Pix2Sky_CylindricalPerspectiveu[  
    Cylindrical perspective - pixel to sky.

    Corresponds to the ``CYP`` projection in FITS WCS.

    .. math::
        \phi &= \frac{x}{\lambda} \\
        \theta &= \arg(1, \eta) + \sin{-1}\left(\frac{\eta \mu}{\sqrt{\eta^2 + 1}}\right)

    where:

    .. math::
        \eta = \frac{\pi}{180^{\circ}}\frac{y}{\mu + \lambda}

    Parameters
    ----------
    mu : float
        Distance from center of sphere in the direction opposite the
        projected surface, in spherical radii, μ. Default is 1.

    lam : float
        Radius of the cylinder in spherical radii, λ. Default is 1.

          ?r  c                 `    t          j        || j         k              rt          d          d S Nz.CYP projection is not defined for mu = -lambdar   r   lamr	   r   s     rI   r   z,Pix2Sky_CylindricalPerspective._mu_validator  9    6%DH9$%% 	X%&VWWW	X 	XrK   c                 `    t          j        || j         k              rt          d          d S Nz.CYP projection is not defined for lambda = -mur   r   r   r	   r   s     rI   _lam_validatorz-Pix2Sky_CylindricalPerspective._lam_validator  9    6%DG8#$$ 	X%&VWWW	X 	XrK   N
rh   ri   rj   rk   rZ   r   r  r   r   r#  rE   rK   rI   r  r    st         2 
c	"	"	"B
,s
#
#
#CX X X "BMX X X $CNNNrK   r  c                   n    e Zd ZdZ edd          Z edd          Zd Zee_        d Z	e	e_        dS )	Sky2Pix_CylindricalPerspectiveu  
    Cylindrical Perspective - sky to pixel.

    Corresponds to the ``CYP`` projection in FITS WCS.

    .. math::
        x &= \lambda \phi \\
        y &= \frac{180^{\circ}}{\pi}\left(\frac{\mu + \lambda}{\mu + \cos \theta}\right)\sin \theta

    Parameters
    ----------
    mu : float
        Distance from center of sphere in the direction opposite the
        projected surface, in spherical radii, μ.  Default is 0.

    lam : float
        Radius of the cylinder in spherical radii, λ.  Default is 0.

    r  z1Distance from center of sphere in spherical radiir   z)Radius of the cylinder in spherical radiic                 `    t          j        || j         k              rt          d          d S r  r  r   s     rI   r   z,Sky2Pix_CylindricalPerspective._mu_validator  r  rK   c                 `    t          j        || j         k              rt          d          d S r!  r"  r   s     rI   r#  z-Sky2Pix_CylindricalPerspective._lam_validator  r$  rK   Nr%  rE   rK   rI   r'  r'    s         ( 
!T
 
 
B ,!L  CX X X "BMX X X $CNNNrK   r'  c                   *    e Zd ZdZ ed          ZdS )Pix2Sky_CylindricalEqualAreauU  
    Cylindrical equal area projection - pixel to sky.

    Corresponds to the ``CEA`` projection in FITS WCS.

    .. math::
        \phi &= x \\
        \theta &= \sin^{-1}\left(\frac{\pi}{180^{\circ}}\lambda y\right)

    Parameters
    ----------
    lam : float
        Radius of the cylinder in spherical radii, λ.  Default is 1.
    r   r  Nrh   ri   rj   rk   rZ   r  rE   rK   rI   r+  r+    ,          ,q
!
!
!CCCrK   r+  c                   *    e Zd ZdZ ed          ZdS )Sky2Pix_CylindricalEqualAreauL  
    Cylindrical equal area projection - sky to pixel.

    Corresponds to the ``CEA`` projection in FITS WCS.

    .. math::
        x &= \phi \\
        y &= \frac{180^{\circ}}{\pi}\frac{\sin \theta}{\lambda}

    Parameters
    ----------
    lam : float
        Radius of the cylinder in spherical radii, λ.  Default is 0.
    r   r  Nr,  rE   rK   rI   r/  r/  !  r-  rK   r/  c                   (    e Zd ZdZed             ZdS )Pix2Sky_PlateCarreeu   
    Plate carrée projection - pixel to sky.

    Corresponds to the ``CAR`` projection in FITS WCS.

    .. math::
        \phi &= x \\
        \theta &= y
    c                 Z    t          j        |           }t          j        |          }||fS rq   r   array)r   r   r   r   s       rI   r   zPix2Sky_PlateCarree.evaluate?  s(     hqkkEzrK   Nrh   ri   rj   rk   staticmethodr   rE   rK   rI   r1  r1  4  s9            \  rK   r1  c                   (    e Zd ZdZed             ZdS )Sky2Pix_PlateCarreeu   
    Plate carrée projection - sky to pixel.

    Corresponds to the ``CAR`` projection in FITS WCS.

    .. math::
        x &= \phi \\
        y &= \theta
    c                 Z    t          j        |           }t          j        |          }||fS rq   r3  )r   r   r   r   s       rI   r   zSky2Pix_PlateCarree.evaluateR  s'     HSMMHUOO!trK   Nr5  rE   rK   rI   r8  r8  G  s9            \  rK   r8  c                       e Zd ZdZdS )Pix2Sky_Mercatorz
    Mercator - pixel to sky.

    Corresponds to the ``MER`` projection in FITS WCS.

    .. math::
        \phi &= x \\
        \theta &= 2 \tan^{-1}\left(e^{y \pi / 180^{\circ}}\right)-90^{\circ}
    Nr   rE   rK   rI   r;  r;  Z             rK   r;  c                       e Zd ZdZdS )Sky2Pix_Mercatorz
    Mercator - sky to pixel.

    Corresponds to the ``MER`` projection in FITS WCS.

    .. math::
        x &= \phi \\
        y &= \frac{180^{\circ}}{\pi}\ln \tan \left(\frac{90^{\circ} + \theta}{2}\right)
    Nr   rE   rK   rI   r>  r>  f  r<  rK   r>  c                       e Zd ZdZdZdS )rQ   a7  Base class for pseudocylindrical projections.

    Pseudocylindrical projections are like cylindrical projections
    except the parallels of latitude are projected at diminishing
    lengths toward the polar regions in order to reduce lateral
    distortion there.  Consequently, the meridians are curved.
    TNr  rE   rK   rI   rQ   rQ   r  s          JJJrK   rQ   c                       e Zd ZdZdS )Pix2Sky_SansonFlamsteedz
    Sanson-Flamsteed projection - pixel to sky.

    Corresponds to the ``SFL`` projection in FITS WCS.

    .. math::
        \phi &= \frac{x}{\cos y} \\
        \theta &= y
    Nr   rE   rK   rI   rA  rA  ~  r<  rK   rA  c                       e Zd ZdZdS )Sky2Pix_SansonFlamsteedz
    Sanson-Flamsteed projection - sky to pixel.

    Corresponds to the ``SFL`` projection in FITS WCS.

    .. math::
        x &= \phi \cos \theta \\
        y &= \theta
    Nr   rE   rK   rI   rC  rC    r<  rK   rC  c                       e Zd ZdZdS )Pix2Sky_Parabolicz
    Parabolic projection - pixel to sky.

    Corresponds to the ``PAR`` projection in FITS WCS.

    .. math::
        \phi &= \frac{180^\circ}{\pi} \frac{x}{1 - 4(y / 180^\circ)^2} \\
        \theta &= 3 \sin^{-1}\left(\frac{y}{180^\circ}\right)
    Nr   rE   rK   rI   rE  rE    r<  rK   rE  c                       e Zd ZdZdS )Sky2Pix_Parabolicz
    Parabolic projection - sky to pixel.

    Corresponds to the ``PAR`` projection in FITS WCS.

    .. math::
        x &= \phi \left(2\cos\frac{2\theta}{3} - 1\right) \\
        y &= 180^\circ \sin \frac{\theta}{3}
    Nr   rE   rK   rI   rG  rG    r<  rK   rG  c                       e Zd ZdZdS )Pix2Sky_Molleweidea  
    Molleweide's projection - pixel to sky.

    Corresponds to the ``MOL`` projection in FITS WCS.

    .. math::
        \phi &= \frac{\pi x}{2 \sqrt{2 - \left(\frac{\pi}{180^\circ}y\right)^2}} \\
        \theta &= \sin^{-1}\left(
                \frac{1}{90^\circ}\sin^{-1}\left(\frac{\pi}{180^\circ}\frac{y}{\sqrt{2}}\right)
                + \frac{y}{180^\circ}\sqrt{2 - \left(\frac{\pi}{180^\circ}y\right)^2}
            \right)
    Nr   rE   rK   rI   rI  rI    s           rK   rI  c                       e Zd ZdZdS )Sky2Pix_Molleweidea  
    Molleweide's projection - sky to pixel.

    Corresponds to the ``MOL`` projection in FITS WCS.

    .. math::
        x &= \frac{2 \sqrt{2}}{\pi} \phi \cos \gamma \\
        y &= \sqrt{2} \frac{180^\circ}{\pi} \sin \gamma

    where :math:`\gamma` is defined as the solution of the
    transcendental equation:

    .. math::

        \sin \theta = \frac{\gamma}{90^\circ} + \frac{\sin 2 \gamma}{\pi}
    Nr   rE   rK   rI   rK  rK    s           rK   rK  c                       e Zd ZdZdS )Pix2Sky_HammerAitoffa  
    Hammer-Aitoff projection - pixel to sky.

    Corresponds to the ``AIT`` projection in FITS WCS.

    .. math::
        \phi &= 2 \arg \left(2Z^2 - 1, \frac{\pi}{180^\circ} \frac{Z}{2}x\right) \\
        \theta &= \sin^{-1}\left(\frac{\pi}{180^\circ}yZ\right)
    Nr   rE   rK   rI   rM  rM    r<  rK   rM  c                       e Zd ZdZdS )Sky2Pix_HammerAitoffaD  
    Hammer-Aitoff projection - sky to pixel.

    Corresponds to the ``AIT`` projection in FITS WCS.

    .. math::
        x &= 2 \gamma \cos \theta \sin \frac{\phi}{2} \\
        y &= \gamma \sin \theta

    where:

    .. math::
        \gamma = \frac{180^\circ}{\pi} \sqrt{\frac{2}{1 + \cos \theta \cos(\phi / 2)}}
    Nr   rE   rK   rI   rO  rO               rK   rO  c                   J    e Zd ZdZ edee          Z edee          ZdS )rR   a  Base class for conic projections.

    In conic projections, the sphere is thought to be projected onto
    the surface of a cone which is then opened out.

    In a general sense, the pixel-to-sky transformation is defined as:

    .. math::

        \phi &= \arg\left(\frac{Y_0 - y}{R_\theta}, \frac{x}{R_\theta}\right) / C \\
        R_\theta &= \mathrm{sign} \theta_a \sqrt{x^2 + (Y_0 - y)^2}

    and the inverse (sky-to-pixel) is defined as:

    .. math::
        x &= R_\theta \sin (C \phi) \\
        y &= R_\theta \cos (C \phi) + Y_0

    where :math:`C` is the "constant of the cone":

    .. math::
        C = \frac{180^\circ \cos \theta}{\pi R_\theta}
    r   r   r   r   r   N)	rh   ri   rj   rk   rZ   r   r   sigmadeltarE   rK   rI   rR   rR     sF         0 LmJOOOEL]:NNNEEErK   rR   c                       e Zd ZdZdS )Pix2Sky_ConicPerspectiveaB  
    Colles' conic perspective projection - pixel to sky.

    Corresponds to the ``COP`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::
        C &= \sin \theta_a \\
        R_\theta &= \frac{180^\circ}{\pi} \cos \eta [ \cot \theta_a - \tan(\theta - \theta_a)] \\
        Y_0 &= \frac{180^\circ}{\pi} \cos \eta \cot \theta_a

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   rV  rV  
             rK   rV  c                       e Zd ZdZdS )Sky2Pix_ConicPerspectiveaB  
    Colles' conic perspective projection - sky to pixel.

    Corresponds to the ``COP`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::
        C &= \sin \theta_a \\
        R_\theta &= \frac{180^\circ}{\pi} \cos \eta [ \cot \theta_a - \tan(\theta - \theta_a)] \\
        Y_0 &= \frac{180^\circ}{\pi} \cos \eta \cot \theta_a

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   rY  rY  '  rW  rK   rY  c                       e Zd ZdZdS )Pix2Sky_ConicEqualAreaa  
    Alber's conic equal area projection - pixel to sky.

    Corresponds to the ``COE`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::
        C &= \gamma / 2 \\
        R_\theta &= \frac{180^\circ}{\pi} \frac{2}{\gamma}
            \sqrt{1 + \sin \theta_1 \sin \theta_2 - \gamma \sin \theta} \\
        Y_0 &= \frac{180^\circ}{\pi} \frac{2}{\gamma}
            \sqrt{1 + \sin \theta_1 \sin \theta_2 - \gamma \sin((\theta_1 + \theta_2)/2)}

    where:

    .. math::
        \gamma = \sin \theta_1 + \sin \theta_2

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   r[  r[  D                 rK   r[  c                       e Zd ZdZdS )Sky2Pix_ConicEqualAreaa  
    Alber's conic equal area projection - sky to pixel.

    Corresponds to the ``COE`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::
        C &= \gamma / 2 \\
        R_\theta &= \frac{180^\circ}{\pi} \frac{2}{\gamma}
            \sqrt{1 + \sin \theta_1 \sin \theta_2 - \gamma \sin \theta} \\
        Y_0 &= \frac{180^\circ}{\pi} \frac{2}{\gamma}
            \sqrt{1 + \sin \theta_1 \sin \theta_2 - \gamma \sin((\theta_1 + \theta_2)/2)}

    where:

    .. math::
        \gamma = \sin \theta_1 + \sin \theta_2

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   r^  r^  h  r\  rK   r^  c                       e Zd ZdZdS )Pix2Sky_ConicEquidistanta1  
    Conic equidistant projection - pixel to sky.

    Corresponds to the ``COD`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::

        C &= \frac{180^\circ}{\pi} \frac{\sin\theta_a\sin\eta}{\eta} \\
        R_\theta &= \theta_a - \theta + \eta\cot\eta\cot\theta_a \\
        Y_0 = \eta\cot\eta\cot\theta_a

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   r`  r`               rK   r`  c                       e Zd ZdZdS )Sky2Pix_ConicEquidistanta1  
    Conic equidistant projection - sky to pixel.

    Corresponds to the ``COD`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::

        C &= \frac{180^\circ}{\pi} \frac{\sin\theta_a\sin\eta}{\eta} \\
        R_\theta &= \theta_a - \theta + \eta\cot\eta\cot\theta_a \\
        Y_0 = \eta\cot\eta\cot\theta_a

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   rc  rc    ra  rK   rc  c                       e Zd ZdZdS )Pix2Sky_ConicOrthomorphica  
    Conic orthomorphic projection - pixel to sky.

    Corresponds to the ``COO`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::

        C &= \frac{\ln \left( \frac{\cos\theta_2}{\cos\theta_1} \right)}
                  {\ln \left[ \frac{\tan\left(\frac{90^\circ-\theta_2}{2}\right)}
                                   {\tan\left(\frac{90^\circ-\theta_1}{2}\right)} \right] } \\
        R_\theta &= \psi \left[ \tan \left( \frac{90^\circ - \theta}{2} \right) \right]^C \\
        Y_0 &= \psi \left[ \tan \left( \frac{90^\circ - \theta_a}{2} \right) \right]^C

    where:

    .. math::

        \psi = \frac{180^\circ}{\pi} \frac{\cos \theta}
               {C\left[\tan\left(\frac{90^\circ-\theta}{2}\right)\right]^C}

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   re  re            # # # #rK   re  c                       e Zd ZdZdS )Sky2Pix_ConicOrthomorphica  
    Conic orthomorphic projection - sky to pixel.

    Corresponds to the ``COO`` projection in FITS WCS.

    See `Conic` for a description of the entire equation.

    The projection formulae are:

    .. math::

        C &= \frac{\ln \left( \frac{\cos\theta_2}{\cos\theta_1} \right)}
                  {\ln \left[ \frac{\tan\left(\frac{90^\circ-\theta_2}{2}\right)}
                                   {\tan\left(\frac{90^\circ-\theta_1}{2}\right)} \right] } \\
        R_\theta &= \psi \left[ \tan \left( \frac{90^\circ - \theta}{2} \right) \right]^C \\
        Y_0 &= \psi \left[ \tan \left( \frac{90^\circ - \theta_a}{2} \right) \right]^C

    where:

    .. math::

        \psi = \frac{180^\circ}{\pi} \frac{\cos \theta}
               {C\left[\tan\left(\frac{90^\circ-\theta}{2}\right)\right]^C}

    Parameters
    ----------
    sigma : float
        :math:`(\theta_1 + \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 90.

    delta : float
        :math:`(\theta_1 - \theta_2) / 2`, where :math:`\theta_1` and
        :math:`\theta_2` are the latitudes of the standard parallels,
        in degrees.  Default is 0.
    Nr   rE   rK   rI   rh  rh    rf  rK   rh  c                       e Zd ZdZdS )rS   zrBase class for pseudoconic projections.

    Pseudoconics are a subclass of conics with concentric parallels.
    Nr   rE   rK   rI   rS   rS     s           rK   rS   c                   2    e Zd ZdZdZ edee          ZdS )Pix2Sky_BonneEqualAreaa  
    Bonne's equal area pseudoconic projection - pixel to sky.

    Corresponds to the ``BON`` projection in FITS WCS.

    .. math::

        \phi &= \frac{\pi}{180^\circ} A_\phi R_\theta / \cos \theta \\
        \theta &= Y_0 - R_\theta

    where:

    .. math::

        R_\theta &= \mathrm{sign} \theta_1 \sqrt{x^2 + (Y_0 - y)^2} \\
        A_\phi &= \arg\left(\frac{Y_0 - y}{R_\theta}, \frac{x}{R_\theta}\right)

    Parameters
    ----------
    theta1 : float
        Bonne conformal latitude, in degrees.
    Tr   rR  N	rh   ri   rj   rk   r   rZ   r   r   theta1rE   rK   rI   rk  rk    s5         . J\#mJOOOFFFrK   rk  c                   4    e Zd ZdZdZ edeed          ZdS )Sky2Pix_BonneEqualAreaa  
    Bonne's equal area pseudoconic projection - sky to pixel.

    Corresponds to the ``BON`` projection in FITS WCS.

    .. math::
        x &= R_\theta \sin A_\phi \\
        y &= -R_\theta \cos A_\phi + Y_0

    where:

    .. math::
        A_\phi &= \frac{180^\circ}{\pi R_\theta} \phi \cos \theta \\
        R_\theta &= Y_0 - \theta \\
        Y_0 &= \frac{180^\circ}{\pi} \cot \theta_1 + \theta_1

    Parameters
    ----------
    theta1 : float
        Bonne conformal latitude, in degrees.
    Tr   z$Bonne conformal latitude, in degreesr   Nrl  rE   rK   rI   ro  ro  :  sA         , J\:	  FFFrK   ro  c                       e Zd ZdZdS )Pix2Sky_Polyconiczf
    Polyconic projection - pixel to sky.

    Corresponds to the ``PCO`` projection in FITS WCS.
    Nr   rE   rK   rI   rq  rq  [             rK   rq  c                       e Zd ZdZdS )Sky2Pix_Polyconiczf
    Polyconic projection - sky to pixel.

    Corresponds to the ``PCO`` projection in FITS WCS.
    Nr   rE   rK   rI   rt  rt  c  rr  rK   rt  c                       e Zd ZdZdS )rT   aw  Base class for quad cube projections.

    Quadrilateralized spherical cube (quad-cube) projections belong to
    the class of polyhedral projections in which the sphere is
    projected onto the surface of an enclosing polyhedron.

    The six faces of the quad-cube projections are numbered and laid
    out as::

              0
        4 3 2 1 4 3 2
              5

    Nr   rE   rK   rI   rT   rT   k  rP  rK   rT   c                       e Zd ZdZdS )Pix2Sky_TangentialSphericalCubezv
    Tangential spherical cube projection - pixel to sky.

    Corresponds to the ``TSC`` projection in FITS WCS.
    Nr   rE   rK   rI   rw  rw  |  rr  rK   rw  c                       e Zd ZdZdS )Sky2Pix_TangentialSphericalCubezv
    Tangential spherical cube projection - sky to pixel.

    Corresponds to the ``TSC`` projection in FITS WCS.
    Nr   rE   rK   rI   ry  ry    rr  rK   ry  c                       e Zd ZdZdS )Pix2Sky_COBEQuadSphericalCubez
    COBE quadrilateralized spherical cube projection - pixel to sky.

    Corresponds to the ``CSC`` projection in FITS WCS.
    Nr   rE   rK   rI   r{  r{    rr  rK   r{  c                       e Zd ZdZdS )Sky2Pix_COBEQuadSphericalCubez
    COBE quadrilateralized spherical cube projection - sky to pixel.

    Corresponds to the ``CSC`` projection in FITS WCS.
    Nr   rE   rK   rI   r}  r}    rr  rK   r}  c                       e Zd ZdZdS )Pix2Sky_QuadSphericalCubez}
    Quadrilateralized spherical cube projection - pixel to sky.

    Corresponds to the ``QSC`` projection in FITS WCS.
    Nr   rE   rK   rI   r  r    rr  rK   r  c                       e Zd ZdZdS )Sky2Pix_QuadSphericalCubez}
    Quadrilateralized spherical cube projection - sky to pixel.

    Corresponds to the ``QSC`` projection in FITS WCS.
    Nr   rE   rK   rI   r  r    rr  rK   r  c                       e Zd ZdZdS )r?   z#Base class for HEALPix projections.Nr   rE   rK   rI   r?   r?     s        ....rK   r?   c                   J    e Zd ZdZdZ edd          Z edd          ZdS )	Pix2Sky_HEALPixz
    HEALPix - pixel to sky.

    Corresponds to the ``HPX`` projection in FITS WCS.

    Parameters
    ----------
    H : float
        The number of facets in longitude direction.

    X : float
        The number of facets in latitude direction.

    T      @,The number of facets in longitude direction.r         @+The number of facets in latitude direction.Nrh   ri   rj   rk   r   rZ   HXrE   rK   rI   r  r    Y          J!O	 	 	A 	!N	 	 	AAArK   r  c                   J    e Zd ZdZdZ edd          Z edd          ZdS )	Sky2Pix_HEALPixa
  
    HEALPix projection - sky to pixel.

    Corresponds to the ``HPX`` projection in FITS WCS.

    Parameters
    ----------
    H : float
        The number of facets in longitude direction.

    X : float
        The number of facets in latitude direction.

    Tr  r  r   r  r  Nr  rE   rK   rI   r  r    r  rK   r  c                       e Zd ZdZdS )Pix2Sky_HEALPixPolar{
    HEALPix polar, aka "butterfly" projection - pixel to sky.

    Corresponds to the ``XPH`` projection in FITS WCS.
    Nr   rE   rK   rI   r  r    rr  rK   r  c                       e Zd ZdZdS )Sky2Pix_HEALPixPolarr  Nr   rE   rK   rI   r  r    rr  rK   r  c                        e Zd ZdZdZdZdZdZ eddgddgg          Z	 eddg          Z
d Zee	_        d Zee
_        e	e
f fd		Zed
             Zed             Zed             Zed             Z xZS )rU   aQ  
    Perform an affine transformation in 2 dimensions.

    Parameters
    ----------
    matrix : array
        A 2x2 matrix specifying the linear transformation to apply to the
        inputs

    translation : array
        A 2D vector (given as either a 2x1 or 1x2 array) specifying a
        translation to apply to the inputs

    r   Fr  r   r  c                 T    t          j        |          dk    rt          d          dS )z2Validates that the input matrix is a 2x2 2D array.)r   r   z0Expected transformation matrix to be a 2x2 arrayN)r   shaper	   r   s     rI   _matrix_validatorz(AffineTransformation2D._matrix_validator  s2    8E??f$$%B   %$rK   c                     t          j        |          dk    rt          j        |          dk    s?t          j        |          dk    rt          j        |          dk    st          d          dS dS )z
        Validates that the translation vector is a 2D vector.  This allows
        either a "row" vector or a "column" vector where in the latter case the
        resultant Numpy array has ``ndim=2`` but the shape is ``(1, 2)``.
        r   )r   r   )r   r   zHExpected translation vector to be a 2 element row or column vector arrayN)r   ndimr  r	   r   s     rI   _translation_validatorz-AffineTransformation2D._translation_validator  ss     WU^^q  RXe__%<%<!##6(A(A%   &=%<(A(ArK   c                 \     t                      j        d||d| d| _        d| _        d S )Nmatrixtranslationr   rE   )r]   r^   r   r   )ra   r  r  rc   rd   s       rI   r^   zAffineTransformation2D.__init__(  s9    JKJJ6JJJ !rK   c                    t           j                            | j        j                  }|dk    rt          d| j        j         d          t           j                            | j        j                  }| j        j	        || j        j	        z  }t          j
        || j        j                   }|                     ||          S )z
        Inverse transformation.

        Raises `~astropy.modeling.InputParameterError` if the transformation cannot be inverted.
        r   z#Transformation matrix is singular; z model does not have an inverseNr  )r   linalgdetr  rg   r	   rd   rh   invunitdotr  )ra   r  r  r  s       rI   rv   zAffineTransformation2D.inverse-  s     immDK-..!88%,dn6M , , ,  
 t{011;'dk..Fvfd&6&<===~~V~EEErK   c                 :   |j         |j         k    rt          d          |j         pd}t          j        t          j        |                                          t          j        |                                          t          j        |j        |j                  g          }|j         d         dk    s|j	        dk    rt          d          | 
                    ||          }t          j        ||          }|d         |d         }}|x|_         |_         ||fS )a,  
        Apply the transformation to a set of 2D Cartesian coordinates given as
        two lists--one for the x coordinates and one for a y coordinates--or a
        single coordinate pair.

        Parameters
        ----------
        x, y : array, float
              x and y coordinates
        z,Expected input arrays to have the same shape)r   r      r   zIncompatible input shapesr   )r  
ValueErrorr   vstackasarrayravelonessizedtyper  _create_augmented_matrixr  )	r   r   r   r  r  r  inarraugmented_matrixresults	            rI   r   zAffineTransformation2D.evaluateC  s     7agKLLL4	Z]]  ""BJqMM$7$7$9$9271617;S;ST
 
 ;q>Q%*//899977LL(%00ay&)1!!!'!trK   c                    d }t          t          |d          t          | d          g          rot          t          |d          t          | d          g          st          d          |j        }| j        |j        z  t
          j        k    st          d          t          j        dt                    }| |ddddf<   ||dddd f         _
        g d|d<   |||z  S |S )	Nr  zXTo use AffineTransformation with quantities, both matrix and unit need to be quantities.z0matrix and translation must have the same units.)r  r  )r  r   r   )r   r   r   )r   hasattrallr  r  r   dimensionless_unscaledr   emptyr~   flat)r  r  r  r  s       rI   r  z/AffineTransformation2D._create_augmented_matrixb  s   V,,gff.E.EFGG 		UV44gff6M6MNOO  B   #DK+"22q7OOO !STTT8F%888%+1ac")41abb!&'ii#d**rK   c                     | j         j        }| j        j        }||d S |&t          t	          | j        |gdz                      S t          t	          | j        |gdz                      S )Nr   )r  
input_unitr  dictzipr   )ra   translation_unitmatrix_units      rI   r   z"AffineTransformation2D.input_unitsx  sr    +6k,#(;4)DK*:);a)?@@AAADK+):;;<<<rK   )rh   ri   rj   rk   r   r   standard_broadcastingr   r
   r  r  r  r   r  r^   r   rv   classmethodr   r6  r  r   rl   rm   s   @rI   rU   rU     s9         HI!JYc
S#J7888F)S#J///K   *F   4K$+ " " " " " "
 F F XF*   [<     \ * 	= 	= X	= 	= 	= 	= 	=rK   rU   Pix2Sky_Sky2Pix_)brk   r   	itertoolsr   r   numpyr   astropyr   r   r   corer   r   r	   r
   utilsr   r   _PROJ_NAME_CODE_NOT_SUPPORTED_PROJ_CODESr  r   rV   listmapjoin__all__rZ   rL   rM   rN   rO   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  rP   r  r'  r+  r/  r1  r8  r;  r>  rQ   rA  rC  rE  rG  rI  rK  rM  rO  rR   rV  rY  r[  r^  r`  rc  re  rh  rS   rk  ro  rq  rt  rT   rw  ry  r{  r}  r  r  r?   r  r  r  r  rU   r   
short_nameglobalsr   rE   rK   rI   <module>r     s  
 
 


 $ $ $ $ $ $ $ $                       6 6 6 6 6 6 6 6 , , , , , , , ,  < #G d?++ 11111	   	DSXww	95uuo7NOO	P	PQQR     9   *C/ C/ C/ C/ C/ C/ C/ C/L*" *" *" *" *"
 *" *" *"Z*" *" *" *" *"
 *" *" *"Z    z   *-" -" -" -" -""3X -" -" -"`+" +" +" +" +""3X +" +" +"\," ," ," ," ,"'8( ," ," ,"^," ," ," ," ,"'8( ," ," ,"^
 
 
 
 
(( 
 
 

 
 
 
 
(( 
 
 

 
 
 
 
-x 
 
 

 
 
 
 
-x 
 
 
 I  I  I  I  I 18  I  I  IF$ $ $ $ $ 18 $ $ $4
 
 
 
 
"3X 
 
 

 
 
 
 
"3X 
 
 

 
 
 
 
 18 
 
 
     18   ) ) ) ) )$h ) ) )$    $h   @    *   '$ '$ '$ '$ '$%6 '$ '$ '$T&$ &$ &$ &$ &$%6 &$ &$ &$R" " " " "#4k " " "&" " " " "#4k " " "&    +[   &    +[   &	 	 	 	 	(+ 	 	 		 	 	 	 	(+ 	 	 		 	 	 	 	
 	 	 		 	 	 	 	/1B 	 	 		 	 	 	 	/1B 	 	 		 	 	 	 	)+< 	 	 		 	 	 	 	)+< 	 	 	    *,=       *,=   &	 	 	 	 	,.? 	 	 	    ,.?   "O O O O OJ O O O:    0%   :    0%   :! ! ! ! !. ! ! !H! ! ! ! !. ! ! !H    0%   <    0%   <$ $ $ $ $ 15 $ $ $N$ $ $ $ $ 15 $ $ $N    *   P P P P P. P P P:    .   B    );       );       z   "    &7       &7       $5x       $5x        18        18   / / / / /j / / /    '   4    '   4    ,g       ,g   N= N= N= N= N=U N= N= N=b - S SIz)0:	3I)JGGIIj:%&)0:	3I)JGGIIj:%&18:	;Q1RGGIIj9$%.18:	;Q1RGGIIj9$%..S SrK   