procedure tsex (mvSExt, testSExt, fstlst, sextLog, frm, imgFile, clnExtn, sumExtn, configFile, addExt, minArea, thresh, deblnd, filter, aperts, seeingFile, checkType, topEnd, CCDused, readSpeed, paramFile, execSExt, delExist, outputFile, awkNum, sortX, sortY, awkcount, delIndiv, exclOuter, Xc, Yc, rad, delUnix, prtExec, nameUnix) bool mvSExt {yes, prompt="Copy SExt files from home and proceed no further?"} bool testSExt {yes, prompt="Test SExtractor parameters on 1 image only?"} bool fstlst {yes, prompt=" Test on 1st image? (if not, then last)"} string sextLog {"log.14a8", prompt=" Name of test log file."} int frm {1, prompt=" Ximtool frame to display detections"} # bool tstpart {yes, prompt="Take only a sub-region of image(s)?"} # string tstreg {"[290:430,720:850]", prompt=" --> sub-region to use"} string imgFile {"list3", prompt="List of images (abbreviated names)"} string clnExtn {"us", prompt=" Detection: Extension appended to abbrev names"} string sumExtn {"gs", prompt=" Photometry: Extension appended to abbrev names"} string configFile {"peak.sex", prompt="SExtractor configuration file?"} bool addExt {yes, prompt="Use config parameters defined below?"} int minArea {20, prompt=" = DETECT_MINAREA"} real thresh {0.5, prompt=" = DETECT/ANALYSIS_THRESH"} real deblnd {0.0006, prompt=" = DEBLEND_MINCONT"} string filter {"5.0_9x9", prompt=" = Gaussian filter (?.?_?x? or list)"} string aperts {"4,8,12,20",prompt=" = PHOT_APERTURES (in pix, NO SPACES)"} string seeingFile {"avgGS.14a8", prompt=" = Seeing FWHM file (TFWHM output)"} string checkType {"NONE", prompt=" = CHECKIMAGE_TYPE (or APERTURES)"} string topEnd {"F/8", prompt=" AAT top end (F/8 or F/15)"} string CCDused {"TEK", prompt=" Detector used (TEK or MITLL2)"} string readSpeed {"NORMAL", prompt=" Read speed (FAST/NORMAL/SLOW)"} string paramFile {"peak.param", prompt="SExtractor parameter file?"} bool execSExt {yes, prompt="Execute SExtractor commands when formed?"} bool delExist {yes, prompt="Delete any existing SExt check images from this scan?"} string outputFile {"cat1.14a8",prompt="Output file name?"} bool awkNum {yes, prompt=" Have AWK add a slice-number column?"} bool sortX {yes, prompt=" Unix sort on X?"} bool sortY {yes, prompt=" Unix sort on Y?"} bool awkcount {yes, prompt=" Awk count of entries?"} bool delIndiv {yes, prompt="Delete individual catalogues when done?"} bool exclOuter {yes, prompt="Exclude detections outside circle?"} real Xc {470., prompt=" X-coord of circular aperture centre"} real Yc {505., prompt=" Y-coord of circular aperture centre"} real rad {440., prompt=" Radius of circular aperture"} bool delUnix {no, prompt="Delete Unix executable file when done?"} bool prtExec {no, prompt="Print Unix executable while running?"} string nameUnix {"exec.14a8", prompt=" Name of saved executable"} struct *flist # list-directed structure to go thru imageFile struct *clist # list-directed structure to go thru seeingFile begin # ################################################################# # # ASSUMES SEXTRACTOR INPUT FILES ARE SET AND READY TO USE. # # ################################################################# # Variable Declarations string shellLine # Unix line containing SExtractor command string clnImage # current CLEANED image (for detection) string sumImage # current SUMMED image (for photometry) string checkImage # current check image string checkImg # current check image (w/o fits extn) string currCat # current ASCII catalogue name string irafname # equivalent IRAF name of image (for wfits) string allCats # string containing the names of all catalogues string message # string containing message to be printed int sliceCounter # counts current slice number string awkLine1 # AWK line to print extra column of slice-no.s string awkLine2 # shell command line to re-name catalogue copy string detectline # includes previous image as detection template struct image # current image name (NO EXTENSIONS) real gain # CCD gain (e-/ADU) real pixScale # CCD pixel scale (arcsec/pix) real currSeeing # seeing FWHM of current image (in pix) real seeingArcsec # seeing FWHM for the input (detection) image string scanjnk # junk string used in scanning seeing values string c1 # first character of all filenames (for checking, since # FORTRAN will not read filenames beginning with a no.) real prev # previous seeing value in a scan to the end string logComment # comment to append to log if running tests string str1, str2 # junk strings if (filter=="list") { print(" ") print(" Listing available SExt gaussian filters...") print(" ") print(" ---> gauss_1.5_3x3.conv") print(" ---> gauss_2.0_3x3.conv") print(" ---> gauss_2.0_5x5.conv") print(" ---> gauss_2.5_5x5.conv") print(" ---> gauss_3.0_5x5.conv") print(" ---> gauss_3.0_7x7.conv") print(" ---> gauss_4.0_7x7.conv") print(" ---> gauss_5.0_9x9.conv") print(" ") print(" Choose one of these and re-run tsex.") print(" ") print(" Bye.") print(" ") bye } if (mvSExt==yes) { print(" ") print(" Copying SExtractor v2.0.0 files from home...") print(" ") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/peak* . print(" ---> peak.sex") print(" ---> peak.param") print(" ---> peak.nnw") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/sex . print(" ---> sex") print(" ") print(" Copying gaussian convolution filters (all sizes):") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_1.5_3x3.conv . print(" ---> gauss_1.5_3x3.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_2.0_3x3.conv . print(" ---> gauss_2.0_3x3.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_2.0_5x5.conv . print(" ---> gauss_2.0_5x5.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_2.5_5x5.conv . print(" ---> gauss_2.5_5x5.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_3.0_5x5.conv . print(" ---> gauss_3.0_5x5.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_3.0_7x7.conv . print(" ---> gauss_3.0_7x7.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_4.0_7x7.conv . print(" ---> gauss_4.0_7x7.conv") !cp /priv/magician8/dhj/programs/Bertin/Sex_v2.0.0/config/gauss_5.0_9x9.conv . print(" ---> gauss_5.0_9x9.conv") print(" ") } if (mvSExt==no) { # Make sure the IMAGES and DATAIO packages are loaded: if (! defpac ("images")) { print("IMAGES package not loaded") bye } if (! defpac ("dataio")) { print("DATAIO package not loaded") bye } # Checking for numeric starters in supplied file names: # (FORTRAN will not read such names if given as input!!) c1 = substr(outputFile, 1, 1) if ((c1=="0")||(c1=="1")||(c1=="2")||(c1=="3")|| (c1=="4")||(c1=="5")||(c1=="6")||(c1=="7")||(c1=="8")||(c1=="9")) { print("** ERROR: first character of 'outputFile' ("//outputFile//") is numeric **") print(" ") print(" --> Please change incorrect file name and re-run") print(" ") print (" Done.") print (" ") print (" ") bye } # Preparing input image file according to whether testing or not: if (testSExt==yes) { # delete (files="temp_tsex1",verify-,default+,go_ahead+) !/bin/rm temp_tsex1 if (fstlst==yes) { head (input_fi=imgFile,nlines=1, >> "temp_tsex1") } else { tail (input_fi=imgFile,nlines=1, >> "temp_tsex1") } # i.e. selected either 1st or last image for testing flist = "temp_tsex1" print (" ") print (" Performing a single-image test on the first image...") print (" ") } else { flist = imgFile # i.e. full image list } # Cleaning up files in preparation: # delete (files="executable.jnk", verify=no,default=yes,go_ahead=yes) !/bin/rm executable.jnk !/bin/rm temp_tsex2 print (" ") print ("-----------------------------------") print (" Creating Unix command files for:") print (" ") allCats = "" sliceCounter = 1 clist = seeingFile # Entering loop to create SExtractor commands for remaining images: while ( fscan(flist, image) != EOF) { # if (tstpart==yes) { # image=image//tstreg # } clnImage = image//clnExtn//".fits" sumImage = image//sumExtn//".fits" checkImage = image//"_check.fits" checkImg = image//"_check" currCat = image//".txt" allCats = allCats//" "//currCat # Deleting exisiting SExtractor output related to this image: if (delExist == yes) { imdelete (images=checkImg,verify=no,default=yes, go_ahead=yes) } awkLine1 = "awk '{print "//sliceCounter//", $0}'" awkLine1 = awkLine1//" "//currCat//" > awkjnk.txt" awkLine2 = "mv -f awkjnk.txt "//currCat # Examining image header (CLEAN) for more SExtractor input: # topEnd="UNDEFINED" # CCDused="UNDEFINED" # pixScale=0.0 # imgets(image=image//clnExtn,param="RO_GAIN") # gain = real(imgets.value) # imgets(image=image//clnExtn,param="TOPEND") # topEnd = imgets.value # imgets(image=image//clnExtn,param="DETECTOR") # CCDused = imgets.value # imgets(image=image//clnExtn,param="SPEED") # readSpeed = imgets.value if (CCDused=="TEK") { if (readSpeed=="FAST") { gain = 5.5 } if (readSpeed=="NORMAL") { gain = 2.74 } if (readSpeed=="SLOW") { gain = 1.36 } } if (CCDused=="MITLL2") { if (readSpeed=="FAST") { gain = 2.3 } if (readSpeed=="NORMAL") { gain = 1.11 } if (readSpeed=="SLOW") { gain = 0.366 } } if (topEnd=="F/8") { pixScale=0.594 } if (topEnd=="F/15") { pixScale=0.315 } if (CCDused=="MITLL2") { pixScale = pixScale*0.625 # i.e. ratio of CCD pixel sizes (15/24) } # i.e. 1K Tek values assumed initially; scaled for MIT-LL scanjnk = fscan(clist, currSeeing) if ((testSExt==yes)&&(fstlst==no)) { # i.e. if a test run and on the last image, scan thru seeing prev=currSeeing while ( fscan(clist, currSeeing) != EOF) { prev=currSeeing } currSeeing=prev } seeingArcsec = currSeeing*pixScale print(" ") print ("Detection: "//clnImage//" Photometry: "//sumImage) print("("//CCDused//" "//gain//" e/ADU "//topEnd//" "//pixScale//" arcsec/pix "//readSpeed//")") print("("//seeingArcsec//" arcsec = "//currSeeing//" pix seeing gauss"//filter//".conv)") print(" ") # Forming the Unix line to execute Sextractor for this image: shellLine = "sex "//clnImage//","//sumImage//" -c "//configFile shellLine = shellLine//" -CATALOG_NAME "//currCat shellLine = shellLine//" -PARAMETERS_NAME "//paramFile shellLine = shellLine//" -CHECKIMAGE_NAME "//checkImage shellLine = shellLine//" -CHECKIMAGE_TYPE "//checkType if (addExt==yes) { # i.e. add externally-defined config file parameters: shellLine=shellLine//" -DETECT_MINAREA "//minArea shellLine=shellLine//" -DETECT_THRESH "//thresh shellLine=shellLine//" -DEBLEND_MINCONT "//deblnd shellLine=shellLine//" -ANALYSIS_THRESH "//thresh shellLine=shellLine//" -FILTER_NAME gauss_"//filter//".conv" shellLine=shellLine//" -PHOT_APERTURES "//aperts # Following parameters derived indirectly: shellLine=shellLine//" -GAIN "//gain shellLine=shellLine//" -PIXEL_SCALE "//pixScale shellLine=shellLine//" -SEEING_FWHM "//seeingArcsec } print(shellLine, >> "executable.jnk") if (awkNum == yes) { print(awkLine1, >> "executable.jnk") print(awkLine2, >> "executable.jnk") } # i.e. if slice numbers are needed, awk commands are issued sliceCounter = sliceCounter+1 } shellLine = "/bin/rm "//outputFile print(shellLine, >> "executable.jnk") shellLine = "cat "//allCats//" > "//outputFile print(shellLine, >> "executable.jnk") # Excluding those objects outside aperture circle: if (exclOuter==yes) { print("Excluding all those objects outside aperture circle") print("---> Center("//Xc//","//Yc//"), rad = "//rad) if (awkNum==yes) { shellLine="awk '{x=$3-"//Xc//";y=$4-"//Yc//";r=sqrt(x*x+y*y); if (r<"//rad//") print $0}' "//outputFile//" > jnk.tmp" } else { shellLine="awk '{x=$2-"//Xc//";y=$3-"//Yc//";r=sqrt(x*x+y*y); if (r<"//rad//") print $0}' "//outputFile//" > jnk.tmp" } # i.e. altering awk command on the existence of the extra column print(shellLine, >> "executable.jnk") shellLine="/bin/rm "//outputFile//"; mv -f jnk.tmp "//outputFile print(shellLine, >> "executable.jnk") } # Unix rough-sort on x or y-coordinate: if (sortX == yes) { print(" ") print("Implementing a Unix sort of objects on x-coordinate") shellLine = "sort +1 -2 "//outputFile//" -o "//outputFile if (awkNum == yes) { shellLine = "sort +2 -3 "//outputFile//" -o "//outputFile } print(shellLine, >> "executable.jnk") } if (sortY == yes) { print(" ") print("Implementing a Unix sort of objects on Y-coordinate") shellLine = "sort +2 -3 "//outputFile//" -o "//outputFile if (awkNum == yes) { shellLine = "sort +3 -4 "//outputFile//" -o "//outputFile } print(shellLine, >> "executable.jnk") } if (delIndiv == yes) { shellLine = "/bin/rm "//allCats print(shellLine, >> "executable.jnk") print (" ") print ("Individual catalogues deleted.") } # Final lines of executable concatenate individual catalogues into # one big, unsorted catalogue, and then delete individual catalogues # if required. # if (testSExt==yes) { if (awkNum==yes) { shellLine = "awk '{print $3,$4,$2}' "//outputFile } else { shellLine = "awk '{print $2,$3,$1}' "//outputFile } shellLine = shellLine//" > temp_tsex2" print(shellLine, >> "executable.jnk") } # Generate an ID list for use with tvmark (below). if (awkcount == yes) { shellLine = "echo 'Total entries: ' ; " shellLine = shellLine//"awk '{a=a+1; print a}' "//outputFile shellLine = shellLine//" | tail -1 " print(shellLine, >> "executable.jnk") print (" ") } # shell/awk-script line to print number of entries in final catalogue if (execSExt==yes) { print ("-----------------------------------") print (" ") print (" Executing SExtractor commands ...") print (" ") !chmod 777 executable.jnk !executable.jnk if (prtExec==yes) { !ty executable.jnk } } else { print ("-----------------------------------") print (" ") print (" Not executing SExtractor commands:") print (" ") print (" Executable file retained regardless.") print (" No image displayed if in single-image test mode.") } if ((delUnix == yes)&&(execSExt==yes)) { # delete (files="executable.jnk", verify=no,default=yes,go_ahead=yes) !/bin/rm executable.jnk print (" ") print (" File executable.jnk deleted.") } else { delete (files=nameUnix,verify-,default+,go_ahead+) rename (files="executable.jnk",newname=nameUnix,field="all") print (" ") print (" File executable.jnk renamed "//nameUnix//" and kept.") } # Displaying check_image if just a single-image test: if ((testSExt==yes)&&(execSExt==yes)) { print (" ") print (" Results of SExtractor test:") print (" Displaying "//image//clnExtn//" in Ximtool (frame "//frm//")...") # display (image=checkImage,frame=frm,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk.out") display (image=image//clnExtn,frame=frm,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk.out") tvmark (frame=frm,coords="temp_tsex2",logfile="",autolog-, outimage="",deletio="",command="",mark="circle",radii=10,lengths=2, font="raster",color=200,label-,number-,nxoffset=10,nyoffset=10,pointsi=3, txsize=3,toleran=1.5,interac-) print (" ") print (" --> One-word comment about detection efficiency:") scan (logComment) date (>> sextLog) if (fstlst==yes) { str1 = " first img "//minArea//" "//thresh } else { str1 = " last img "//minArea//" "//thresh } str2 = " "//deblnd//" "//filter//" "//logComment print (str1//str2, >> sextLog) print (" ", >> sextLog) print (" ") print (" Results appended to "//sextLog//"...") print (" ") !/bin/rm temp_tsex2 !/bin/rm temp_tsex1 !/bin/rm temp_junk.out } } # end of mvSExt option==no ====================================== print (" ") print (" Done.") print (" ") print (" ") end