#!/bin/sh # imsex: run SExtractor on a FITS image # By Doug Mink, Smithsonian Astrophysical Observatory # November 10, 2009 wcsbin=/data/oir/wcs/bin.redhat if test $# = 0 then echo "imsex: Run SExtractor on a FITS image and return objects in DAOFIND x y mag" echo " usage: imsex file.fits returns image coordinates in file.sex" echo " -v note progress" echo " -m extract objects from all images in multi-extension file" echo " -n number of brightest objects to return (default is 100)" exit fi if test $1 = 'help' then echo "Run SExtractor on a FITS image and return brightest objects in DAOFIND x y mag" echo "-v note progress" echo "-n number of brightest objects to return (default is 100)" exit fi if test $1 = "-v" then v=1 shift else v= fi if test $1 = "-m" then m=1 shift else m= fi if test $1 = "-n" then s=$2 shift shift else s=100 fi f=$1 g=`echo $f | grep ,` if test $g then r=`$wcsbin/fileroot $1` echo $f '->' $r elif test $m then n=1 r=$f f=$r,$n else r=$f fi while test -r $r do if test $m then if test $v then e=`$wcsbin/imrot -v $f` else e=`$wcsbin/imrot $f` fi elif test $g then if test $v then e=`$wcsbin/imrot -v $f` else e=`$wcsbin/imrot $f` fi else e=$f fi if test $e then echo $f '->' $e if test $v then echo Running SExtractor on $e fi $wcsbin/sex -c default.sex $e f=`$wcsbin/filename $e` c=`$wcsbin/fileroot $f`.sex n=`wc -l test.cat` if test $v then echo Saving $s brightest of $n objects in $c fi sort -n --k=3 test.cat | head -$s > $c /bin/rm test.cat if test $m then n=`expr $n + 1` f=$r,$n elif test $# = 0 then exit else shift g=`echo $1 | grep ,` if test $g then f=`$wcsbin/fileroot $1` else f=$1 fi echo $f fi else exit fi done # May 2 2000 Use fileroot and filename instead of root and fname # Sep 12 2000 Fix help if no arguments # Sep 15 2000 Add extraction of single image from multi-extension file # Jul 4 2004 Change pathnames for Redhat Linux # Nov 14 2005 Make all executable pathnames explicit # Nov 14 2005 Print number of objects found if in verbose mode # Nov 10 2009 Change magnitude sort argument from +2.0 to --k=3 # Nov 10 2009 Change pathnames to wcsbin$