procedure tcray (sumImage, clnImage, ratio, compOffset, maskImage, crThreshold, asciiFile, full, inspect, frm1, frm2, circRad) string sumImage {prompt="Summed (uncleaned) image"} string clnImage {prompt="Cleaned image (no CRs, ghosts)"} real ratio {5.5, prompt="Flux ratio (summed/cleaned)"} real compOffset {100, prompt="Offset to add before comparing images"} string maskImage {"g0mask_reduced",prompt="Image mask to apply"} real crThreshold {7.0, 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=" ==> sumImage display frame number"} int frm2 {2,prompt=" ==> clnImage display frame number"} int circRad {10, prompt=" ==> pixel radius of circle markers"} begin # Variable Declarations: string shellLine # Unix line containing SExtractor command # 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) # 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) # 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") 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") } 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 !/bin/rm executable.jnk # 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