B
    z‹dYÉ  ã            !   @   sâ   d Z ddddddddd	d
g
ZddlmZ ddlZddlZddlm	Z
 ddlmZ ejZed Zd+dd„Zd,d d„Zd-d"d„Zd.d$d„Zd/d%d„Zd0d&d„Zd'd„ Zd(d„ Zejjj e_ d)d	„ Zejjj e_ d*d
„ Zejjj e_ dS )1a³  
=====================================================
visufunc.py : Healpix visualization functions
=====================================================

This module provides functions to display Healpix map.

Map projections
---------------

- :func:`mollview` displays a map using Mollweide projection (full sky)
- :func:`gnomview` displays a map using Gnomonic projection (local map)
- :func:`cartview` displays a map using Cartesian projection
- :func:`orthview` displays a map using Orthographic projection (full or half sky)
- :func:`azeqview` displays a map using Azimuthal equidistant projection

Graticules
----------

- :func:`graticule` adds a graticule to the current map
- :func:`delgraticules` deletes all graticules of a map

Tracing lines or points
-----------------------

- :func:`projplot` plots data points on the current map
- :func:`projscatter` displays scatter points
- :func:`projtext` display a text on the current map
ÚmollviewÚgnomviewÚcartviewÚorthviewÚazeqviewÚ	graticuleÚdelgraticulesÚprojplotÚprojscatterÚprojtexté   )Úprojaxesé    N)Ú	pixelfuncg     €f@Ú é   úMollweide viewFÚastroú%gTÚgrayÚwhiteé   c       2      C   sâ  ddl }| dkr$t d¡tj } d}t | ¡}tj||d |sf|sf|sf|j|dd}|s^d}d	} n|r¼| ¡ }t 	| 
¡  ¡ ¡ ¡ \}!}"}#}$|s˜d
}|!|"|#|! |$|" f} | | 
¡ ¡ nÆ|rÊ| ¡ }n¸| ¡ }t|dƒrè|\}%}&}'n |d |d d |d   }%}&}'|'dk s |'|&|% kr2td|%|&|'f ƒ‚|'d |& |'d |&  }(})|sVd}|(d |& d|)d d |%  d|& d|% f} |sÔ| d |d  | d |d  | d |d  |d  | d |d  |d  f} | ¡ }*| ¡  zÔt | ¡} |dk	rt |¡}|r| 
¡ }+n tj|| ||||
d}+| |+¡ |rPtj| ||dd} n|rhtj| ||dd} |+j| |||||	|||||d},|r^|+ ¡ d }-|-j t dd|-jjd ¡¡}.t |-jj|-jj |-jj¡}/t!j"j#t$j%j&|-jj|-jj d|d}0t$j'dkr,|j(|0|+dddt )||¡dd|.|/|d }1n&|j(|0dddt )||¡dd|.|/|d!
}1|1j* +d¡ |+ ,|¡ |sŠ|+j-d"d|+j.j/d#d$|+j0d% |r®|1j1j-dd&|d#|1j1j0d'd'd( | 2|+¡ W d| 3¡  |*rÒ| 4¡  X |rÞ|,S dS ))a.  Plot a healpix map (given as an array) in Mollweide projection.

    Parameters
    ----------
    map : float, array-like or None
      An array containing the map, supports masked maps, see the `ma` function.
      If None, will display a blank map, useful for overplotting.
    fig : int or None, optional
      The figure number to use. Default: create a new figure
    rot : scalar or sequence, optional
      Describe the rotation to apply.
      In the form (lon, lat, psi) (unit: degrees) : the point at
      longitude *lon* and latitude *lat* will be at the center. An additional rotation
      of angle *psi* around this direction is applied.
    coord : sequence of character, optional
      Either one of 'G', 'E' or 'C' to describe the coordinate
      system of the map, or a sequence of 2 of these to rotate
      the map from the first to the second coordinate system.
    unit : str, optional
      A text describing the unit of the data. Default: ''
    xsize : int, optional
      The size of the image. Default: 800
    title : str, optional
      The title of the plot. Default: 'Mollweide view'
    nest : bool, optional
      If True, ordering scheme is NESTED. Default: False (RING)
    min : float, optional
      The minimum range value
    max : float, optional
      The maximum range value
    flip : {'astro', 'geo'}, optional
      Defines the convention of projection : 'astro' (default, east towards left, west towards right)
      or 'geo' (east towards right, west towards left)
    remove_dip : bool, optional
      If :const:`True`, remove the dipole+monopole
    remove_mono : bool, optional
      If :const:`True`, remove the monopole
    gal_cut : float, scalar, optional
      Symmetric galactic cut for the dipole/monopole fit.
      Removes points in latitude range [-gal_cut, +gal_cut]
    format : str, optional
      The format of the scale label. Default: '%g'
    format2 : str, optional
      Format of the pixel value under mouse. Default: '%g'
    cbar : bool, optional
      Display the colorbar. Default: True
    notext : bool, optional
      If True, no text is printed around the map
    norm : {'hist', 'log', None}
      Color normalization, hist= histogram equalized color mapping,
      log= logarithmic color mapping, default: None (linear color mapping)
    cmap : a color map
       The colormap to use (see matplotlib.cm)
    badcolor : str
      Color to use to plot bad values
    bgcolor : str
      Color to use for background
    hold : bool, optional
      If True, replace the current Axes by a MollweideAxes.
      use this if you want to have multiple maps on the same
      figure. Default: False
    sub : int, scalar or sequence, optional
      Use only a zone of the current figure (same syntax as subplot).
      Default: None
    reuse_axes : bool, optional
      If True, reuse the current Axes (should be a MollweideAxes). This is
      useful if you want to overplot with a partially transparent colormap,
      such as for plotting a line integral convolution. Default: False
    margins : None or sequence, optional
      Either None, or a sequence (left,bottom,right,top)
      giving the margins on left,bottom,right and top
      of the axes. Values are relative to figure (0-1).
      Default: None
    return_projected_map : bool
      if True returns the projected map in a 2d numpy array
    alpha : float, array-like or None
      An array containing the alpha channel, supports masked maps, see the `ma` function.
      If None, no transparency will be applied.

    See Also
    --------
    gnomview, cartview, orthview, azeqview
    r   Né   F)Únest)g      !@gš™™™™™@)Úfigsize)g{®Gáz”?gš™™™™™©?g{®Gáz”?gš™™™™™©?)g        g        g      ð?g      ð?)g        g        g        g        Ú__len__éd   é
   r   z Wrong values for sub: %d, %d, %d)g{®Gáz„?g        g        g{®Gáz”?g      ð?r   é   )ÚcoordÚrotÚformatÚflipconvT)Úgal_cutr   Úcopy)
