2

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?

christopherlovell
  • 3,800
  • 4
  • 19
  • 26
  • 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 :) ) –  Apr 05 '16 at 10:37
  • @YvesDaoust could you suggest a utility? What do you mean by separating the colour planes? – christopherlovell Apr 05 '16 at 10:39
  • Maybe this: http://imagej.net/Align_RGB_planes –  Apr 05 '16 at 10:43
  • A Python only solution would be preferable, especially over a dedicated Java program + plugin that hasn't been updated for nearly 10 years. Thanks for the suggestion though. I take it that by 'separating the three colour planes' you mean just translating each layer individually until they line up. – christopherlovell Apr 05 '16 at 11:04
  • 3
    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)? –  Apr 05 '16 at 12:14
  • @Evert thanks for the suggestion. I loaded each image in to DS9, overlayed a coordinate grid and blinked through them, and the blue image has an offset coordinate grid with respect to the red and green images. Really strange. I'll try another image from the same source and see if the error is consistent – christopherlovell Apr 05 '16 at 14:56
  • If the blue image has a WCS offset compared to the other two images, you may want to check if there's a contact address /helpdesk and inform the; perhaps the people there know of better calibrated images. Otherwise, it'll be up to yourself to recalibrate the blue image I'm afraid. –  Apr 05 '16 at 22:30
  • 1
    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 Jul 06 '16 at 14:46

2 Answers2

2

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

christopherlovell
  • 3,800
  • 4
  • 19
  • 26
  • STWCS is on github https://github.com/spacetelescope/stwcs. Start an issue there for a quicker response. – veda905 Aug 15 '17 at 15:03
1

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.

veda905
  • 782
  • 2
  • 12
  • 32