def findXAt(xArr, yArr, yVal, index=<NUM_LIT:0>, s=<NUM_LIT:0.0>):
if xArr[<NUM_LIT:1>] < xArr[<NUM_LIT:0>]:<EOL><INDENT>xArr = xArr[::-<NUM_LIT:1>]<EOL>yArr = yArr[::-<NUM_LIT:1>]<EOL><DEDENT>yArr = yArr - yVal<EOL>if len(yArr) < <NUM_LIT:5>:<EOL><INDENT>xn = np.linspace(xArr[<NUM_LIT:0>], xArr[-<NUM_LIT:1>], <NUM_LIT:5>)<EOL>yArr = np.interp(xn, xArr, yArr)<EOL>xArr = xn<EOL><DEDENT>f = interpolate.UnivariateSpline(xArr, yArr, s=s)<EOL>return f.roots()[index]<EOL>
index: position of root (return index=0 by default)

return all x values where y would be equal to given yVal
if arrays are spline interpolated