procedure tdeep (nScans,impref1,impref2,impref3,start1,end1,start2,end2, start3,end3,inExtn,outType,clnOut,clipmode,sigL,sigH,sigTol,val,sumOut, maskType,maskZer,clnmaRMS,summaRMS,logname,convFits) int nScans {3,prompt="Number of image scans (<=3)"} string impref1 {prompt=" Scan 1: Image name prefix"} string impref2 {prompt=" Scan 2: Image name prefix"} string impref3 {prompt=" Scan 3: Image name prefix"} int start1 {prompt=" Scan 1: Image start number"} int end1 {prompt=" Scan 1: Image finish number"} int start2 {prompt=" Scan 2: Image start number"} int end2 {prompt=" Scan 2: Image finish number"} int start3 {prompt=" Scan 3: Image start number"} int end3 {prompt=" Scan 3: Image finish number"} string inExtn {"r", prompt="Extension for all input images?"} string outType {"cleaned", prompt="Output images (cleaned|averaged|both)"} string clnOut {"c1", prompt="Cleaned: Output image name?"} string clipmode {"avsigclip", prompt=" Clip method for cleaning (avsigclip|pclip)"} real sigL {1.0, prompt=" Lower sigma clipping factor"} real sigH {1.0, prompt=" Upper sigma clipping factor"} real sigTol {0.1, prompt=" Tolerance for sig-clip scaling corrections"} real val {-0.5, prompt=" pclip: Percentile clipping parameter"} string sumOut {"s1", prompt="Average: Output image name?"} string maskType {"rms", prompt="Apply corner mask? (none|zero|rms)"} string maskZer {"-",prompt=" Zero mask image (full name)"} string clnmaRMS {"--",prompt=" Cleaned: RMS mask image (full name)"} string summaRMS {"---",prompt=" Average: RMS mask image (full name)"} string logname {"STDOUT", prompt="Log file written here"} bool convFits {no, prompt="Convert output images to FITS FORMAT?"} begin if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } # Cleaning-up old files and ones about to be created: delete (files="temp_tcomb*",go_ahea+,ver-) imdelete (images="tempImg",verify=no,default=yes, go_ahead=yes) print (" ") print ("Creating image lists (please wait) ...") print (" ") if ((nScans>=1)&&(nScans<=3)) { tmakefile (file_out="temp_tcomb1",startNum=start1,stopNum=end1, prefixOU=impref1,anyExtn+,extnOU=inExtn,padOU+,listImgs-) !cp temp_tcomb1 temp_tcomb4 } if ((nScans>=2)&&(nScans<=3)) { tmakefile (file_out="temp_tcomb2",startNum=start2,stopNum=end2, prefixOU=impref2,anyExtn+,extnOU=inExtn,padOU+,listImgs-) ! cat -s temp_tcomb4 temp_tcomb2 >> temp_tcomb4 } if (nScans==3) { tmakefile (file_out="temp_tcomb3",startNum=start3,stopNum=end3, prefixOU=impref3,anyExtn+,extnOU=inExtn,padOU+,listImgs-) ! cat -s temp_tcomb4 temp_tcomb3 >> temp_tcomb4 } if (nScans>3) { print (" ") print (" *** Invalid number of scans *** ") bye } if (nScans<1) { print (" ") print (" *** Invalid number of scans *** ") bye } # CLEANED ---------------------------------------------------------- if ((outType=="cleaned")||(outType=="both")) { print (" ") print ("============================================================") print (" ") print ("Creating CLEANED deep image (please wait)...") print (" ") imdelete (images=clnOut,verify=no,default=yes, go_ahead=yes) imcombine(inp="@temp_tcomb4",output=clnOut,logfile=logname,combine="median", rej=clipmode,proj=no,outty="real",offse="none",maskty="none",scale="none", zer="none",weig="none",statsec="",lthr=INDEF,hthr=INDEF,nkee=0, mclip=yes,lsig=sigL,hsig=sigH,sigscal=sigTol,pclip=val) if ((maskType=="zero")||(maskType=="rms")) { # Multiplying by zero mask (required by both cases): imarith(operand1=clnOut,op="*",operand2=maskZer, result="tempImg",title="combined image",divzero=0,verb=no) imdelete (images=clnOut,verify=no,default=yes, go_ahead=yes) imrename (oldnames="tempImg",newnames=clnOut,verb=no) if (maskType=="rms") { # Adding RMS mask: imarith(operand1=clnOut,op="+",operand2=clnmaRMS, result="tempImg",title="combined image",divzero=0,verb=no) imdelete (images=clnOut,verify-,default+, go_ahead+) imrename (oldnames="tempImg",newnames=clnOut,verb-) } } if (convFits==yes) { fitsname = clnOut//".fits" print (" ") print (" Converting "//clnOut//" to fits ("//fitsname//") ...") imdelete (images=fitsname,verify=no,default=yes, go_ahead=yes) imrename (oldnames=clnOut,newnames="tempImg",verb=no) wfits(iraf_fil="tempImg",fits_fil=fitsname, make_im+,long_he-, short_h+,bitpix=0,blockin=0,scale+,autosca+, bscale=1.,bzero=0.) imdelete (images="tempImg",verify=no,default=yes, go_ahead=yes) } } # end of CLEANED --------------------------------------------------- # AVERAGED ----------------------------------------------------------- if ((outType=="averaged")||(outType=="both")) { print (" ") print ("============================================================") print (" ") print ("Creating AVERAGED deep image (please wait)...") print (" ") imdelete (images=sumOut,verify=no,default=yes, go_ahead=yes) imcombine(inp="@temp_tcomb4",output=sumOut,logfile=logname,combine="average", rej="none",proj=no,outty="real",offse="none",maskty="none",scale="none", zer="none",weig="none",statsec="",lthr=INDEF,hthr=INDEF,nkee=0, mclip=yes,lsig=2.5,hsig=2.5) if ((maskType=="zero")||(maskType=="rms")) { # Multiplying by zero mask (required by both cases): imarith(operand1=sumOut,op="*",operand2=maskZer, result="tempImg",title="combined image",divzero=0,verb=no) imdelete (images=sumOut,verify=no,default=yes, go_ahead=yes) imrename (oldnames="tempImg",newnames=sumOut,verb=no) if (maskType=="rms") { # Adding RMS mask: imarith(operand1=sumOut,op="+",operand2=clnmaRMS, result="tempImg",title="combined image",divzero=0,verb=no) imdelete (images=sumOut,verify-,default+, go_ahead+) imrename (oldnames="tempImg",newnames=sumOut,verb-) } } if (convFits==yes) { fitsname = sumOut//".fits" print (" ") print (" Converting "//sumOut//" to fits ("//fitsname//") ...") imdelete (images=fitsname,verify=no,default=yes, go_ahead=yes) imrename (oldnames=sumOut,newnames="tempImg",verb=no) wfits(iraf_fil="tempImg",fits_fil=fitsname, make_im+,long_he-, short_h+,bitpix=0,blockin=0,scale+,autosca+, bscale=1.,bzero=0.) imdelete (images="tempImg",verify=no,default=yes, go_ahead=yes) } } # end of AVERAGED --------------------------------------------------- delete (files="temp_tcomb*",go_ahea+,ver-) print (" ") print ("============================================================") print (" ") print (" ") print ("Done.") print (" ") end