title: Google Earth Engine - counts days of the longest dry period in a time period
body: <p>I'm trying to map the max number of consecutive days with rain &lt;1 mm in Google Earth Engine. </p>
  
  <p>This is the link to the code</p>
  
  <p><a href="https://code.earthengine.google.com/22b5c20d2700a2ffb5989f892838ac58" rel="nofollow noreferrer">https://code.earthengine.google.com/22b5c20d2700a2ffb5989f892838ac58</a></p>
  
  <p>First I reclassify the collection with 0 if rain &lt;=1 and 1 if >1.
  Then I run the code that should count the days of the longest dry period, but it is able to do so only if the dry period reach the end of the time period.</p>
  
  <p>For instance if I am looking for the longest dry period in 4 days timestep i get the following series:</p>
  
  <pre><code>rain days 1 2 3 4   output
            0,0,1,1 = 0 dry days
            0,1,0,0 = 2 dry days
  0 = rain&lt;=1 and 
  1 = rain&gt;1 (as per the first step)
  </code></pre>
  
  <p>Does anyone can help in solving this?
  Thanks</p>