This file is indexed.

/usr/lib/python3/dist-packages/pymoc/util/plot.py is in python3-pymoc 0.4.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Copyright (C) 2013-2014 Science and Technology Facilities Council.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import healpy
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as plt
import numpy as np


def plot_moc(moc, order=None, antialias=0, filename=None,
             projection='cart', color='blue', title='', coord_sys='C',
             graticule=True, **kwargs):
    """Plot a MOC using Healpy.

    This generates a plot of the MOC at the specified order, or the MOC's
    current order if this is not specified.  The MOC is flattened at an order
    of `order + antialias` to generate intermediate color levels.

    :param order: HEALPix order at which to generate the plot.

    :param antialias: number of additional HEALPix orders to use for
        intermediate color levels.  (There can be `4 ** antialias` levels.)

    :param filename: file in which to save plot.  If not specified then
        the plot is shown with `plt.show()`.

    :param projection: map projection to be used --- can be shortened to
        4 characters.  One of:

            * `'cart[esian]'` (uses `healpy.visufunc.cartview`)
            * `'moll[weide]'` (uses `healpy.visufunc.mollview`)
            * `'gnom[onic]'` (uses `healpy.visufunc.gnomview`)

    :param color: color scheme.
        One of:

            * `'blue'`
            * `'green'`
            * `'red'`
            * `'black'`

    :param title: title of the plot.

    :param coord_sys: Healpy coordinate system code for the desired plot
        coordinates.  One of:

            * `'C'` --- Celestial (equatorial)
            * `'G'` --- Galactic
            * `'E'` --- Ecliptic

    :param graticule: whether or not to draw a graticule.

    :param \*\*kwargs: passed to the selected Healpy plotting function.
    """

    # Process arguments.
    plotargs = {'xsize': 3200, 'cbar': False, 'notext': True}

    if order is None:
        order = moc.order

    if projection.startswith('cart'):
        plotter = healpy.visufunc.cartview
    elif projection.startswith('moll'):
        plotter = healpy.visufunc.mollview
    elif projection.startswith('gnom'):
        plotter = healpy.visufunc.gnomview
    else:
        raise ValueError('Unknown projection: {0}'.format(projection))

    if color == 'blue':
        plotargs['cmap'] = LinearSegmentedColormap.from_list(
            'white-blue', ['#FFFFFF', '#0000AA'])
    elif color == 'green':
        plotargs['cmap'] = LinearSegmentedColormap.from_list(
            'white-green', ['#FFFFFF', '#008800'])
    elif color == 'red':
        plotargs['cmap'] = LinearSegmentedColormap.from_list(
            'white-red', ['#FFFFFF', '#FF0000'])
    elif color == 'black':
        plotargs['cmap'] = LinearSegmentedColormap.from_list(
            'white-black', ['#FFFFFF', '#000000'])
    else:
        raise ValueError('Unknown color: {0}'.format(color))

    if coord_sys == 'C':
        pass
    elif coord_sys == 'G':
        plotargs['coord'] = ('C', 'G')
    elif coord_sys == 'E':
        plotargs['coord'] = ('C', 'E')
    else:
        raise ValueError('Unknown coordinate system: {0}'.format(coord_sys))

    # Any other arguments are passed the Healpy plotter directly.
    plotargs.update(kwargs)

    # Create a Numpy array which is zero for points outside the MOC and one
    # for points inside the MOC.
    map = np.zeros(12 * 4 ** order)
    antialias_shift = 2 * antialias

    for cell in moc.flattened(order + antialias):
        map[cell >> antialias_shift] += 1.0

    # Plot the Numpy array using Healpy.
    plotter(map, nest=True, title=title, **plotargs)

    if graticule:
        healpy.visufunc.graticule()

    if filename is not None:
        plt.savefig(filename)
    else:
        plt.show()