r   Úxsizer   ÚvminÚvmaxÚcmapÚbadcolorÚbgcolorÚnormÚalpha)r%   r&   )r*   r'   z0.91.0Ú
horizontalg      à?é   gš™™™™™©?gš™™™™™¹?)
ÚaxÚorientationÚshrinkÚaspectÚticksÚpadÚfractionÚ
boundariesÚvaluesr    )	r/   r0   r1   r2   r3   r4   r5   r6   r    g…ëQ¸…ë?é   Úbold)ÚfontsizeÚ
fontweightÚ	transformg      ð¿Úcenter)r9   r;   ÚhaÚva)5ÚpylabÚnpÚzerosÚinfr   Ú	get_nsideÚcheck_nsideÚfigureÚgcfÚarrayÚgcaÚget_positionÚravelÚdelaxesÚhasattrÚ
ValueErrorÚisinteractiveÚioffÚma_to_arrayÚPAÚHpxMollweideAxesÚadd_axesÚremove_dipoleÚremove_monopoleÚprojmapÚ
get_imagesr*   ÚinverseÚlinspacer'   ÚNr%   r&   ÚpltÚcmÚScalarMappableÚ
matplotlibÚcolorsÚ	NormalizeÚ__version__ÚcolorbarÚBoundaryLocatorÚsolidsÚset_rasterizedÚ	set_titleÚtextÚprojÚcoordsysstrÚ	transAxesr.   ÚscaÚdrawÚion)2ÚmapÚfigr   r   Úunitr$   Útitler   ÚminÚmaxÚflipÚ
remove_dipÚremove_monor"   r    Úformat2Úcbarr'   r(   r)   Únotextr*   ÚholdÚ
reuse_axesÚmarginsÚsubZnlocsÚreturn_projected_mapr+   r?   ÚnsideÚfÚextentÚleftÚbottomÚrightÚtopÚnrowsÚncolsÚidxÚcÚrÚwasinteractiver.   ÚimgÚimÚbÚvÚmappableÚcb© r’   ú\/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/healpy/visufunc.pyr   J   sö    s


 












