procedure tfwhm (defPosns,refImage,xysFile,offImgs,abbName,extn,outFile1, inclAvg,col,outFile2,addRad, outFile3, Xc, Yc, delOld) bool defPosns {yes, prompt="1. Define a list of X-Y star positions?"} string refImage {prompt=" Image to use (full name)"} string xysFile {"=", prompt="X-Y position file (supplied or created here)"} string offImgs {prompt="2. List of images to measure"} bool abbName {no, prompt=" Are image names abbreviated?"} string extn {prompt=" Extension appended to abbreviated image names"} string outFile1 {"-", prompt="Name of output file 1 (full output)"} bool inclAvg {yes, prompt="Include mean for each frame?"} string col {"11",prompt=" Column to average"} string outFile2 {"--", prompt=" Output 2 file name (mean values)"} bool addRad {yes, prompt="Generate a FWHM vs optical radius file?"} string outFile3 {"---", prompt=" Output 3 file name (FWHM vs radius)"} int Xc {730, prompt=" X-location of optical axis"} int Yc {830, prompt=" Y-location of optical axis"} bool delOld {yes, prompt="Delete old output files (otherwise append)?"} struct *flist1 # list-directed structure struct *flist2 # list-directed structure begin # Variable Declarations: string currImage # current image string rawName # raw (abbreviated) image name string padding # tab space to place before printed mean string imgjnk # image junk real avg # current average value int slice # current slice string awkLine # awk command line padding=" " if (addRad==yes) { print("", >> outFile3) } # Do this here to avoid concatenation-on-an-empty-file problems later if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } delete (files="temp_junk.out",go_ahea+,ver-, >> "tempJNK") delete (files="temp_tfwhm*",go_ahea+,ver-, >> "tempJNK") if (delOld==yes) { print(" ") print("Deleting old versions of output files ...") delete (files=outFile1,go_ahea+,ver-, >> "tempJNK") delete (files=outFile2,go_ahea+,ver-, >> "tempJNK") delete (files=outFile3,go_ahea+,ver-, >> "tempJNK") } # i.e. deleting old output file if requested # 1. -------------------------------------------------------- if (defPosns==yes) { print(" ") print(" Defining X-Y position file (please wait for image to display) ...") print(" ") if (xysFile=="=") { print (" ") print (" ") print (" *** ERROR: Need to specify an X-Y position file name ...") print (" ") print (" Try again.") bye } delete (files=xysFile,go_ahea+,ver-, >> "tempJNK") # Position file for star positions: display (image=refImage,frame=1,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk.out") print (" ") print (" *** 1. Select measurement stars from REFERENCE image: "//refImage//" ***") print (" *** (Currently displayed in Ximtool frame 1) ***") print (" --> Use <,> to select each star and type when done.") print (" ") imexam(input=refImage,frame=1,image=refImage,keeplog-,defkey="a",autor+, allfram+,nfram=0,graphcu="",imagecu="",wcs="logical",graphic="stdgraph", display="display(image='$1',frame=$2)",use_dis+,flpar-, >> "temp_tfwhm1") # *** N.B: Note the use of the "," key. *** fields (files="temp_tfwhm1",fields="1,2",lines="2-9999",quit_if-, print_f-, >> xysFile) # *** N.B: Note that output taken from line 2 (to remove heading) *** type (input_fi=xysFile,map_cc+,device="terminal",flpar-) delete (files="temp_jnk.out",go_ahea+,ver-, >> "tempJNK") } # Main offset-image loop: ---------------------------------------- print (" ") print ("Measuring FWHM in each image ...") print (" ") print (" ") slice=0 flist1 = offImgs while ( fscan(flist1, rawName) != EOF) { slice=slice+1 if (abbName==yes) { currImage=rawName//extn } if (abbName==no) { currImage=rawName } # delete (files="temp_tfwhm4",go_ahea+,ver-) # delete (files="temp_tfwhm5",go_ahea+,ver-) # delete (files="temp_tfwhm6",go_ahea+,ver-) # delete (files="temp_tfwhm7",go_ahea+,ver-) # delete (files="temp_tfwhm8",go_ahea+,ver-) delete (files="temp_tfwhm*",go_ahea+,ver-, >> "tempJNK") print(" ") imexam(inp=currImage,frame=1,image=currImage,logfile="",keeplog-, defkey=",",autored+,allfram+,nframes=0,ncstat=50,nlstat=50,graphcu="", imagecu=xysFile,wcs="logical",graphic="stdgraph",use_dis-, >> "temp_tfwhm4") # *** N.B: Note the use of the "," key. *** # Writing output to screen and file: print(currImage) print(" ") type (input_fi="temp_tfwhm4",map_cc+,device="terminal",flpar-) print(currImage, >> outFile1) print(" ", >> outFile1) type (input_fi="temp_tfwhm4",map_cc+,device="terminal",flpar-, >> outFile1) # Calculating and adding an average (if required): if (inclAvg==yes) { fields (files="temp_tfwhm4",fields=col,lines="2-", quit_if-, print_f-) | average(option="new_sample", >> "temp_tfwhm5") fields(files="temp_tfwhm5",fields="1",lines="1-", quit_if-,print_f-, >> "temp_tfwhm6") flist2 = "temp_tfwhm6" imgjnk = fscan(flist2, avg) print (padding//padding//"------") printf (padding//padding//"%6.2f \n",avg) print (padding//padding//"------", >> outFile1) printf (padding//padding//"%6.2f \n",avg, >> outFile1) printf ("%6.2f \n",avg, >> outFile2) } # Creating a FWHM vs radius file (if requested): if (addRad==yes) { print (" ") print (" Adding to FWHM vs radius file (please wait) ...") fields (files="temp_tfwhm4",fields="1-",lines="2-", quit_if-, print_f-, >> "temp_tfwhm7") awkLine="awk '{x=$1-"//Xc//";y=$2-"//Yc//";r=sqrt(x*x+y*y);" awkLine=awkLine//" print r,$11,"//slice//",$1,$2}' temp_tfwhm7" awkLine=awkLine//" > temp_tfwhm8;" awkLine=awkLine//" mv -f "//outFile3//" temp_tfwhm9;" awkLine=awkLine//" cat temp_tfwhm9 temp_tfwhm8 > "//outFile3 print(awkLine, >> "temp_tfwhm10") !chmod 777 temp_tfwhm10 !temp_tfwhm10 } print (" ", >> outFile1) } # ---------------------------------------------------------------- print (" ") delete (files="temp_tfwhm*",go_ahea+,ver-, >> "tempJNK") delete (files="tempJNK",go_ahea+,ver-, >> "tempJNK") # awk '{if(NR==1) {a=$2;c=$2} b=$2; if(a>b) {a=b;} if(NR>1 && c==$2) d=1; if(d==1) print $2/a}' jnk jnk # AWK command to normalise a list to its minimum value -- complicated! print (" ") print (" ") print ("Done.") print (" ") end