def _adjust_for_thermal(data, filt_method=lambda x: x, thresh=0.9, window=5000, tdiff_threshold=10000):
    n = filt_method(data)
    n = n[~np.isnan(n)]  # pylint: disable=no-member

    d = np.diff(n)  # pylint: disable=no-member
    d = d[~np.isnan(d)]  # pylint: disable=no-member
    dmin = min(d)
    dmax = max(d)

    index_up = np.max((d > dmax * thresh).nonzero())  # pylint: disable=no-member
    index_down = np.min((d < dmin * thresh).nonzero())  # pylint: disable=no-member
    low_average = np.average(n[index_up:index_up + window])  # pylint: disable=no-member
    high_average = np.average(n[index_down - window:index_down])  # pylint: disable=no-member
    if low_average > high_average or index_down - index_up < tdiff_threshold:
        return 0
    else:
        return low_average
dataset/ETHPy150Open ARM-software/workload-automation/wlauto/instrumentation/energy_model/__init__.py/_adjust_for_thermal/original