0

I've got 2 .FITS images. One is an image of some stars and galaxies. The other is a significance map that I want to plot over it, as a contour. PyWCSGrid2 is the python module to do this in, but I've tried to overlay one on the other for a while and I can't get them both to show up at the same time. Any ideas why this isn't working?

import matplotlib.pyplot as plt
import sys
import pyfits
import pywcsgrid2
from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable


imagename=str("example1.fits")

def setup_axes():
ax = pywcsgrid2.subplot(111, header=f_radio[0].header)
return ax

# GET IMAGE1
data = f_radio[0].data #*1000
ax = setup_axes()

# prepare figure & axes
fig = plt.figure(1)

#GET CONTOUR SOURCE:
f_contour_image = pyfits.open("IMAGE2.fits")
data_contour = f_contour_image[0].data

# DRAW CONTOUR
cont = ax.contour(data_contour, [5, 6, 7, 8, 9],
                   colors=["r","r","r", "r", "r"], alpha=0.5)

# DRAW IMAGE
im = ax.imshow(data, cmap=plt.cm.gray, origin="lower", interpolation="nearest",alpha=1.0)
plt.show()

UPDATE: The issue seems to be that the two images have different scales, so it actually IS plotting the contours, but they are tiny and waaaay in the bottom left corner. I need to rescale them somehow.

Astro_Dart
  • 175
  • 1
  • 1
  • 7
  • 1
    If you continue to have issues, you may want to consider trying APLpy (http://aplpy.github.io/) or WCSAxes (http://wcsaxes.readthedocs.org/en/latest/) – astrofrog Mar 21 '15 at 16:14
  • Thanks. I'm aware of those, but I'm close to being done with a big project, and I'd have to update some software to make those work, and I don't have the time in case it breaks some of the other (homebuilt) tools I need. – Astro_Dart Mar 22 '15 at 16:54

1 Answers1

1

It's possible that you are drawing the contour bellow the image? You are doing this:

# DRAW CONTOUR
cont = ax.contour(data_contour, [5, 6, 7, 8, 9],
                   colors=["r","r","r", "r", "r"], alpha=0.5)

# DRAW IMAGE
im = ax.imshow(data, cmap=plt.cm.gray, origin="lower", interpolation="nearest",alpha=1.0)
plt.show()

But I thing this can be better:

# DRAW IMAGE
im = ax.imshow(data, cmap=plt.cm.gray, origin="lower",interpolation="nearest",alpha=1.0)
# Overlay -> DRAW CONTOUR
cont = ax.contour(data_contour, [5, 6, 7, 8, 9],
                   colors=["r","r","r", "r", "r"], alpha=0.5)
plt.show()

I hope it helps.

JoseM LM
  • 333
  • 1
  • 7