title: Is there a way to stack multiple 2D (numpy) image arrays about a specified point?
body: <p>I need to stack many images that are represented by 2D numpy arrays of the same shape (i.e., take the sum or the median of them all). However, as I stack them, they need to be aligned properly -- each image, while the same shape, is all black with a small circular object around the center, but not exactly at the center. I can find the coordinates of the centroid for each image (using the module <code>SourceProperties.centroid</code> through the package <code>photutils</code>), but these coordinates will be different for each image -- they are also subpixel coordinates (example: <code>(y, x) = (203.018, 207.397)</code>).</p>
  
  <p>I do not know of a way to simply move the objects to the center of the arrays, given the centroids have subpixel coordinates, so it seems like it would be more straightforward if there was a way to align each one by their unique centroid coordinates as I stack them... in other words:</p>
  
  <pre><code>import numpy as np
  # First image = array1, shape = (400, 400)
  centroid1 = (203.018, 207.397)
  
  # Second image = array2, shape = (400, 400)
  centroid2 = (205.256, 199.312)
  
  array_list = [array1, array2]
  &gt;&gt;&gt; stacked = np.median(array_list, axis=0) # but while setting centroid1 = centroid2 so that the two centroid points exactly overlap while computing median
  </code></pre>
  
  <p>But I'm not really sure how this would look in code. Is this possible?</p>