(
    map=None,
    fig=None,
    rot=None,
    coord=None,
    unit="",
    xsize=800,
    title="Mollweide view",
    nest=False,
    min=None,
    max=None,
    flip="astro",
    remove_dip=False,
    remove_mono=False,
    gal_cut=0,
    format="%g",
    cmap=None,
    norm=None,
    hold=False,
    margins=None,
    sub=None,
)
Interactive mollweide plot with zoomed gnomview.

    Parameters:
    -----------
    map : float, array-like shape (Npix,)
      An array containing the map,
      supports masked maps, see the `ma` function.
      if None, use map with inf value (white map), useful for
      overplotting
    fig : a figure number.
      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 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'
Interactive mollweide plot with zoomed gnomview.
Interactive mollweide plot with zoomed gnomview .
def mollzoom(
    map=None,
    fig=None,
    rot=None,
    coord=None,
    unit="",
    xsize=800,
    title="Mollweide view",
    nest=False,
    min=None,
    max=None,
    flip="astro",
    remove_dip=False,
    remove_mono=False,
    gal_cut=0,
    format="%g",
    cmap=None,
    norm=None,
    hold=False,
    margins=None,
    sub=None,
):
    """Interactive mollweide plot with zoomed gnomview.

    Parameters:
    -----------
    map : float, array-like shape (Npix,)
      An array containing the map,
      supports masked maps, see the `ma` function.
      if None, use map with inf value (white map), useful for
      overplotting
    fig : a figure number.
      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 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'
    """
    import pylab

    # Ensure that the nside is valid
    nside = pixelfunc.get_nside(map)
    pixelfunc.check_nside(nside, nest=nest)

    # create the figure (if interactive, it will open the window now)
    f = pylab.figure(fig, figsize=(10.5, 5.4))
    extent = (0.02, 0.25, 0.56, 0.72)
    # Starting to draw : turn interactive off
    wasinteractive = pylab.isinteractive()
    pylab.ioff()
    try:
        if map is None:
            map = np.zeros(12) + np.inf
        map = pixelfunc.ma_to_array(map)
        ax = PA.HpxMollweideAxes(
            f, extent, coord=coord, rot=rot, format=format, flipconv=flip
        )
        f.add_axes(ax)
        if remove_dip:
            map = pixelfunc.remove_dipole(
                map, gal_cut=gal_cut, nest=nest, copy=True
            )
        elif remove_mono:
            map = pixelfunc.remove_monopole(
                map, gal_cut=gal_cut, nest=nest, copy=True
            )
        ax.projmap(
            map,
            nest=nest,
            xsize=xsize,
            coord=coord,
            vmin=min,
            vmax=max,
            cmap=cmap,
            norm=norm,
        )
        im = ax.get_images()[0]
        b = im.norm.inverse(np.linspace(0, 1, im.cmap.N + 1))
        v = np.linspace(im.norm.vmin, im.norm.vmax, im.cmap.N)
        if matplotlib.__version__ >= "0.91.0":
            cb = f.colorbar(
                ax.get_images()[0],
                ax=ax,
                orientation="horizontal",
                shrink=0.5,
                aspect=25,
                ticks=PA.BoundaryLocator(),
                pad=0.05,
                fraction=0.1,
                boundaries=b,
                values=v,
            )
        else:
            # for older matplotlib versions, no ax kwarg
            cb = f.colorbar(
                ax.get_images()[0],
                orientation="horizontal",
                shrink=0.5,
                aspect=25,
                ticks=PA.BoundaryLocator(),
                pad=0.05,
                fraction=0.1,
                boundaries=b,
                values=v,
            )
        ax.set_title(title)
        ax.text(
            0.86,
            0.05,
            ax.proj.coordsysstr,
            fontsize=14,
            fontweight="bold",
            transform=ax.transAxes,
        )
        cb.ax.text(
            1.05,
            0.30,
            unit,
            fontsize=14,
            fontweight="bold",
            transform=cb.ax.transAxes,
            ha="left",
            va="center",
        )
        f.sca(ax)

        ## Gnomonic axes
        # extent = (0.02,0.25,0.56,0.72)
        g_xsize = 600
        g_reso = 1.0
        extent = (0.60, 0.04, 0.38, 0.94)
        g_ax = PA.HpxGnomonicAxes(
            f, extent, coord=coord, rot=rot, format=format, flipconv=flip
        )
        f.add_axes(g_ax)
        if remove_dip:
            map = pixelfunc.remove_dipole(map, gal_cut=gal_cut, nest=nest, copy=True)
        elif remove_mono:
            map = pixelfunc.remove_monopole(map, gal_cut=gal_cut, nest=nest, copy=True)
        g_ax.projmap(
            map,
            nest=nest,
            coord=coord,
            vmin=min,
            vmax=max,
            xsize=g_xsize,
            ysize=g_xsize,
            reso=g_reso,
            cmap=cmap,
            norm=norm,
        )
        im = g_ax.get_images()[0]
        b = im.norm.inverse(np.linspace(0, 1, im.cmap.N + 1))
        v = np.linspace(im.norm.vmin, im.norm.vmax, im.cmap.N)
        if matplotlib.__version__ >= "0.91.0":
            cb = f.colorbar(
                g_ax.get_images()[0],
                ax=g_ax,
                orientation="horizontal",
                shrink=0.5,
                aspect=25,
                ticks=PA.BoundaryLocator(),
                pad=0.08,
                fraction=0.1,
                boundaries=b,
                values=v,
            )
        else:
            cb = f.colorbar(
                g_ax.get_images()[0],
                orientation="horizontal",
                shrink=0.5,
                aspect=25,
                ticks=PA.BoundaryLocator(),
                pad=0.08,
                fraction=0.1,
                boundaries=b,
                values=v,
            )
        g_ax.set_title(title)
        g_ax.text(
            -0.07,
            0.02,
            "%g '/pix,   %dx%d pix"
            % (
                g_ax.proj.arrayinfo["reso"],
                g_ax.proj.arrayinfo["xsize"],
                g_ax.proj.arrayinfo["ysize"],
            ),
            fontsize=12,
            verticalalignment="bottom",
            transform=g_ax.transAxes,
            rotation=90,
        )
        g_ax.text(
            -0.07,
            0.8,
            g_ax.proj.coordsysstr,
            fontsize=14,
            fontweight="bold",
            rotation=90,
            transform=g_ax.transAxes,
        )
        lon, lat = np.around(g_ax.proj.get_center(lonlat=True), g_ax._coordprec)
        g_ax.text(
            0.5,
            -0.03,
            "on (%g,%g)" % (lon, lat),
            verticalalignment="center",
            horizontalalignment="center",
            transform=g_ax.transAxes,
        )
        cb.ax.text(
            1.05,
            0.30,
            unit,
            fontsize=14,
            fontweight="bold",
            transform=cb.ax.transAxes,
            ha="left",
            va="center",
        )
        # Add graticule info axes
        grat_ax = pylab.axes([0.25, 0.02, 0.22, 0.25])
        grat_ax.axis("off")
        # Add help text
        help_ax = pylab.axes([0.02, 0.02, 0.22, 0.25])
        help_ax.axis("off")
        t = help_ax.transAxes
        help_ax.text(0.1, 0.8, "r/t .... zoom out/in", transform=t, va="baseline")
        help_ax.text(0.1, 0.65, "p/v .... print coord/val", transform=t, va="baseline")
        help_ax.text(0.1, 0.5, "c ...... go to center", transform=t, va="baseline")
        help_ax.text(0.1, 0.35, "f ...... next color scale", transform=t, va="baseline")
        help_ax.text(
            0.1, 0.2, "k ...... save current scale", transform=t, va="baseline"
        )
        help_ax.text(0.1, 0.05, "g ...... toggle graticule", transform=t, va="baseline")
        f.sca(g_ax)
        # Set up the zoom capability
        zt = ZoomTool(map, fig=f.number, nest=nest, cmap=cmap, norm=norm, coord=coord)
    finally:
        pylab.draw()
        if wasinteractive:
            pylab.ion()
