title: Using OR to reduce a 3D boolean array to 2D
body: <p>I have a 3D boolean array <code>(5830L, 6447L, 4L)</code> which I want to reduce to <code>(5830L, 6447L)</code> by using <code>OR</code> boolean operator across the 3rd dimension <code>(4L)</code>. Therefore I will be doing an element by element comparison of <code>4L</code> 2D arrays. A simple 1D example would be something like:</p>
  
  <pre><code>a = [True, False, True]
  b = [False, False, True]
  c = [True, False, True]
  mask = [any(tup) for tup in zip(a, b, c)]
  print mask
  'True, False, True'
  </code></pre>
  
  <p>The size of the 3rd dimension can vary, so I need to run it in a <code>for</code> loop or run it in such a way that the size of the 3rd dimension isn't hardcoded as it is above.
  <code>numpy.logical_or(a, b)</code> works well, but only for 2 array elements (<code>2L</code>).</p>
  
  <p>Any ideal how to do this when its 3 or more elements; i.e. the 3rd dimension is > <code>2L</code>?</p>