éÈ   ç      ø?úGnomonic viewú%.3gc       5      C   sf  ddl }| dkr$t d¡tj } d}t | ¡}tj||	d |sf|sf|sf|j|dd} |s^d}d	}!n|r¼| ¡ } t 	| 
¡  ¡ ¡ ¡ \}"}#}$}%|s˜d
}|"|#|$|" |%|# f}!|  | 
¡ ¡ nÆ|rÊ| ¡ } n¸| ¡ } t|dƒrè|\}&}'}(n |d |d d |d   }&}'}(|(dk s |(|'|& kr2td|&|'|(f ƒ‚|(d |' |(d |'  })}*|sVd}|)d |' d|*d d |&  d|' d|& f}!|sÔ|!d |d  |!d |d  |!d |d  |d  |!d |d  |d  f}!| ¡ }+| ¡  z8t | ¡} |r|  
¡ },n tj| |!||||d},|  |,¡ |
r<tj| ||	dd} n|rTtj| ||	dd} |,j| |	|||||||||||d}-|rF|, ¡ d }.|.j t dd|.jjd ¡¡}/t |.jj|.jj |.jj¡}0t!j"j#t$j%j&|.jj|.jj d|d}1t$j'dkr| j(|1|,dddt )¡ dd|/|0|d }2n"| j(|1dddt )¡ dd|/|0|d!
}2|2j* +d¡ |, ,|¡ |sì|,j-d"d#d$|,j.j/d% |,j.j/d& |,j.j/d' f dd(|,j0d)d* |,j-d"d+|,j.j1d,d-d)|,j0d. t 2|,j.j3dd/|,j4¡\}3}4|,j-dd0d1|3|4f d2d2|,j0d3 |r|2j5j-d4d5|d,d-|2j5j0d6d2d7 |  6|,¡ W d| 7¡  |+r6| 8¡  |rV| 9| ¡ |  :¡  |, ;¡  X |rb|-S dS )8a5  Plot a healpix map (given as an array) in Gnomonic projection.

    Parameters
    ----------
    map : array-like
      The map to project, supports masked maps, see the `ma` function.
      If None, use a blank map, useful for
      overplotting.
    fig : None or int, optional
      A figure number. Default: None= create a new figure
    rot : scalar or sequence, optional
      Describe the rotation to apply.
      In the form (lon, lat, psi) (unit: degrees) : the point at
      longitude *lon* and latitude *lat* will be at the center. An additional rotation
      of angle *psi* around this direction is applied.
    coord : sequence of character, optional
      Either one of 'G', 'E' or 'C' to describe the coordinate
      system of the map, or a sequence of 2 of these to rotate
      the map from the first to the second coordinate system.
    unit : str, optional
      A text describing the unit of the data. Default: ''
    xsize : int, optional
      The size of the image. Default: 200
    ysize : None or int, optional
      The size of the image. Default: None= xsize
    reso : float, optional
      Resolution (in arcmin). Default: 1.5 arcmin
    title : str, optional
      The title of the plot. Default: 'Gnomonic view'
    nest : bool, optional
      If True, ordering scheme is NESTED. Default: False (RING)
    min : float, scalar, optional
      The minimum range value
    max : float, scalar, optional
      The maximum range value
    flip : {'astro', 'geo'}, optional
      Defines the convention of projection : 'astro' (default, east towards left, west towards right)
      or 'geo' (east towards roght, west towards left)
    remove_dip : bool, optional
      If :const:`True`, remove the dipole+monopole
    remove_mono : bool, optional
      If :const:`True`, remove the monopole
    gal_cut : float, scalar, optional
      Symmetric galactic cut for the dipole/monopole fit.
      Removes points in latitude range [-gal_cut, +gal_cut]
    format : str, optional
      The format of the scale label. Default: '%g'
    cmap : a color map
       The colormap to use (see matplotlib.cm)
    badcolor : str
      Color to use to plot bad values
    bgcolor : str
      Color to use for background
    hold : bool, optional
      If True, replace the current Axes by a GnomonicAxes.
      use this if you want to have multiple maps on the same
      figure. Default: False
    sub : int or sequence, optional
      Use only a zone of the current figure (same syntax as subplot).
      Default: None
    reuse_axes : bool, optional
      If True, reuse the current Axes (should be a GnomonicAxes). This is
      useful if you want to overplot with a partially transparent colormap,
      such as for plotting a line integral convolution. Default: False
    margins : None or sequence, optional
      Either None, or a sequence (left,bottom,right,top)
      giving the margins on left,bottom,right and top
      of the axes. Values are relative to figure (0-1).
      Default: None
    notext: bool, optional
      If True: do not add resolution info text. Default=False
    return_projected_map : bool, optional
      if True returns the projected map in a 2d numpy array
    no_plot : bool, optional
      if True no figure will be created
    alpha : float, array-like or None
      An array containing the alpha channel, supports masked maps, see the `ma` function.
      If None, no transparency will be applied.
      See an example usage of the alpha channel transparency in the documentation under
      "Other tutorials"

    See Also
    --------
    mollview, cartview, orthview, azeqview
    r   Nr   F)r   )g333333@gš™™™™™@)r   )g333333³?gš™™™™™©?g333333³?gš™™™™™©?)g        g        g      ð?g      ð?)g        g        g        g        r   r   r   r   z Wrong values for sub: %d, %d, %d)g{®Gáz„?g        g        g{®Gáz”?g      ð?r   r   )r   r   r    r!   T)r"   r   r#   )r   r   r%   r&   r$   ÚysizeÚresor'   r*   r(   r)   r+   )r%   r&   )r*   r'   z0.91.0r,   g      à?r-   g{®Gáz´?gš™™™™™¹?)
