def calcDownscaleFactor(P_REQ, p_max_values, downsc_coeffs, dsc_v_split,
    p_rated, v_max, f_downscale_threshold):
    """Check if downscaling required, and apply it.

    :return: (float) the factor

    @see: Annex 1-7, p 68
    """
    p_req_max = P_REQ[p_max_values[0]]
    r_max = p_req_max / p_rated
    if dsc_v_split is not None:
        assert len(downsc_coeffs) == 2, downsc_coeffs
        downsc_coeffs = downsc_coeffs[0
            ] if v_max <= dsc_v_split else downsc_coeffs[1]
    if downsc_coeffs is None:
        f_downscale = 0
    else:
        r0, a1, b1 = downsc_coeffs
        if r_max < r0:
            f_downscale = 0
        else:
            f_downscale = a1 * r_max + b1
            f_downscale = round(f_downscale, 1)
            if f_downscale <= f_downscale_threshold:
                f_downscale = 0
    return f_downscale
