procedure tpay (inSum, inCln, countCRs, testMini, x1, x2, y1, y2, ratio, compOffset, inMask, crThreshold, asciiFile, full, inspect, frm1, frm2, circRad) string inSum {"deepAVG13c8", prompt="Summed (uncleaned) image"} string inCln {"deepCLN13c8",prompt="Cleaned image (no CRs, ghosts)"} bool countCRs {no, prompt="Count the CRs found?"} bool testMini {yes, prompt="Test a mini region of image?"} int x1 {500, prompt=" ---> x1"} int x2 {600, prompt=" ---> x2"} int y1 {500, prompt=" ---> y1"} int y2 {600, prompt=" ---> y2"} real ratio {1.0, prompt="Flux ratio (summed/cleaned)"} real compOffset {500, prompt="Offset to add before comparing images"} string inMask {"zero13c8",prompt="Image mask to apply"} real crThreshold {1.03, prompt="CR threshold (lower limit), in counts"} string asciiFile {"tcray.out",prompt="Name of output ascii file"} bool full {no, prompt="Verbose listing of each operation?"} bool inspect {yes,prompt="Inspect results of CR identification?"} int frm1 {1,prompt=" ==> inSum display frame number"} int frm2 {2,prompt=" ==> inCln display frame number"} int circRad {10, prompt=" ==> pixel radius of circle markers"} begin # Variable Declarations: string shellLine # Unix line containing SExtractor command string sumImage, clnImage, maskImage # Make sure the IMAGES and IMGTOOLS packages are loaded: if (! defpac ("images")) { print("IMAGES package not loaded") bye } if (! defpac ("imgtools")) { print("STSDAS.TOOLBOX.IMGTOOLS package not loaded") bye } # Deleting any old version of images/files: !/bin/rm executable.jnk delete(files=asciiFile,verify=no,default=yes, go_ahead=yes) delete(files="tempcratxt*",verify=no,default=yes, go_ahead=yes) imdelete(images="tempcra*",verify=no,default=yes, go_ahead=yes) if (testMini==yes) { sumImage=inSum//"["//x1//":"//x2//","//y1//":"//y2//"]" clnImage=inCln//"["//x1//":"//x2//","//y1//":"//y2//"]" maskImage=inMask//"["//x1//":"//x2//","//y1//":"//y2//"]" } else { sumImage=inSum clnImage=inCln maskImage=inMask } # Scaling clean image, adding offset to both, taking ratio: print (" ") print ("Ratio-ing images ...") # print (" ") imarith(operand1=clnImage,op="*",operand2=ratio,result="tempcra1", title="scaled clnImage",divzero=0.,verb=full,noact-,flpar-) imarith(operand1=sumImage,op="+",operand2=compOffset,result="tempcra2", title="sumImage + offset",divzero=0.,verb=full,noact-,flpar-) # sumImage to use is now in tempcra2 imarith(operand1="tempcra1",op="+",operand2=compOffset, result="tempcra3", title="clnImage + offset",divzero=0.,verb=full,noact-,flpar-) # clnImage to use is now in tempcra3 imarith(operand1="tempcra2",op="/",operand2="tempcra3", result="tempcra4", title="(sum+off)/(cln+off)",divzero=0.,verb=full, noact-,flpar-) # Cleaning around edges by applying mask image: # print (" ") print ("Applying edge mask ...") # print (" ") imarith(operand1="tempcra4",op="*",operand2=maskImage, result="tempcra5", title="(sum+off)/(cln+off)",divzero=0.,verb=full, noact-,flpar-) # Creating ascii file of CR/ghost pixels: # print (" ") print ("Creating ascii table "//asciiFile//" of pixel positions ...") # print (" ") pixlocate(input="tempcra5",lowerlim=crThreshold,upperlim=INDEF, maxvals=INDEF,border=0,outside-,mode="al", >> "tempcratxt_1") fields(files="tempcratxt_1",fields="1-2",lines="1-",quit_if-,print_f-, mode="al", >> asciiFile) # type (input_fi=asciiFile, map_cc+, device="terminal") # Displaying results if required: if (inspect==yes) { print (" ") print ("Displaying results in frames "//frm1//" and "//frm2//" ...") # print (" ") display (image=sumImage,fra=frm1,bpdispl="none",erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear") display (image=clnImage,fra=frm2,bpdispl="none",erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear") if (testMini==yes) { shellLine="awk '{print ($1+"//x1//"), ($2+"//y1//")}'" shellLine=shellLine//" "//asciiFile//" > tpay.TMP" print(shellLine, >> "executable.jnk") # print(shellLine) # !chmod 777 executable.jnk !sh executable.jnk delete(files=asciiFile, verify-, default+, allvers+) rename(files="tpay.TMP", newname=asciiFile, field="all") delete(files="executable.jnk", verify-, default+, allvers+) } tvmark(frame=frm1,coords=asciiFile,logfile="",autolog-,outimag="", mark="circle",radii=circRad,lengths=0,font="raster",color=0,label-,number-, pointsi=3, txsize=2, interac-,flpar-,mode="ql") } if (countCRs==yes) { shellLine = "echo 'Number of CR/ghost-affected pixels: ' ; " shellLine = shellLine//"awk '{a=a+1; print a}' "//asciiFile shellLine = shellLine//" | tail -1 " print(shellLine, >> "executable.jnk") print (" ") !chmod 777 executable.jnk !executable.jnk delete(files="executable.jnk", verify-, default+, allvers+) # shell/awk-script line to print number of entries in final catalogue } # Cleaning up temporary images: print (" ") delete(files="tempcratxt*",verify=no,default=yes, go_ahead=yes) imdelete(images="tempcra*",verify=no,default=yes, go_ahead=yes) # print (" ") print ("Done.") print (" ") end