title: Find plateau in Numpy array
body: <p>I am looking for an efficient way to detect plateaus in otherwise very noisy data. The plateaus are always relatively broad A simple example of what this data could look like:</p>
  
  <pre><code>test=np.random.uniform(0.9,1,100)
  test[10:20]=0
  plt.plot(test)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5ZV8D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ZV8D.png" alt="enter image description here"></a></p>
  
  <p>Note that there can be multiple plateaus (which should all be detected) which can have different values.</p>
  
  <p>I've tried using scipy.signal.argrelextrema, but it doesn't seem to be doing what I want it to:</p>
  
  <pre><code>peaks=argrelextrema(test,np.less,order=25)
  plt.vlines(peaks,ymin=0, ymax=1)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jsJHM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsJHM.png" alt="enter image description here"></a></p>
  
  <p>I don't need the  exact interval of the plateau- a rough range estimate would be enough, as long as that estimate is bigger or equal than the actual plateau range. It should be relatively efficient however.</p>