import math


def stPlotFrom3Dmat(array3D, rowChoice = None, colChoice = None):
    """
    This function creates a 2D space-time plot (needs to be colored later) from a 3D matrix.
    Will return error if input matrix is not 3D.

    Allows user to specify rowChoice or colChoice for the slicing.
    If neither rowChoice or colChoice is selected, will default to middle row.
    If both contain values, will default to rowChoice (essentially ignores colChoice).
    """

    if array3D.ndim != 3:  # If not a 3D array
        print("Error: input array is not 3 dimensional")
        return
    
    if not (rowChoice or colChoice):  # If neither are given values, go with middle row
        rowChoice = int(math.ceil(array3D.shape[0] / 2))

    if not rowChoice:  # If colChoice is selected
        return array3D[:, colChoice, :]

    else: 
        return array3D[rowChoice, :, :]