The old way would not properly handle a situation where K_p values were all greater than 0.1. For example, if Kp = np.array([1, .5, .11]), then the old way of computing the index, Kpcutind = np.argmax(Kp <= 0.1) will return 0. In this case we want to have the "cutoff" be the entire array, not none of the array. To fix this, we change to np.nonzero(Kp > 0.1)[0][-1] + 1 which is the index of the last value in the array, plus 1.
If Kp = np.array([1, .5, .11, .1, .09, .01]), then the old and new approach both yield 3.
The old way would not properly handle a situation where K_p values were all greater than 0.1. For example, if
Kp = np.array([1, .5, .11])
, then the old way of computing the index,Kpcutind = np.argmax(Kp <= 0.1)
will return0
. In this case we want to have the "cutoff" be the entire array, not none of the array. To fix this, we change tonp.nonzero(Kp > 0.1)[0][-1] + 1
which is the index of the last value in the array, plus 1.If
Kp = np.array([1, .5, .11, .1, .09, .01])
, then the old and new approach both yield3
.