def _restrict_model_parameters(param, sc_dir):
    """Restrict model parameters.

    Parameters
    ----------
    param : ndarray
        Model parameter to restrict.

    sc_dir : int
        Direction of semicoarsening.

    Returns
    -------
    out : ndarray
        Restricted model parameter.

    """
    # Only sum the four cells in y-z-plane
    if sc_dir == 1:
        out = param[:, :-1:2, :-1:2] + param[:, 1::2, :-1:2]
        out += param[:, :-1:2, 1::2] + param[:, 1::2, 1::2]

    # Only sum the four cells in x-z-plane
    elif sc_dir == 2:
        out = param[:-1:2, :, :-1:2] + param[1::2, :, :-1:2]
        out += param[:-1:2, :, 1::2] + param[1::2, :, 1::2]

    # Only sum the four cells in x-y-plane
    elif sc_dir == 3:
        out = param[:-1:2, :-1:2, :] + param[1::2, :-1:2, :]
        out += param[:-1:2, 1::2, :] + param[1::2, 1::2, :]

    # Only sum the two cells in x-direction
    elif sc_dir == 4:
        out = param[:-1:2, :, :] + param[1::2, :, :]

    # Only sum the two cells y-direction
    elif sc_dir == 5:
        out = param[:, :-1:2, :] + param[:, 1::2, :]

    # Only sum the two cells z-direction
    elif sc_dir == 6:
        out = param[:, :, :-1:2] + param[:, :, 1::2]

    # Standard: Sum all 8 cells.
    else:
        out = param[:-1:2, :-1:2, :-1:2] + param[1::2, :-1:2, :-1:2]
        out += param[:-1:2, :-1:2, 1::2] + param[1::2, :-1:2, 1::2]
        out += param[:-1:2, 1::2, :-1:2] + param[1::2, 1::2, :-1:2]
        out += param[:-1:2, 1::2, 1::2] + param[1::2, 1::2, 1::2]

    return out