sphere2dice.py
def _process_fig(create_patch, patch, scalars, _is_right, xz_rotation,
                 patch_labels=None):
    """
    Plotting this figure is just for verbosity/debugging purposes.
    It creates a 3x5 subplot of 5 figures displaying the generation process.
    """

    def _norm_axes(ax, _is_right: False):
        """ Applies default formatting for 3D objects
        :param ax: matplotlib.pyplot.axis object
        :param _is_right: boolean used for more accurate axis labeling
        """
        # Note that we flipped the coordinates
        flipped = ''
        if _is_right:
            flipped = '-'

        ax.set_xlabel(flipped + 'x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')
        ax.set_xlim([-1, 1])
        ax.set_ylim([-1, 1])
        ax.set_zlim([-1, 1])
        ax.set_aspect('auto')

    # Retrieve data stored in wrapper
    spheres_r, spheres_f, s = create_patch()
    # Get neutral sphere
    x, y, z = np.split(spheres_r[(False, (0, 0))], 3, axis=1)
    # Get rotated sphere
    d, x_d, z_d = spheres_f[(_is_right, xz_rotation)]
    _n_patches = len(set(rotations for _, rotations in spheres_r))

    # Keep track of which data point corresponds with which patch
    patch_bool = np.logical_and(np.abs(x_d) <= s, np.abs(z_d) <= s)
    if patch_labels is None:
        # On first loop, convert current label to integer
        patch_labels = patch_bool.astype(int)
    else:
        # On subsequent loops, add current label to integer list.
        patch_labels[patch_bool] = np.max(patch_labels) + 1

    # Subplot 1: Original spherical data
    fig = plt.figure(figsize=(12, 8))
    ax1 = fig.add_subplot(2, 3, 1, projection='3d')
    ax1.scatter(xs=x, ys=y, zs=z, c=scalars, s=1, cmap='jet')
    _norm_axes(ax1, _is_right)
    ax1.set_title('Scalar sphere')

    # Subplot 2: Distance to sampling point
    ax2 = fig.add_subplot(2, 3, 2, projection='3d')
    sc1 = ax2.scatter(xs=x, ys=y, zs=z, c=d, s=1, cmap='inferno_r')
    _norm_axes(ax2, _is_right)
    ax2.set_title('Distance to patch center')
    fig.colorbar(sc1)

    # Subplot 3: 2D projected distance to sampling point
    ax3 = fig.add_subplot(2, 3, 3)
    ax3.scatter(x_d, z_d, c=scalars, s=1, cmap='jet')
    ax3.plot([-s, -s, s, s, -s], [-s, s, s, -s, -s], c='k')
    ax3.set_title('Distance to patch center and patch border')

    # Subplot 4: Selected patch on sphere
    ax4 = fig.add_subplot(2, 3, 4, projection='3d')
    ax4.scatter(xs=x, ys=y, zs=z, s=1, c=patch_labels,
                cmap='gist_stern', vmin=0, vmax=_n_patches)
    _norm_axes(ax4, _is_right)
    ax4.set_title('Patch domain')

    # Subplot 5: Content of captured patch
    ax5 = fig.add_subplot(2, 3, 5)
    ax5.imshow(patch, cmap='jet')
    ax5.set_title('Final {}x{} patch'.format(len(patch), len(patch)))

    fig.suptitle('Direction ' + str(xz_rotation) + ' from "{}"')

    # Return the figure handle, and patch labels assigned to each coordinate
    return fig, patch_labels

    Plotting this figure is just for verbosity/debugging purposes.
    It creates a 3x5 subplot of 5 figures displaying the generation process.
    
Plotting this figure is just for verbosity/debugging purposes.
It creates a 3x5 subplot of 5 figures displaying the generation process.
Plotting this figure is just for verbosity / debugging purposes . It creates a 3x5 subplot of 5 figures displaying the generation process .
def _process_fig(create_patch, patch, scalars, _is_right, xz_rotation,
                 patch_labels=None):
    def _norm_axes(ax, _is_right: False):
        flipped = ''
        if _is_right:
            flipped = '-'
        ax.set_xlabel(flipped + 'x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')
        ax.set_xlim([-1, 1])
        ax.set_ylim([-1, 1])
        ax.set_zlim([-1, 1])
        ax.set_aspect('auto')
    spheres_r, spheres_f, s = create_patch()
    x, y, z = np.split(spheres_r[(False, (0, 0))], 3, axis=1)
    d, x_d, z_d = spheres_f[(_is_right, xz_rotation)]
    _n_patches = len(set(rotations for _, rotations in spheres_r))
    patch_bool = np.logical_and(np.abs(x_d) <= s, np.abs(z_d) <= s)
    if patch_labels is None:
        patch_labels = patch_bool.astype(int)
    else:
        patch_labels[patch_bool] = np.max(patch_labels) + 1
    fig = plt.figure(figsize=(12, 8))
    ax1 = fig.add_subplot(2, 3, 1, projection='3d')
    ax1.scatter(xs=x, ys=y, zs=z, c=scalars, s=1, cmap='jet')
    _norm_axes(ax1, _is_right)
    ax1.set_title('Scalar sphere')
    ax2 = fig.add_subplot(2, 3, 2, projection='3d')
    sc1 = ax2.scatter(xs=x, ys=y, zs=z, c=d, s=1, cmap='inferno_r')
    _norm_axes(ax2, _is_right)
    ax2.set_title('Distance to patch center')
    fig.colorbar(sc1)
    ax3 = fig.add_subplot(2, 3, 3)
    ax3.scatter(x_d, z_d, c=scalars, s=1, cmap='jet')
    ax3.plot([-s, -s, s, s, -s], [-s, s, s, -s, -s], c='k')
    ax3.set_title('Distance to patch center and patch border')
    ax4 = fig.add_subplot(2, 3, 4, projection='3d')
    ax4.scatter(xs=x, ys=y, zs=z, s=1, c=patch_labels,
                cmap='gist_stern', vmin=0, vmax=_n_patches)
    _norm_axes(ax4, _is_right)
    ax4.set_title('Patch domain')
    ax5 = fig.add_subplot(2, 3, 5)
    ax5.imshow(patch, cmap='jet')
    ax5.set_title('Final {}x{} patch'.format(len(patch), len(patch)))
    fig.suptitle('Direction ' + str(xz_rotation) + ' from "{}"')
    return fig, patch_labels
