procedure tgauss (imageFile, abbName, extn, seeingFile, imposeLimit, pixScale, outExtn, saveKernal, kernFile, measFWHM, starPosns, resultsFile) string imageFile {"-", prompt="List of images to convolve"} bool abbName {no, prompt=" Are image names abbreviated?"} string extn {prompt=" Extension appended to abbreviated names"} string seeingFile {prompt="File listing mean FWHM of each image"} bool imposeLimit {no, prompt="Impose 1 pix kernal minimum size limit?"} real pixScale {0.88, prompt="Kernal scaling factor (fractional)"} string outExtn {"--", prompt="Output image extension"} bool saveKernal {yes, prompt="Save file of kernal sigmas?"} string kernFile {"tgauss.out1", prompt=" Name of kernal file?"} bool measFWHM {yes, prompt="Make before/after FWHM comparison?"} string starPosns {"xys.out", prompt=" File listing stellar X-Ys"} string resultsFile {"tgauss.out2", prompt=" Name of results file?"} struct *flist # list-directed structure to go thru sigma file struct *clist # list-directed structure to go thru sigma file begin # Variable Declarations: string rawName # raw (abbreviated) image name real currFWHM # current FWHM string currImage # current image name real worstFWHM # worst seeing FWHM string worstImage # worst seeing image name int j # image counter int k # number of images with seeing sufficiently # bad to convolve string imgjnk # image junk real currSigma # current convolution sigma real pixLimit # Lower limit to useful size for conv kernal # (i.e. 1 pixel in sigma) string outImage # output image name string awkLine # awk command line real sclFWHM # scaled current FWHM # Make sure the IMAGES package is loaded: if (! defpac ("images")) { print("IMAGES package not loaded") bye } if ((imageFile=="-")||(outExtn=="--")) { print (" ") print (" ** PLEASE SUPPLY SOME INPUT/OUTPUT FILE NAMES **") print (" ") print ("Bye.") print (" ") bye } # Removing any files with names to be used: delete (files="temp_tgauss1",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss6",verify-,default+,go_ahea+, >> "tempJNK") pixLimit = 1.0/2.355 # i.e. 1 pixel in sigma # print ("pixLimit= "//pixLimit) print (" ") # First loop to find worst-seeing image: ----------------------------- clist = seeingFile flist = imageFile worstFWHM = 0 while ( fscan(clist, currFWHM) != EOF) { imgjnk = fscan(flist, rawName) if (abbName==yes) { currImage=rawName//extn } if (abbName==no) { currImage=rawName } if (currFWHM==worstFWHM) { worstImage = worstImage//" and "//currImage worstFWHM = currFWHM } if (currFWHM>worstFWHM) { worstImage = currImage worstFWHM = currFWHM } } print (" ") print ("----------------------------------------------------") print (" ") print ("Worst seeing image: "//worstImage//" Seeing: "//worstFWHM//" pix") # Second loop to find create a file of convolution sigmas: ---------- print (" ") print ("----------------------------------------------------") print ("Convolution sigmas: (scale factor = "//pixScale//")") print (" ") clist = seeingFile flist = imageFile k=0 j=0 while ( fscan(clist, currFWHM) != EOF) { imgjnk = fscan(flist, rawName) j=j+1 if (abbName==yes) { currImage=rawName//extn } if (abbName==no) { currImage=rawName } # sclFWHM = pixScale*currFWHM # i.e. scaling by input factor currSigma=sqrt((worstFWHM*worstFWHM)-(currFWHM*currFWHM)) currSigma=currSigma/2.355 # i.e. expressing convolution FWHM in units of sigma currSigma=currSigma*pixScale if (currSigma==0) { currSigma=0.1 currImage=currImage//"**" } if ((imposeLimit==yes)&&(currSigma<=pixLimit)) { currImage=currImage//"**" } else { currImage=currImage//" " k=k+1 } print (currImage//" "//currFWHM//" "//currSigma) print (currSigma, >> "temp_tgauss1") print (rawName, >> "temp_tgauss6") } print (" ") print ("Images: "//j//" Number to convolve: "//k) # Final loop to convolve images: ------------------------------------ print (" ") print ("----------------------------------------------------") print ("Performing convolution (please wait...)") print (" ") print ("Start:") time print (" ") clist = "temp_tgauss1" flist = imageFile j=0 while ( fscan(clist, currSigma) != EOF) { imgjnk = fscan(flist, rawName) j=j+1 if (abbName==yes) { currImage=rawName//extn } if (abbName==no) { currImage=rawName } outImage = rawName//outExtn print (j//": "//currImage//" --> "//outImage//" ...") imdelete(images=outImage,verif-,default+,go_ahead+, >> "tempJNK") if ((imposeLimit==no)||(currSigma>pixLimit)) { gauss(input=currImage,output=outImage,sigma=currSigma,ratio=1., theta=0., nsigma=4.,bilinear+,boundary="nearest",constan=0.) } else { print ("(=> straight imcopy, no convolution)") imcopy(input=currImage,output=outImage,verbose-) } print (" ") } if (saveKernal==yes) { delete (files=kernFile,verify-,go_ahea+) copy (input="temp_tgauss1",output=kernFile,verb-) print (" ") print ("Record of kernal sizes written to "//kernFile//" ...") print (" ") } # Making before/after comparison if requested: ---------------------- if (measFWHM==yes) { delete (files="temp_tgauss2",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss3",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss4",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss5",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss7",verify-,default+,go_ahea+, >> "tempJNK") print (" ") print ("----------------------------------------------------") print ("Before/after comparison (please wait...):") print (" ") tfwhm (defPosns-,refImage="",xysFile=starPosns,offImgs=imageFile, abbName=abbName,extn=outExtn,outFile1="temp_tgauss2",inclAvg+,col=11, outFile2="temp_tgauss3",addRad-,outFile3="-",Xc=9999,Yc=9999,delOld+, >> "temp_tgauss4") joinlines (list1="temp_tgauss6,"//seeingFile//",temp_tgauss3",list2="", output="temp_tgauss5",delim="",missing="Missing",maxchar=161,shortest+,verb+) awkLine = "awk '{print $0, ("//worstFWHM//"/$3)}' temp_tgauss5" awkLine = awkLine//" > "//resultsFile print (awkLine, >> "temp_tgauss7") !chmod 777 temp_tgauss7 !temp_tgauss7 print (" ") print ("IMAGE BEFORE AFTER worst/AFTER") type (input_fi=resultsFile,map_cc+,device="terminal") print (" ") # delete (files="temp_tgauss2",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss3",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss4",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss5",verify-,default+,go_ahea+, >> "tempJNK") delete (files="temp_tgauss7",verify-,default+,go_ahea+, >> "tempJNK") } print (" ") print ("----------------------------------------------------") # Cleaning up: delete (files="temp_tgauss1",verify-,default+,go_ahea+) delete (files="temp_tgauss6",verify-,default+,go_ahea+) delete (files="tempJNK",verify-,default+,go_ahea+) print (" ") print ("Finish:") time print (" ") print (" Done.") print (" ") print (" ") end