def mollzoom ( map = None , fig = None , rot = None , coord = None , unit = "" , xsize = 800 , title = "Mollweide view" , nest = False , min = None , max = None , flip = "astro" , remove_dip = False , remove_mono = False , gal_cut = 0 , format = "%g" , cmap = None , norm = None , hold = False , margins = None , sub = None , ) : import pylab # Ensure that the nside is valid nside = pixelfunc . get_nside ( map ) pixelfunc . check_nside ( nside , nest = nest ) # create the figure (if interactive, it will open the window now) f = pylab . figure ( fig , figsize = ( 10.5 , 5.4 ) ) extent = ( 0.02 , 0.25 , 0.56 , 0.72 ) # Starting to draw : turn interactive off wasinteractive = pylab . isinteractive ( ) pylab . ioff ( ) try : if map is None : map = np . zeros ( 12 ) + np . inf map = pixelfunc . ma_to_array ( map ) ax = PA . HpxMollweideAxes ( f , extent , coord = coord , rot = rot , format = format , flipconv = flip ) f . add_axes ( ax ) if remove_dip : map = pixelfunc . remove_dipole ( map , gal_cut = gal_cut , nest = nest , copy = True ) elif remove_mono : map = pixelfunc . remove_monopole ( map , gal_cut = gal_cut , nest = nest , copy = True ) ax . projmap ( map , nest = nest , xsize = xsize , coord = coord , vmin = min , vmax = max , cmap = cmap , norm = norm , ) im = ax . get_images ( ) [ 0 ] b = im . norm . inverse ( np . linspace ( 0 , 1 , im . cmap . N + 1 ) ) v = np . linspace ( im . norm . vmin , im . norm . vmax , im . cmap . N ) if matplotlib . __version__ >= "0.91.0" : cb = f . colorbar ( ax . get_images ( ) [ 0 ] , ax = ax , orientation = "horizontal" , shrink = 0.5 , aspect = 25 , ticks = PA . BoundaryLocator ( ) , pad = 0.05 , fraction = 0.1 , boundaries = b , values = v , ) else : # for older matplotlib versions, no ax kwarg cb = f . colorbar ( ax . get_images ( ) [ 0 ] , orientation = "horizontal" , shrink = 0.5 , aspect = 25 , ticks = PA . BoundaryLocator ( ) , pad = 0.05 , fraction = 0.1 , boundaries = b , values = v , ) ax . set_title ( title ) ax . text ( 0.86 , 0.05 , ax . proj . coordsysstr , fontsize = 14 , fontweight = "bold" , transform = ax . transAxes , ) cb . ax . text ( 1.05 , 0.30 , unit , fontsize = 14 , fontweight = "bold" , transform = cb . ax . transAxes , ha = "left" , va = "center" , ) f . sca ( ax ) ## Gnomonic axes # extent = (0.02,0.25,0.56,0.72) g_xsize = 600 g_reso = 1.0 extent = ( 0.60 , 0.04 , 0.38 , 0.94 ) g_ax = PA . HpxGnomonicAxes ( f , extent , coord = coord , rot = rot , format = format , flipconv = flip ) f . add_axes ( g_ax ) if remove_dip : map = pixelfunc . remove_dipole ( map , gal_cut = gal_cut , nest = nest , copy = True ) elif remove_mono : map = pixelfunc . remove_monopole ( map , gal_cut = gal_cut , nest = nest , copy = True ) g_ax . projmap ( map , nest = nest , coord = coord , vmin = min , vmax = max , xsize = g_xsize , ysize = g_xsize , reso = g_reso , cmap = cmap , norm = norm , ) im = g_ax . get_images ( ) [ 0 ] b = im . norm . inverse ( np . linspace ( 0 , 1 , im . cmap . N + 1 ) ) v = np . linspace ( im . norm . vmin , im . norm . vmax , im . cmap . N ) if matplotlib . __version__ >= "0.91.0" : cb = f . colorbar ( g_ax . get_images ( ) [ 0 ] , ax = g_ax , orientation = "horizontal" , shrink = 0.5 , aspect = 25 , ticks = PA . BoundaryLocator ( ) , pad = 0.08 , fraction = 0.1 , boundaries = b , values = v , ) else : cb = f . colorbar ( g_ax . get_images ( ) [ 0 ] , orientation = "horizontal" , shrink = 0.5 , aspect = 25 , ticks = PA . BoundaryLocator ( ) , pad = 0.08 , fraction = 0.1 , boundaries = b , values = v , ) g_ax . set_title ( title ) g_ax . text ( - 0.07 , 0.02 , "%g '/pix,   %dx%d pix" % ( g_ax . proj . arrayinfo [ "reso" ] , g_ax . proj . arrayinfo [ "xsize" ] , g_ax . proj . arrayinfo [ "ysize" ] , ) , fontsize = 12 , verticalalignment = "bottom" , transform = g_ax . transAxes , rotation = 90 , ) g_ax . text ( - 0.07 , 0.8 , g_ax . proj . coordsysstr , fontsize = 14 , fontweight = "bold" , rotation = 90 , transform = g_ax . transAxes , ) lon , lat = np . around ( g_ax . proj . get_center ( lonlat = True ) , g_ax . _coordprec ) g_ax . text ( 0.5 , - 0.03 , "on (%g,%g)" % ( lon , lat ) , verticalalignment = "center" , horizontalalignment = "center" , transform = g_ax . transAxes , ) cb . ax . text ( 1.05 , 0.30 , unit , fontsize = 14 , fontweight = "bold" , transform = cb . ax . transAxes , ha = "left" , va = "center" , ) # Add graticule info axes grat_ax = pylab . axes ( [ 0.25 , 0.02 , 0.22 , 0.25 ] ) grat_ax . axis ( "off" ) # Add help text help_ax = pylab . axes ( [ 0.02 , 0.02 , 0.22 , 0.25 ] ) help_ax . axis ( "off" ) t = help_ax . transAxes help_ax . text ( 0.1 , 0.8 , "r/t .... zoom out/in" , transform = t , va = "baseline" ) help_ax . text ( 0.1 , 0.65 , "p/v .... print coord/val" , transform = t , va = "baseline" ) help_ax . text ( 0.1 , 0.5 , "c ...... go to center" , transform = t , va = "baseline" ) help_ax . text ( 0.1 , 0.35 , "f ...... next color scale" , transform = t , va = "baseline" ) help_ax . text ( 0.1 , 0.2 , "k ...... save current scale" , transform = t , va = "baseline" ) help_ax . text ( 0.1 , 0.05 , "g ...... toggle graticule" , transform = t , va = "baseline" ) f . sca ( g_ax ) # Set up the zoom capability zt = ZoomTool ( map , fig = f . number , nest = nest , cmap = cmap , norm = norm , coord = coord ) finally : pylab . draw ( ) if wasinteractive : pylab . ion ( )