def maxzerodown(x):
 x = np.asarray(x)
 cond1 = (x[:(-1)] > 0)
 cond2 = (x[1:] < 0)
 allzeros = (np.nonzero(((cond1 & cond2) | (x[1:] == 0)))[0] + 1)
 if (x[(-1)] <= 0):
  maxz = max(allzeros)
 else:
  maxz = None
 return (maxz, allzeros)

def maxzerodown ( x ) : x = np . asarray ( x ) cond1 = ( x [ : ( - 1 ) ] > 0 ) cond2 = ( x [ 1 : ] < 0 ) allzeros = ( np . nonzero ( ( ( cond1 & cond2 ) | ( x [ 1 : ] == 0 ) ) ) [ 0 ] + 1 ) if ( x [ ( - 1 ) ] <= 0 ) : maxz = max ( allzeros ) else : maxz = None return ( maxz , allzeros )
find all up zero crossings and return the index of the highest not used anymore .