code: def windowed_run_events(da, window, dim='time'):
      
      d = rle(da, dim=dim)
      out = (d >= window).sum(dim=dim)
      return out
docs: Return the number of runs of a minimum length.
  
          Parameters
          ----------
          da: N-dimensional Xarray data array  (boolean)
            Input data array
          window : int
            Minimum run length.
          dim : Xarray dimension (default = 'time')
            Dimension along which to calculate consecutive run
  
          Returns
          -------
          out : N-dimensional xarray data array (int)
            Number of distinct runs of a minimum length.