html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/3896#issuecomment-605456013,https://api.github.com/repos/pydata/xarray/issues/3896,605456013,MDEyOklzc3VlQ29tbWVudDYwNTQ1NjAxMw==,9312831,2020-03-28T14:39:06Z,2020-03-28T14:39:06Z,NONE,">Minor comment / nit: you don't really need the astype(np.float), the result should already be of dtype float since there are missing values after the rolling sum.

You're right.  That is used for debuging the intermediate results.

Thanks again @keewis @max-sixty. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,588126763
https://github.com/pydata/xarray/issues/3896#issuecomment-605395619,https://api.github.com/repos/pydata/xarray/issues/3896,605395619,MDEyOklzc3VlQ29tbWVudDYwNTM5NTYxOQ==,9312831,2020-03-28T05:02:59Z,2020-03-28T05:02:59Z,NONE,"Hi @keewis, this is really a smart way, using `rolling` twice.  I've refactored the code slightly as:
```python
def continuous_meet(cond, count, dim):
    """"""
    Continuously meet a given condition along a dimension.
    """"""
    _found = cond.rolling(dim={dim:count},
                          center=True).sum().fillna(0).astype(np.float)
    
    detected = (
        _found.rolling(dim={dim:count}, center=True) 
        .reduce(lambda a, axis: (a == count).any(axis=axis)) 
        .fillna(False) 
        .astype(bool) 
    )
    
    if count % 2 == 0:
        return detected.shift({dim:-1}).fillna(False)
    
    return detected

sst = xr.DataArray(
    np.array(
        [0., 0., 0., 0., 0., 1., 1., 1., 1., 1.,
         0., 0., 1., 0., 0., 1., 1., 1., 1., 1.,
         1., 0., 0., 0.]
    ),
    dims=""time"",
    coords={""time"": np.arange(24)},
    name=""sst"",
)

ElNino = continuous_meet(sst > 0.5, count=5, dim='time')

sst.plot.step(linewidth=3)
sst.where(ElNino).plot.step(linewidth=2)
```
Note that when `count` is a even number, truly centered `rolling` cannot be obtained.  So we need to `shift` the result by -1.  Is this perfect?  I didn't check the performance.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,588126763
https://github.com/pydata/xarray/issues/3896#issuecomment-604776072,https://api.github.com/repos/pydata/xarray/issues/3896,604776072,MDEyOklzc3VlQ29tbWVudDYwNDc3NjA3Mg==,9312831,2020-03-27T02:01:54Z,2020-03-27T02:01:54Z,NONE,"Hi @max-sixty, thanks for your kind help.  But I found it works not as I expected.  If the SST has the values `[..., 0, 0, 1, 1, 1, 1, 1, 0, 0, ...]`, then the method you suggested will give `[..., F, F, F, F, T, F, F, F, F, ...]`.  That is only one `True` for a 5 consecutive 1s.  But I would expect five `True` like `[..., F, F, T, T, T, T, T, F, F, ...]`.  Any suggestion?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,588126763