def _apply_overall_clipping_threshold(power_ac,
                                      clipping_mask,
                                      clipped_power_ac):
    """
    Apply an overall clipping threshold to the data. This
    additional logic sets an overall threshold in the dataset
    where all points above this threshold are labeled as clipping
    periods.

    Parameters
    ----------
    power_ac : pandas.Series
        Pandas time series, representing PV system power or energy.
        For best performance, timestamps should be in local time.
    clipping_mask : pandas.Series
        Boolean mask of the AC power or energy time series, where clipping
        periods are labeled as True and non-clipping periods are
        labeled as False. Has a datetime index.
    clipped_power_ac: pandas.Series
        Pandas time series, representing PV system power or energy filtered
        where only clipping periods occur. Has a pandas datetime index.

    Returns
    -------
    clipping_mask : pandas.Series
        Boolean mask of clipping/non-clipping periods, after applying
        the overall clipping threshold to the mask. Clipping
        periods are labeled as True and non-clipping periods are
        labeled as False. Has a pandas datetime index.
    """
    upper_bound_pdiff = abs((power_ac.quantile(.99) -
                             clipped_power_ac.quantile(.99))
                            / ((power_ac.quantile(.99) +
                                clipped_power_ac.quantile(.99))/2))
    percent_clipped = len(clipped_power_ac)/len(power_ac)*100
    if (upper_bound_pdiff < 0.005) & (percent_clipped > 4):
        max_clip = (power_ac >= power_ac.quantile(0.99))
        clipping_mask = (clipping_mask | max_clip)
    return clipping_mask