2
votes

I am using aplypy to create an RGB image of the Eagle nebula from three FITS files, representing the red, green and blue components of the image. The FITS files are available here, 673nm being the red, 656nm the green and 502nm the blue.

import aplpy
aplpy.make_rgb_cube(['673nmos.fits','656nmos.fits','502nmos.fits'], 'nmod_cube.fits')
aplpy.make_rgb_image('nmod_cube.fits','nmod.png')

f = aplpy.FITSFigure('../data/nmod_cube_2d.fits')
f.show_rgb('../data/output/nmod.png')

The image should look something like this, but comes out looking like the image below. The blue component is clearly misaligned with the red and green.

Eagle nebula misaligned RGB

make_rgb_cube is supposed to realign the three images in to the same projection based on the WCS information in each FITS header, according to the docs, but it doesn't seem to be working in this case.

Do I need to employ a star matching library to get the alignment accuracy?

2
The shift seems to be pure translation. You could fix it by hand with a utility that separates the three color planes. (Or fix the bug in aplpy :) ) - Yves Daoust
@YvesDaoust could you suggest a utility? What do you mean by separating the colour planes? - christopherlovell
It may be that the WCS is simply off (I wouldn't expect it though, if these are reduced archival HST images). Have you checked the individual FITS images in a tool like DS9 (where you can match images by WCS and then blink them, or create a slightly more simplified RGB image as well)? - user707650
One thing to note is that the scattered light, like diffraction spikes, are physically wavelength dependent and may not match up because the light is bent slightly differently in the telescope so make sure you align on sources and not artifacts. - veda905

2 Answers

2
votes

There is an error in the WCS coordinates in the header of the Blue FITS file. I have contacted spacetelescope.org to alert them.

Another example from the site, of M17, is created correctly using the aplpy script shown in the question. Blinking through each filter using DS9, as suggested in the comments, confirms the correct alignment.

M17

1
votes

Use the STScI software TweakReg to align the images and get a good alignment before combining. More information and worked examples can be found on the DrizzlePac website.

TweakReg:

Combining images using astrodrizzle requires that the WCS information in the headers of each input image align to within sub-pixel accuracy. The tweakreg task allows the user to align sets of images to each other and/or to and external astrometric reference frame or image.

It is optimized for use with HST instruments, but can be adapted for other observatories/instruments.