def _process_fig ( create_patch , patch , scalars , _is_right , xz_rotation , patch_labels = None ) : def _norm_axes ( ax , _is_right : False ) : """ Applies default formatting for 3D objects
        :param ax: matplotlib.pyplot.axis object
        :param _is_right: boolean used for more accurate axis labeling
        """ flipped = '' if _is_right : flipped = '-' ax . set_xlabel ( flipped + 'x' ) ax . set_ylabel ( 'y' ) ax . set_zlabel ( 'z' ) ax . set_xlim ( [ - 1 , 1 ] ) ax . set_ylim ( [ - 1 , 1 ] ) ax . set_zlim ( [ - 1 , 1 ] ) ax . set_aspect ( 'auto' ) spheres_r , spheres_f , s = create_patch ( ) x , y , z = np . split ( spheres_r [ ( False , ( 0 , 0 ) ) ] , 3 , axis = 1 ) d , x_d , z_d = spheres_f [ ( _is_right , xz_rotation ) ] _n_patches = len ( set ( rotations for _ , rotations in spheres_r ) ) patch_bool = np . logical_and ( np . abs ( x_d ) <= s , np . abs ( z_d ) <= s ) if patch_labels is None : patch_labels = patch_bool . astype ( int ) else : patch_labels [ patch_bool ] = np . max ( patch_labels ) + 1 fig = plt . figure ( figsize = ( 12 , 8 ) ) ax1 = fig . add_subplot ( 2 , 3 , 1 , projection = '3d' ) ax1 . scatter ( xs = x , ys = y , zs = z , c = scalars , s = 1 , cmap = 'jet' ) _norm_axes ( ax1 , _is_right ) ax1 . set_title ( 'Scalar sphere' ) ax2 = fig . add_subplot ( 2 , 3 , 2 , projection = '3d' ) sc1 = ax2 . scatter ( xs = x , ys = y , zs = z , c = d , s = 1 , cmap = 'inferno_r' ) _norm_axes ( ax2 , _is_right ) ax2 . set_title ( 'Distance to patch center' ) fig . colorbar ( sc1 ) ax3 = fig . add_subplot ( 2 , 3 , 3 ) ax3 . scatter ( x_d , z_d , c = scalars , s = 1 , cmap = 'jet' ) ax3 . plot ( [ - s , - s , s , s , - s ] , [ - s , s , s , - s , - s ] , c = 'k' ) ax3 . set_title ( 'Distance to patch center and patch border' ) ax4 = fig . add_subplot ( 2 , 3 , 4 , projection = '3d' ) ax4 . scatter ( xs = x , ys = y , zs = z , s = 1 , c = patch_labels , cmap = 'gist_stern' , vmin = 0 , vmax = _n_patches ) _norm_axes ( ax4 , _is_right ) ax4 . set_title ( 'Patch domain' ) ax5 = fig . add_subplot ( 2 , 3 , 5 ) ax5 . imshow ( patch , cmap = 'jet' ) ax5 . set_title ( 'Final {}x{} patch' . format ( len ( patch ) , len ( patch ) ) ) fig . suptitle ( 'Direction ' + str ( xz_rotation ) + ' from "{}"' ) return fig , patch_labels
Plotting this figure is just for verbosity/debugging purposes.
Plotting this figure is just for verbosity / debugging purposes .
"""
    Plotting this figure is just for verbosity/debugging purposes.
    It creates a 3x5 subplot of 5 figures displaying the generation process.
    """ """ Applies default formatting for 3D objects
        :param ax: matplotlib.pyplot.axis object
        :param _is_right: boolean used for more accurate axis labeling
        """ # Note that we flipped the coordinates # Retrieve data stored in wrapper # Get neutral sphere # Get rotated sphere # Keep track of which data point corresponds with which patch # On first loop, convert current label to integer # On subsequent loops, add current label to integer list. # Subplot 1: Original spherical data # Subplot 2: Distance to sampling point # Subplot 3: 2D projected distance to sampling point # Subplot 4: Selected patch on sphere # Subplot 5: Content of captured patch # Return the figure handle, and patch labels assigned to each coordinate
create_patch
patch
scalars
_is_right
xz_rotation
patch_labels