import math


def calculate_subplot_dims(num_elements):
    """
    Calculates the subplot dimentions based on the number of channels
    that we're going to be plotting.
    :param num_elements: The number of channels that need plotted.
    :return: A dictionary containing the calculated subplot dimensions
    """
    square_dim = int(math.sqrt(math.pow(math.ceil(math.sqrt(num_elements)), 2)))
    pad = square_dim ** 2 - num_elements
    if pad == 0:
        rows = square_dim
    else:
        pad = pad - square_dim
        rows = int((num_elements + pad) / square_dim)
    return {
        "rows": rows,
        "cols": square_dim,
        "pad": pad
    }