thanks @usdn for your reply.
By interval I mean all the consecutive elements higher than half-threshold, yes they are non-zero intervals.
Thanks for the suggestion, however, this is part of a larger project and introduce a new module like pandas or numba just for this issue, unfortunately is not a possible solution.
I can use numpy, scipy and pure Python.