This is a bash script that uses a variety of other scripts, as well as some generally useful shell script methods. An image is displayed using some nice auto-scaling features. The user can mark approximate circle apertures, and then a refined cenetering is performed. The final X,Y values are written to a file.
ds9_set_xy 20150117T051556.5_cat_sci.fits 9 20 3 Usage: ds9_set_xy a.fits 6.0 20 3 arg1 - input FITS image name arg2 - sigma-level for image scaling arg3 - search radius in pixels arg4 - centering radius (Integer,pixels)When this finishes, the file "20150117T051556.5_cat_sci.xy" will contain the centered positions that the user set. Because this is a generally useful script, I reproduce the (Jan23,2015) code below. Notice that I use a bash string replacment convention to get the name of the XY output file.
#!/bin/bash
# Check command line args
if [ -z "$1" ]
then
printf 'Usage: ds9_set_xy a.fits 6.0 20 3\n'
printf "arg1 - input FITS image name \n"
printf "arg2 - sigma-level for image scaling \n"
printf "arg3 - search radius in pixels \n"
printf "arg4 - centering radius (Integer,pixels) \n"
exit
fi
if [ -z "$2" ]
then
printf "arg2 - sigma-level for image scaling \n"
exit
fi
if [ -z "$3" ]
then
printf "arg3 - search radius in pixels \n"
exit
fi
if [ -z "$4" ]
then
printf "arg4 - centering radius (Integer,pixels) \n"
exit
fi
# Reassign some argument names
Rsearch="$3"
IRcen="$4"
listxy="$5"
printf "Rsearch = $Rsearch\n"
printf "IRcen = $IRcen\n"
#------------------------------------------------------
# Make a filename for the output file
fitsin="$1"
newname=${fitsin/.fits/.xy}
#printf "Name of xy file will be: $newname\n\n\n"
#------------------------------------------------------
# Open the ds9 tool
ds9_open 800 800
# View the image
imlook $1 $2
# Allow user to draw markers, enter key when done, and
# then build the "id.objects" file
printf "Mark apertures around stars.\n"
printf "Enter any key when done with marking.\n"
read NEW_STRING
# Save the regions and create a simple ASCII xy file
xpaset -p ds9 regions save ds9_save2.reg
ds9regget.sh ds9_save2.reg circle any >list_1.xy
#
clip_boxcen.sh $1 list_1.xy $Rsearch $IRcen listOUT
xy2circ_reg listOUT 5 yellow > new.reg
cat new.reg | xpaset ds9 regions -format ds9
# make the final (blah.xy) XY file
mv listOUT $newname
# close the ds9 window
printf "\nClose the ds9 window? (Y/n):"
read Final_Answer
if [ "$Final_Answer" = "Y" ]
then
printf "Deleting the ds9 window. Goodbye.\n"
xpaset -p ds9 exit
else
printf "Goodbye.\n"
fi
\rm -f cih.explain cih.stndout ds9_save2.reg list_1.xy new.reg tmp1