def deflatten(array, window):
    """De-flatten 2D array to 3D, given window.

    Parameters
    ----------
    array: numpy.ndarray
        2D data to de-flatten.

    Returns
    -------
    deflat_array: numpy.ndarray
        3D deflattened data.
    """
    if array.ndim != 2:
        raise ValueError('array must be 2D')
    N, LM = array.shape
    if (LM / window) % 1 != 0:
        raise ValueError('invalid window size')
    return array.reshape(N, window, LM // window)