title: Rescale a numpy array
body: <p>I have a 2D numpy array that represents a monochrome image from a CCD that has been binned 3x3 (that is, each value in the array represents 9 pixels (3x3) on the physical CCD).</p>
  
  <p>I want to rescale it to match the original CCD layout (so I can easily overlay it with a non-binned image from the same CCD).</p>
  
  <p>I saw <a href="https://stackoverflow.com/questions/13242382/resampling-a-numpy-array-representing-an-image">Resampling a numpy array representing an image</a>, but that doesn't seem to do what I want.</p>
  
  <p>Suppose I have an array g:</p>
  
  <pre><code>import numpy as np
  import scipy.ndimage
  
   g = np.array([[0, 1, 2],
                 [3, 4, 5],
                 [6, 7, 8]])
  </code></pre>
  
  <p>When I try to scale it by a factor of 2:</p>
  
  <pre><code>o = scipy.ndimage.zoom(g, 2, order=0)
  </code></pre>
  
  <p>I get exactly what I expect - each value is now 2x2 identical values:</p>
  
  <pre><code>array([[0, 0, 1, 1, 2, 2],
         [0, 0, 1, 1, 2, 2],
         [3, 3, 4, 4, 5, 5],
         [3, 3, 4, 4, 5, 5],
         [6, 6, 7, 7, 8, 8],
         [6, 6, 7, 7, 8, 8]])
  </code></pre>
  
  <p>But when I try to scale by a factor of 3, I get this:</p>
  
  <pre><code>o = scipy.ndimage.zoom(g, 3, order=0)
  </code></pre>
  
  <p>Gives me:</p>
  
  <pre><code>array([[0, 0, 1, 1, 1, 1, 2, 2, 2],
         [0, 0, 1, 1, 1, 1, 2, 2, 2],
         [3, 3, 4, 4, 4, 4, 5, 5, 5],
         [3, 3, 4, 4, 4, 4, 5, 5, 5],
         [3, 3, 4, 4, 4, 4, 5, 5, 5],
         [3, 3, 4, 4, 4, 4, 5, 5, 5],
         [6, 6, 7, 7, 7, 7, 8, 8, 8],
         [6, 6, 7, 7, 7, 7, 8, 8, 8],
         [6, 6, 7, 7, 7, 7, 8, 8, 8]])
  </code></pre>
  
  <p>I wanted each value in the original array to become a set of 3x3 values...that's not what I get.</p>
  
  <p>How can I do it?  (And why do I get this unintuitive result?)</p>