Read a ds9 marker file and extract the X,Y,Text values for markers of a specified color and type. You can use "any" for a color and/or type if you want to pull anything.
% cat test1.reg # Region file format: DS9 version 4.1 # Filename: a.fits global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1 physical circle(793,1118,20.1409) # text={1} circle(1141,935,20) # color=yellow text={2} circle(1082,1104,20) # color=cyan text={3} ellipse(911,1002,95,38,331.881) # color=white text={4 and all } circle(2082,1104,20) circle(3082,1104,20) circle(3082,1104,20) text={booty baby} % xyds9.sh test1.reg circle green Need local "log.make" for log file. % cat xyds9.xy 793.000 1118.000 "1 " circle green % xyds9.sh test1.reg ellipse any Need local "log.make" for log file. % cat xyds9.xy 911.000 1002.000 "4 and all " ellipse white % xyds9.sh test1.reg any any Need local "log.make" for log file. % cat xyds9.xy 793.000 1118.000 "1 " circle green 1141.000 935.000 "2 " circle yellow 1082.000 1104.000 "3 " circle cyan 911.000 1002.000 "4 and all " ellipse white
The simple file produced here (named xyds9.xy) can easily be read through the wcstools routine xy2sky. If I use the output file (xyds9.xy) used in the last example above, and the local image dss.fits, I can easily compute the RA,DEC asoociated with each XY value (according to the WCS in the header of dss.fits):
% cat xyds9.xy 793.000 1118.000 "1 " circle green 1141.000 935.000 "2 " circle yellow 1082.000 1104.000 "3 " circle cyan 911.000 1002.000 "4 and all " ellipse white % xy2sky dss.fits @xyds9.xy 12:40:41.390 +41:28:22.08 J2000 793.000 1118.000 12:39:48.472 +41:23:17.68 J2000 1141.000 935.000 12:39:57.656 +41:28:03.97 J2000 1082.000 1104.000 12:40:23.334 +41:25:07.31 J2000 911.000 1002.000 % xy2sky dss.fits @xyds9.xy > ra_dec.list % cat ra_dec.list 12:40:41.390 +41:28:22.08 J2000 793.000 1118.000 12:39:48.472 +41:23:17.68 J2000 1141.000 935.000 12:39:57.656 +41:28:03.97 J2000 1082.000 1104.000 12:40:23.334 +41:25:07.31 J2000 911.000 1002.000Notice that the original X,Y are tacked on to the output of xy2sky, however the format is not in rigid columns anymore. This is not a big deal really as I am reading these lines now mostly with shell scripts and python codes that are smart enough to handle this.
I have decided to have the output from xyds9 come to standard out, just like the other wcstools and things I am mostly using now. The point here is that when I use the xyds9 in a script, I can direct the output to a filename of my choosing there. I do not have to tie myself to a name like "xyds9.xy" or whatever. I also turned off the "log.make message". So, my new run would look something like:
% xyds9.sh test1.reg any any 793.000 1118.000 "1 " circle green 1141.000 935.000 "2 " circle yellow 1082.000 1104.000 "3 " circle cyan 911.000 1002.000 "4 and all " ellipse white