r.   r/   r0   r1   r2   r3   r4   r5   r6   r    )	r/   r0   r1   r2   r3   r4   r5   r6   r    gìQ¸…ë±¿g{®Gáz”?z%g '/pix,   %dx%d pixr™   r$   r˜   rƒ   éZ   )r9   Úverticalalignmentr;   Úrotationg333333ã?r7   r8   )r9   r:   rœ   r;   )Zlonlatg¸…ëQ¸ž¿z(%g,%g)r<   )r›   Zhorizontalalignmentr;   gÍÌÌÌÌÌð?g333333Ó?r‚   )r9   r:   r;   r=   r>   )<r?   r@   rA   rB   r   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   ZHpxGnomonicAxesrS   rT   rU   rV   rW   r*   rX   rY   r'   rZ   r%   r&   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   Z	arrayinforj   ri   ZaroundZ
get_centerZ
_coordprecr.   rk   rl   rm   ÚcloseZclfZcla)5rn   ro   r   r   rp   r$   r˜   r™   rq   r   ru   rv   r"   rr   rs   rt   r    rx   r'   r(   r)   r*   rz   r}   r{   r|   ry   r~   Zno_plotr+   r?   r   r€   r   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   r.   rŒ   r   rŽ   r   r   r‘   ZlonZlatr’   r’   r“   r   T  s$   u


 













