Plotting catalogs over FITS images in ds9

I wanted to plot the locations of BOSS DR12 galaxy positions on top of the map of the CMB I’m currently working with. I didn’t find an easy example of this online, so here’s the simplest method I’ve found to do this, using “regions” in SAOImage DS9. I’m using version 7.5.

I started with a FITS map, let’s call it “map.fits,” and lists of ra and dec coordinates of the galaxy positions converted into “physical” coordinates in the map. That is, I had x and y coordinates in pixel space. I believe this can also be done using ra and dec positions, toggling the wcs coordinate type when you load the .reg file in step 3). To overplot these positions on the map:

1) Save x and y coordinates in a text file. I was using python and already had my rapixels and decpixels lists:

>> import numpy as np
>> coords=np.array([rapixels,decpixels])
>> coords=coords.T
>> np.savetxt(‘coords.txt’, coords, delimiter=’,’, newline=’\n’)

2) In a text editor, edit the text file into a .reg file for ds9 to read in. I started with

1.51775e+04,1.0865e+03
1.51655e+04,1.0895e+03

1.02205e+04,1.1375e+03

and ended with

point(1.51775e+04,1.0865e+03) # point=circle 1
point(1.51655e+04,1.0895e+03) # point=circle 1

point(1.02205e+04,1.1375e+03) # point=circle 1

and saved the .txt file as a .reg file. There are many options for plotting, you can find them all here: http://ds9.si.edu/doc/ref/region.html

3) Open the .fits map, then overplot the .reg file:

>> ds9 map.fits

Scale and zoom into your map as desired. Hit the “region” tab. Under “region,” hit “load.” Navigate to your .reg file and hit “ok.” Hit “ok” again. Your points should now be plotted!

Screen Shot 2017-05-04 at 2.55.52 PM

2 thoughts on “Plotting catalogs over FITS images in ds9

Comments are closed.