Lucidnonsense
Lucidnonsense

Reputation: 1243

Getting image from Fits files from SDSS DR10

Basically I just want to get the image data from the r-waveband fits file found here using pyfits that has been incorporated into astropy. Here is my attempt:

from astropy.io import fits
import matplotlib.pyplot as plt

hdulist = fits.open("frame-r-004646-1-0019.fits")
hdulist.info()

imgplot = plt.imshow(hdulist[0].data)
imgplot.set_cmap('binary_r')

plt.show()
hdulist.close()

Currently, I can only see tiny little dots instead of the the bright stars seen in the jpeg image. Also, the ImageHDU doesn't contain an image (it can't since it is a 1D array) Any idea why this is?

Finally, I'm attempting to identify my target galaxy in this image from (ra, dec). The fits file has a (ra, dec) associated with it and a Pixel scale of 0.396 arcsec per pixel. So I'd like to know which corner the incorporated (ra, dec) is talking about so I can extrapolate the position of the target within the image!

Upvotes: 0

Views: 846

Answers (1)

mdurant
mdurant

Reputation: 28673

You'll want some decent colour normalisation, like this:

imshow(im,vmin=np.percentile(im,5),vmax=np.percentile(im,95),cmap='gray')

where im=hdulist[0].data

For rendering the WCS, I recommend you use aplpy, if you are staying clear of a real viewer such as ds9.

gc = aplpy.FITSFigure("frame-r-004646-1-0019.fits")
gc.show_grayscale(vmin=np.percentile(im,5),vmax=np.percentile(im,95))

Upvotes: 3

Related Questions