def correct_trend(trend):
    """Correct a indicator based trend model for closure (probabilities sum to 1.0).
    :param trend: ndarray [ny,nx,ncut]
    :return: nadarray [ny,nx,ncut] corrected for closure
    """
    ny = trend.shape[0]
    nx = trend.shape[1]
    ncut = trend.shape[2]
    for iy in range(0, ny):
        for ix in range(0, nx):
            sum = 0.0
            for ic in range(0, ncut):
                sum = sum + trend[iy, ix, ic]
            if sum > 0.0:
                for icut in range(0, ncut):
                    trend[iy, ix, ic] = trend[iy, ix, ic] / sum
    return trend