úCartesian viewc        5      C   s  ddl } | dkr$t d¡tj } d}t | ¡}!tj|!|d |sf|sf|sf| j|dd}"|s^d}d	}#n|r¼|  ¡ }"t 	|  
¡  ¡ ¡ ¡ \}$}%}&}'|s˜d
}|$|%|&|$ |'|% f}#|" |  
¡ ¡ nÆ|rÊ|  ¡ }"n¸|  ¡ }"t|dƒrè|\}(})}*n |d |d d |d   }(})}*|*dk s |*|)|( kr2td|(|)|*f ƒ‚|*d |) |*d |)  }+},|sVd}|+d |) d|,d d |(  d|) d|( f}#|sÔ|#d |d  |#d |d  |#d |d  |d  |#d |d  |d  f}#|  ¡ }-|  ¡  zt | ¡} |r|rtdƒ‚|r6tj	|tjd}| d¡ |d  d8  < |rF|" 
¡ }.n tj|"|#||||d}.|" |.¡ |r€tj| ||dd} n|r˜tj| ||dd} |.j| ||||||||	||||||d}/|rŽ|. ¡ d }0|0j t dd|0jj d ¡¡}1t |0jj!|0jj"|0jj ¡}2t#j$j%t&j'j(|0jj!|0jj"d|d}3t&j)dkr`|"j*|3|.ddd t +¡ d!d"|1|2|d#}4n"|"j*|3ddd t +¡ d!d"|1|2|d$
}4|4j, -d¡ |. .|
¡ |s¼|.j/d%d&|.j0j1d'd(d|.j2d) |râ|4j3j/d*d+|d'd(|4j3j2d,d-d. |" 4|.¡ W d|-r|  5¡  |  6¡  X |r|/S dS )/a~  Plot a healpix map (given as an array) in Cartesian projection.

    Parameters
    ----------
    map : float, array-like or None
      An array containing the map,
      supports masked maps, see the `ma` function.
      If None, will display a blank map, useful for overplotting.
    fig : int or None, optional
      The figure number to use. Default: create a new figure
    rot : scalar or sequence, optional
      Describe the rotation to apply.
      In the form (lon, lat, psi) (unit: degrees) : the point at
      longitude *lon* and latitude *lat* will be at the center. An additional rotation
      of angle *psi* around this direction is applied.
    coord : sequence of character, optional
      Either one of 'G', 'E' or 'C' to describe the coordinate
      system of the map, or a sequence of 2 of these to rotate
      the map from the first to the second coordinate system.
    unit : str, optional
      A text describing the unit of the data. Default: ''
    xsize : int, optional
      The size of the image. Default: 800
    lonra : sequence, optional
      Range in longitude. Default: [-180,180]
    latra : sequence, optional
      Range in latitude. Default: [-90,90]
    title : str, optional
      The title of the plot. Default: 'Mollweide view'
    nest : bool, optional
      If True, ordering scheme is NESTED. Default: False (RING)
    min : float, optional
      The minimum range value
    max : float, optional
      The maximum range value
    flip : {'astro', 'geo'}, optional
      Defines the convention of projection : 'astro' (default, east towards left, west towards right)
      or 'geo' (east towards roght, west towards left)
    remove_dip : bool, optional
      If :const:`True`, remove the dipole+monopole
    remove_mono : bool, optional
      If :const:`True`, remove the monopole
    gal_cut : float, scalar, optional
      Symmetric galactic cut for the dipole/monopole fit.
      Removes points in latitude range [-gal_cut, +gal_cut]
    format : str, optional
      The format of the scale label. Default: '%g'
    cbar : bool, optional
      Display the colorbar. Default: True
    notext : bool, optional
      If True, no text is printed around the map
    norm : {'hist', 'log', None}, optional
      Color normalization, hist= histogram equalized color mapping,
      log= logarithmic color mapping, default: None (linear color mapping)
    cmap : a color map
       The colormap to use (see matplotlib.cm)
    badcolor : str
      Color to use to plot bad values
    bgcolor : str
      Color to use for background
    hold : bool, optional
      If True, replace the current Axes by a CartesianAxes.
      use this if you want to have multiple maps on the same
      figure. Default: False
    sub : int, scalar or sequence, optional
      Use only a zone of the current figure (same syntax as subplot).
      Default: None
    reuse_axes : bool, optional
      If True, reuse the current Axes (should be a CartesianAxes). This is
      useful if you want to overplot with a partially transparent colormap,
      such as for plotting a line integral convolution. Default: False
    margins : None or sequence, optional
      Either None, or a sequence (left,bottom,right,top)
      giving the margins on left,bottom,right and top
      of the axes. Values are relative to figure (0-1).
      Default: None
    return_projected_map : bool
      if True returns the projected map in a 2d numpy array
    alpha : float, array-like or None
      An array containing the alpha channel, supports masked maps, see the `ma` function.
      If None, no transparency will be applied.

    See Also
    --------
    mollview, gnomview, orthview, azeqview
    r   Nr   F)r   )g      !@gš™™™™™@)r   )g333333³?gš™™™™™©?g333333³?gš™™™™™©?)g        g        g      ð?g      ð?)g        g        g        g        r   r   r   r   z Wrong values for sub: %d, %d, %d)g{®Gáz„?g        g        g{®Gáz”?g      ð?r   r   zOnly give rot or zat, not both)Zdtyperš   )r   r   r    r!   T)r"   r   r#   )r   r   r%   r&   r$   r˜   ÚlonraÚlatrar'   r(   r)   r*   r1   r+   )r%   r&   )r*   r'   z0.91.0r,   g      à?r-   g{®Gáz´?gš™™™™™¹?)
r.   r/   r0   r1   r2   r3   r4   r5   r6   r    )	r/   r0   r1   r2   r3   r4   r5   r6   r    gìQ¸…ë±¿g333333ã?r7   r8   )r9   r:   rœ   r;   gÍÌÌÌÌÌð?g333333Ó?r‚   r<   )r9   r:   r;   r=   r>   )7r?   r@   rA   rB   r   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   Zfloat64ÚresizerQ   ZHpxCartesianAxesrS   rT   rU   rV   rW   r*   rX   rY   r'   rZ   r%   r&   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r.   rk   rm   rl   )5rn   ro   r   Úzatr   rp   r$   r˜   rŸ   r    rq   r   ru   rv   r"   rr   rs   rt   r    rx   r'   r(   r)   r*   r1   rz   r}   r{   r|   ry   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   y  s   x


 









úOrthographic viewc       2      C   s¾  ddl }| dkr$t d¡tj } d}t | ¡}tj||d |sf|sf|sf|j|dd}|s^d}d	} n|r¼| ¡ }t 	| 
¡  ¡ ¡ ¡ \}!}"}#}$|s˜d
}|!|"|#|! |$|" f} | | 
¡ ¡ nÆ|rÊ| ¡ }n¸| ¡ }t|dƒrè|\}%}&}'n |d |d d |d   }%}&}'|'dk s |'|&|% kr2td|%|&|'f ƒ‚|'d |& |'d |&  }(})|sVd}|(d |& d|)d d |%  d|& d|% f} |sÔ| d |d  | d |d  | d |d  |d  | d |d  |d  f} | ¡ }*| ¡  z°|rø| 
¡ }+n tj|| ||||d}+| |+¡ |r2tj| ||dd} n|rJtj| ||dd} |+j| |||||	|
|||||d},|r:|+ ¡ d }-|-j t dd|-jjd ¡¡}.t |-jj|-jj|-jj¡}/t j!j"t#j$j%|-jj|-jjd|d}0t#j&dkr|j'|0|+dddt (¡ dd|.|/|d }1n"|j'|0dddt (¡ dd|.|/|d!
}1|1j) *d¡ |+ +|¡ |sf|+j,d"d|+j-j.d#d$|+j/d% |rŠ|1j0j,dd&|d#|1j0j/d'd'd( | 1|+¡ W d| 2¡  |*r®| 3¡  X |rº|,S dS ))ac  Plot a healpix map (given as an array) in Orthographic projection.

    Parameters
    ----------
    map : float, array-like or None
      An array containing the map.
      If None, will display a blank map, useful for overplotting.
    fig : int or None, optional
      The figure number to use. Default: create a new figure
    rot : scalar or sequence, optional
      Describe the rotation to apply.
      In the form (lon, lat, psi) (unit: degrees) : the point at
      longitude *lon* and latitude *lat* will be at the center. An additional rotation
      of angle *psi* around this direction is applied.
    coord : sequence of character, optional
      Either one of 'G', 'E' or 'C' to describe the coordinate
      system of the map, or a sequence of 2 of these to rotate
      the map from the first to the second coordinate system.
    half_sky : bool, optional
      Plot only one side of the sphere. Default: False
    unit : str, optional
      A text describing the unit of the data. Default: ''
    xsize : int, optional
      The size of the image. Default: 800
    title : str, optional
      The title of the plot. Default: 'Orthographic view'
    nest : bool, optional
      If True, ordering scheme is NESTED. Default: False (RING)
    min : float, optional
      The minimum range value
    max : float, optional
      The maximum range value
    flip : {'astro', 'geo'}, optional
      Defines the convention of projection : 'astro' (default, east towards left, west towards right)
      or 'geo' (east towards roght, west towards left)
    remove_dip : bool, optional
      If :const:`True`, remove the dipole+monopole
    remove_mono : bool, optional
      If :const:`True`, remove the monopole
    gal_cut : float, scalar, optional
      Symmetric galactic cut for the dipole/monopole fit.
      Removes points in latitude range [-gal_cut, +gal_cut]
    format : str, optional
      The format of the scale label. Default: '%g'
    format2 : str, optional
      Format of the pixel value under mouse. Default: '%g'
    cbar : bool, optional
      Display the colorbar. Default: True
    notext : bool, optional
      If True, no text is printed around the map
    norm : {'hist', 'log', None}
      Color normalization, hist= histogram equalized color mapping,
      log= logarithmic color mapping, default: None (linear color mapping)
    cmap : a color map
       The colormap to use (see matplotlib.cm)
    badcolor : str
      Color to use to plot bad values
    bgcolor : str
      Color to use for background
    hold : bool, optional
      If True, replace the current Axes by an OrthographicAxes.
      use this if you want to have multiple maps on the same
      figure. Default: False
    sub : int, scalar or sequence, optional
      Use only a zone of the current figure (same syntax as subplot).
      Default: None
    reuse_axes : bool, optional
      If True, reuse the current Axes (should be a OrthographicAxes). This is
      useful if you want to overplot with a partially transparent colormap,
      such as for plotting a line integral convolution. Default: False
    margins : None or sequence, optional
      Either None, or a sequence (left,bottom,right,top)
      giving the margins on left,bottom,right and top
      of the axes. Values are relative to figure (0-1).
      Default: None
    return_projected_map : bool
      if True returns the projected map in a 2d numpy array
    alpha : float, array-like or None
      An array containing the alpha channel, supports masked maps, see the `ma` function.
      If None, no transparency will be applied.

    See Also
    --------
    mollview, gnomview, cartview, azeqview
    r   Nr   F)r   )g      !@gš™™™™™@)r   )g{®Gáz”?gš™™™™™©?g{®Gáz”?gš™™™™™©?)g        g        g      ð?g      ð?)g        g        g        g        r   r   r   r   z Wrong values for sub: %d, %d, %d)g{®Gáz„?g        g        g{®Gáz”?g      ð?r   r   )r   r   r    r!   T)r"   r   r#   )r   r$   Úhalf_skyr   r%   r&   r'   r(   r)   r*   r+   )r%   r&   )r*   r'   z0.91.0r,   g      à?r-   gš™™™™™©?gš™™™™™¹?)
r.   r/   r0   r1   r2   r3   r4   r5   r6   r    )	r/   r0   r1   r2   r3   r4   r5   r6   r    g…ëQ¸…ë?r7   r8   )r9   r:   r;   g      ð¿r<   )r9   r;   r=   r>   )4r?   r@   rA   rB   r   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rQ   ZHpxOrthographicAxesrS   rT   rU   rV   rW   r*   rX   rY   r'   rZ   r%   r&   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r.   rk   rl   rm   )2rn   ro   r   r   rp   r$   r¤   rq   r   rr   rs   rt   ru   rv   r"   r    rw   rx   r'   r(   r)   ry   r*   rz   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   Ž  sò    u


 







c!       6      C   sÞ  ddl }!| dkr$t d¡tj } d}t | ¡}"tj|"|d |sf|sf|sf|!j|dd}#|s^d}d	}$n|r¼|! ¡ }#t 	|# 
¡  ¡ ¡ ¡ \}%}&}'}(|s˜d
}|%|&|'|% |(|& f}$|# |# 
¡ ¡ nÆ|rÊ|! ¡ }#n¸|! ¡ }#t|dƒrè|\})}*}+n |d |d d |d   })}*}+|+dk s |+|*|) kr2td|)|*|+f ƒ‚|+d |* |+d |*  },}-|sVd}|,d |* d|-d d |)  d|* d|) f}$|sÔ|$d |d  |$d |d  |$d |d  |d  |$d |d  |d  f}$|! ¡ }.|! ¡  zÐ|rø|# 
¡ }/n tj|#|$||||d}/|# |/¡ |r2tj| ||dd} n|rJtj| ||dd} |/j| |||||	|
|||||||| d}0|r@|/ ¡ d }1|1j t dd|1jjd ¡¡}2t |1jj|1jj|1jj¡}3t j!j"t#j$j%|1jj|1jjd|d}4t#j&dkr|#j'|4|/dddt (¡ dd|2|3|d }5n"|#j'|4dddt (¡ dd|2|3|d!
}5|5j) *d¡ |dkrZ|	rVd"}nd#}|/ +|¡ |s†|/j,d$d|/j-j.d%d&|/j/d' |rª|5j0j,dd(|d%|5j0j/d)d)d* |# 1|/¡ W d|! 2¡  |.rÎ|! 3¡  X |rÚ|0S dS )+aù  Plot a healpix map (given as an array) in Azimuthal equidistant projection
    or Lambert azimuthal equal-area projection.

    Parameters
    ----------
    map : float, array-like or None
      An array containing the map,
      supports masked maps, see the `ma` function.
      If None, will display a blank map, useful for overplotting.
    fig : int or None, optional
      The figure number to use. Default: create a new figure
    rot : scalar or sequence, optional
      Describe the rotation to apply.
      In the form (lon, lat, psi) (unit: degrees) : the point at
      longitude *lon* and latitude *lat* will be at the center. An additional rotation
      of angle *psi* around this direction is applied.
    coord : sequence of character, optional
      Either one of 'G', 'E' or 'C' to describe the coordinate
      system of the map, or a sequence of 2 of these to rotate
      the map from the first to the second coordinate system.
    unit : str, optional
      A text describing the unit of the data. Default: ''
    xsize : int, optional
      The size of the image. Default: 800
    ysize : None or int, optional
      The size of the image. Default: None= xsize
    reso : float, optional
      Resolution (in arcmin). Default: 1.5 arcmin
    lamb : bool, optional
      If True, plot Lambert azimuthal equal area instead of azimuthal
      equidistant. Default: False (az equidistant)
    half_sky : bool, optional
      Plot only one side of the sphere. Default: False
    title : str, optional
      The title of the plot. Default: 'Azimuthal equidistant view'
      or 'Lambert azimuthal equal-area view' (if lamb is True)
    nest : bool, optional
      If True, ordering scheme is NESTED. Default: False (RING)
    min : float, optional
      The minimum range value
    max : float, optional
      The maximum range value
    flip : {'astro', 'geo'}, optional
      Defines the convention of projection : 'astro' (default, east towards left, west towards right)
      or 'geo' (east towards roght, west towards left)
    remove_dip : bool, optional
      If :const:`True`, remove the dipole+monopole
    remove_mono : bool, optional
      If :const:`True`, remove the monopole
    gal_cut : float, scalar, optional
      Symmetric galactic cut for the dipole/monopole fit.
      Removes points in latitude range [-gal_cut, +gal_cut]
    format : str, optional
      The format of the scale label. Default: '%g'
    cbar : bool, optional
      Display the colorbar. Default: True
    notext : bool, optional
      If True, no text is printed around the map
    norm : {'hist', 'log', None}
      Color normalization, hist= histogram equalized color mapping,
      log= logarithmic color mapping, default: None (linear color mapping)
    cmap : a color map
       The colormap to use (see matplotlib.cm)
    badcolor : str
      Color to use to plot bad values
    bgcolor : str
      Color to use for background
    hold : bool, optional
      If True, replace the current Axes by an Equidistant AzimuthalAxes.
      use this if you want to have multiple maps on the same
      figure. Default: False
    sub : int, scalar or sequence, optional
      Use only a zone of the current figure (same syntax as subplot).
      Default: None
    reuse_axes : bool, optional
      If True, reuse the current Axes (should be a AzimuthalAxes). This is
      useful if you want to overplot with a partially transparent colormap,
      such as for plotting a line integral convolution. Default: False
    margins : None or sequence, optional
      Either None, or a sequence (left,bottom,right,top)
      giving the margins on left,bottom,right and top
      of the axes. Values are relative to figure (0-1).
      Default: None
    return_projected_map : bool
      if True returns the projected map in a 2d numpy array
    alpha : float, array-like or None
      An array containing the alpha channel, supports masked maps, see the `ma` function.
      If None, no transparency will be applied.

    See Also
    --------
    mollview, gnomview, cartview, orthview
    r   Nr   F)r   )g      !@gš™™™™™@)r   )g{®Gáz”?gš™™™™™©?g{®Gáz”?gš™™™™™©?)g        g        g      ð?g      ð?)g        g        g        g        r   r   r   r   z Wrong values for sub: %d, %d, %d)g{®Gáz„?g        g        g{®Gáz”?g      ð?r   r   )r   r   r    r!   T)r"   r   r#   )r   r$   r˜   r™   Úlambr¤   r   r%   r&   r'   r(   r)   r*   r+   )r%   r&   )r*   r'   z0.91.0r,   g      à?r-   gš™™™™™©?gš™™™™™¹?)
r.   r/   r0   r1   r2   r3   r4   r5   r6   r    )	r/   r0   r1   r2   r3   r4   r5   r6   r    z!Lambert azimuthal equal-area viewzAzimuthal equidistant viewg…ëQ¸…ë?r7   r8   )r9   r:   r;   g      ð¿r<   )r9   r;   r=   r>   )4r?   r@   rA   rB   r   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rQ   ZHpxAzimuthalAxesrS   rT   rU   rV   rW   r*   rX   rY   r'   rZ   r%   r&   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r.   rk   rl   rm   )6rn   ro   r   r¢   r   rp   r$   r˜   r™   r¥   r¤   rq   r   ru   rv   r"   rr   rs   rt   r    rx   r'   r(   r)   r*   r1   rz   r}   r{   r|   ry   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   ˜  s    


 








c       	      K   s¾   ddl }| ¡ }| ¡ }| ¡  z‚t| ¡ ƒdkrhtj|d|d}| |¡ |j	dd|j
jdd|jd	 x6| ¡ D ]*}t|tjƒrr|jf | |||d
œ|—Ž qrW W d| ¡  |r¸| ¡  X dS )aX  Draw a graticule on the current Axes.

    Parameters
    ----------
    dpar, dmer : float, scalars
      Interval in degrees between meridians and between parallels
    coord : {'E', 'G', 'C'}
      The coordinate system of the graticule (make rotation if needed,
      using coordinate system of the map if it is defined).
    local : bool
      If True, draw a local graticule (no rotation is performed, useful for
      a gnomonic view, for example)

    Notes
    -----
    Other keyword parameters will be transmitted to the projplot function.

    See Also
    --------
    delgraticules
    r   N)g{®Gáz”?gš™™™™™©?g¸…ëQ¸î?gÍÌÌÌÌÌì?)r   g…ëQ¸…ë?gš™™™™™©?r7   r8   )r9   r:   r;   )ÚdparÚdmerr   Úlocal)r?   rF   rN   rO   ÚlenÚget_axesrQ   rR   rS   rg   rh   ri   rj   Ú
isinstanceÚSphericalProjAxesr   rl   rm   )	r¦   r§   r   r¨   Úkwdsr?   r€   r‹   r.   r’   r’   r“   r   ¶  s*    

"c              C   sf   ddl } |  ¡ }|  ¡ }|  ¡  z*x$| ¡ D ]}t|tjƒr,| ¡  q,W W d|  	¡  |r`|  
¡  X dS )zcDelete all graticules previously created on the Axes.

    See Also
    --------
    graticule
    r   N)r?   rF   rN   rO   rª   r«   rQ   r¬   r   rl   rm   )r?   r€   r‹   r.   r’   r’   r“   r   æ  s    c              O   sn   dd l }| ¡ }| ¡ }| ¡  d }z.x(| ¡ D ]}t|tjƒr0|j| |Ž}q0W W d | 	¡  |rh| 
