is there an equivalent of labview Threshold 1D Array Function: http://zone.ni.com/reference/en-XX/help/371361H-01/glang/threshold_1d_array/ in python?
Asked
Active
Viewed 564 times
1 Answers
1
I don't know of one as is, but it's a very small to write. You can wrap the following into a function
p = next(ii for ii,v in enumerate(x) if (v>=y))
frac=p-1.0+(float(y) - x[p-1])/(x[p]-x[p-1])
in the above, x
is the input dataset, y
is the value for which you want the fractional index. frac
is, well...
Small explanation: enumerate(x) makes an iterator that returns (index,value) from x
. So, they're what get put into ii,v
.

Dan
- 608
- 1
- 5
- 9