コード例 #1
0
def plot_core_occupancy(occ, path, name):
    """Plot number of compartments per core of a layer.

    :param np.ndarray occ: Core occupancy to plot. Shape is equal to the number
        of cores per axis.
    :param str path: Where to save figure.
    :param str name: Name of partition.
    """

    occ = normalizeImageDim(occ)

    fig, ax = plt.subplots()
    im = ax.imshow(occ, cmap='Blues', vmin=0, vmax=1024)
    vals = np.unique([0] + list(np.ravel(occ)))
    if 1024 - np.max(vals) > 100:
        vals = np.concatenate([vals, [1024]])
    fig.colorbar(im,
                 ticks=vals[::(len(vals) // 10) + 1],
                 fraction=0.02,
                 pad=0.04)
    ax.set_xticks(np.arange(0, occ.shape[1], occ.shape[1] // 10 + 1))
    ax.set_yticks(np.arange(0, occ.shape[0], occ.shape[0] // 10 + 1))
    ax.tick_params(which='both', left=False, bottom=False)
    ax.xaxis.set_minor_locator(IndexLocator(1, 1))
    ax.yaxis.set_minor_locator(IndexLocator(1, 1))
    ax.grid(which='minor')
    ax.set_title('Core occupancy of layer {}'.format(name))
    fig.savefig(os.path.join(path, 'coreOccupancy_{}'.format(name)),
                bbox_inches='tight')
コード例 #2
0
def plot_multiplicity(m, path, name):
    """Plot multiplicityMap.

    :param np.array m: multiplicityMap.
    :param str path: Where to save figure.
    :param str name: Name of partition.
    """

    m = normalizeImageDim(m)

    fig, ax = plt.subplots()
    im = ax.imshow(m, cmap='Blues', vmin=0)
    vals = np.unique(m)
    fig.colorbar(im,
                 ticks=[0] + list(vals[::(len(vals) // 10) + 1]),
                 fraction=0.02,
                 pad=0.04)
    ax.set_xticks(np.arange(0, m.shape[1], m.shape[1] // 5 + 1))
    ax.set_yticks(np.arange(0, m.shape[0], m.shape[0] // 5 + 1))
    ax.set_title('Multiplicity map of input to {}'.format(name))
    ax.tick_params(which='both', left=False, bottom=False)
    ax.xaxis.set_minor_locator(IndexLocator(1, 1))
    ax.yaxis.set_minor_locator(IndexLocator(1, 1))
    ax.grid(which='minor')
    fig.savefig(os.path.join(path, 'multiplicityMap_{}'.format(name)),
                bbox_inches='tight')
コード例 #3
0
def plot_coreIdMap(m, path, name):
    """Plot coreIdMap.

    :param np.array m: coreIdMap.
    :param str path: Where to save figure.
    :param str name: Name of partition.
    """

    yy = normalizeImageDim(m)
    shape = yy.shape

    fig, ax = plt.subplots()
    im = ax.imshow(yy, cmap='Blues', vmin=0)
    vals = np.unique(yy)
    fig.colorbar(im,
                 ticks=vals[::len(vals) // 10 + 1],
                 fraction=0.02,
                 pad=0.04)
    ax.set_xticks(np.arange(0, shape[1], shape[1] // 5 + 1))
    ax.set_yticks(np.arange(0, shape[0], shape[0] // 5 + 1))
    ax.tick_params(which='both', left=False, bottom=False)
    ax.xaxis.set_minor_locator(IndexLocator(1, 1))
    ax.yaxis.set_minor_locator(IndexLocator(1, 1))
    ax.grid(which='minor')

    if m.ndim == 3:
        num_depth_partitions = len(np.unique(m[0, 0, :]))
        num_channels = m.shape[-1]
        s = '' if num_depth_partitions == 1 else 's'
        ss = '' if num_channels == 1 else 's'
        ax.set_title('Core ID map of layer {}\n({} partition{} along '
                     '{} channel{}.)'.format(name, num_depth_partitions, s,
                                             num_channels, ss))
    else:
        ax.set_title('Core ID map of layer {}'.format(name))

    fig.savefig(os.path.join(path, 'partition_{}'.format(name)),
                bbox_inches='tight')