¡  X |S )Nr   )r?   rF   rN   rO   rª   r«   rQ   r¬   r   rl   rm   )Úargsr­   r?   r€   r‹   Úretr.   r’   r’   r“   r   ý  s    
c              O   sn   dd l }| ¡ }| ¡ }| ¡  d }z.x(| ¡ D ]}t|tjƒr0|j| |Ž}q0W W d | 	¡  |rh| 
¡  X |S )Nr   )r?   rF   rN   rO   rª   r«   rQ   r¬   r	   rl   rm   )r®   r­   r?   r€   r‹   r¯   r.   r’   r’   r“   r	     s    
c              O   sn   dd l }| ¡ }| ¡ }| ¡  d }z.x(| ¡ D ]}t|tjƒr0|j| |Ž}q0W W d | 	¡  |rh| 
¡  X |S )Nr   )r?   rF   rN   rO   rª   r«   rQ   r¬   r
   rl   rm   )r®   r­   r?   r€   r‹   r¯   r.   r’   r’   r“   r
   )  s    
)NNNNr   r   r   FNNr   FFr   r   r   TNr   r   FNFFNNr   FN)NNNNr   r”   Nr•   r–   FFFr   NNr   r—   TNr   r   NFNFNFFFN) NNNNNr   r   NNNrž   FFFr   NNr   r—   TNr   r   NNFNFNFFN)NNNNr   r   Fr£   FNNr   FFr   r   r   TNr   r   FNFNNFFN)!NNNNNr   r   Nr•   FFNFFFr   NNr   r—   TNr   r   NNFNFNFFN)NNNN)Ú__doc__Ú__all__r   r   rQ   Únumpyr@   r^   Zmatplotlib.pyplotZpyplotr[   r   ÚpiZdtorr   r   r   r   r   r   r   r   r¬   r	   r
   r’   r’   r’   r“   Ú<module>1   sp                              
 o                             
  
                               
 w                            
 o                                
 ~
0