<p>If you have the WCS for both images, you can use the <a href="https://reproject.readthedocs.io/en/stable/" rel="nofollow noreferrer">astropy reproject module</a>. Once you have projected image 1 onto image 2, the <code>(x,y)</code>th pixel from the output will correspond to the <code>(x,y)</code>th pixel from image 2. </p>

<p>Then you can <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html" rel="nofollow noreferrer">flatten</a> both images with numpy, and assemble them into a 2-column array. </p>

CC BY-SA 4.0
2020-01-07T09:07:41.110Z
2020-01-07T09:07:41.110Z
usernumber
<p>I have two images of NGC 6946:</p>

<pre><code>item       description        size (pixels)    scale (arcseconds/pixel)
 1.     70 micron MIPS FITS     241 x 241           4.5 
 2.     20 cm VLA FITS          512 x 512           2.0  
</code></pre>

<p>I need to create a matrix with 2 columns (70 micron vs 20 cm), where each column will store the values at each pixel in such a way that the central pixel coordinate of each image coincides, so that I can plot for Radio/FIR correlation. </p>

<p>How should I perform such task in python?</p>

CC BY-SA 4.0
2019-11-19T08:03:40.223Z
I've added the `astropy` tag on the off chance that it will apply. Do you want to interpolate one image to fit the other, since their pixel sizes aren't 1:1? Will you need to rotate one image to match the other as well? I reformatted a bit, feel free to edit further or roll-back.
uhoh
CC BY-SA 4.0
2019-11-19T09:15:08.497Z
Thank you for formatting my question. I will keep this method in mind. Returning to the problem at hand, I want to create a 70 micron intensity (Jy) vs 20 cm intensity (Jy) plot and fit a curve through those points.
user30981
CC BY-SA 4.0
2019-11-19T12:24:22.030Z
Right, you are hoping for pixel-for-pixel matching so that you can look for a correlation. They have different scales, so you'll need to at least interpolate first, since the pixel scales are different, (roughly 9:4). Is there some rotation difference, or are they both oriented exactly the same way (e.g. North = up)?
uhoh
CC BY-SA 4.0
2019-11-22T06:17:35.803Z
Do the images have world co-ordinate system (WCS) in their headers?
TazAstroSpacial
CC BY-SA 4.0
2019-12-17T00:17:53.240Z
Yes. Thank you. I have already done it.
user30981
<radio-astronomy><astropy>
Creating a 2D matrix from 2 FITS images of unequal dimensions for Radio/FIR correlation
user30981
# Creating a 2D matrix from 2 FITS images of unequal dimensions for Radio/FIR correlation

(Asked by: username_0 on 2019-11-19)

I have two images of NGC 6946:
item       description        size (pixels)    scale (arcseconds/pixel)
 1.     70 micron MIPS FITS     241 x 241           4.5 
 2.     20 cm VLA FITS          512 x 512           2.0  

I need to create a matrix with 2 columns (70 micron vs 20 cm), where each column will store the values at each pixel in such a way that the central pixel coordinate of each image coincides, so that I can plot for Radio/FIR correlation. 
How should I perform such task in python?

**Tags:** radio-astronomy, astropy
> **Comments:**
> **username_1**: I've added the `astropy` tag on the off chance that it will apply. Do you want to interpolate one image to fit the other, since their pixel sizes aren't 1:1? Will you need to rotate one image to match the other as well? I reformatted a bit, feel free to edit further or roll-back.  
> **username_0**: Thank you for formatting my question. I will keep this method in mind. Returning to the problem at hand, I want to create a 70 micron intensity (Jy) vs 20 cm intensity (Jy) plot and fit a curve through those points.  
> **username_1**: Right, you are hoping for pixel-for-pixel matching so that you can look for a correlation. They have different scales, so you'll need to at least interpolate first, since the pixel scales are different, (roughly 9:4). Is there some rotation difference, or are they both oriented exactly the same way (e.g. North = up)?  
> **username_2**: Do the images have world co-ordinate system (WCS) in their headers?  
> **username_0**: Yes. Thank you. I have already done it.  

---

## 1 answers

### Answer by username_3 on 2020-01-07. Score: 1

If you have the WCS for both images, you can use the [astropy reproject module](https://reproject.readthedocs.io/en/stable/). Once you have projected image 1 onto image 2, the `(x,y)`th pixel from the output will correspond to the `(x,y)`th pixel from image 2.

Then you can [flatten](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html) both images with numpy, and assemble them into a 2-column array.


---

