procedure toffsets (refImage, defOff, offImgs, repOffs, img1, img2, Nsl, abbName, extn, runAuto, coordFil, outFile, delOld, defLong, longList, delStar) string refImage {prompt="Reference image"} bool defOff {yes, prompt="1. Define a list of X-Y image offsets?"} string offImgs {prompt=" List of images offset with respect to reference"} bool repOffs {no, prompt=" OR generate list of representative offsets?"} string img1 {"=", prompt=" -> image 1 (from scan 2)"} string img2 {"=", prompt=" -> image 2 (from scan 3)"} int Nsl {prompt=" -> Number of images in a scan"} bool abbName {no, prompt=" Are FILE image names abbreviated?"} string extn {prompt=" Extension appended to abbreviated image names"} bool runAuto {no, prompt=" Run automatically (non-interactively)?"} string coordFil {"=", prompt=" -> Name of star coord file"} string outFile {"-", prompt=" Name of output file of X and Y offsets"} bool delOld {yes, prompt=" Delete old offset file? Otherwise append."} bool defLong {yes, prompt="2. Define a long list of reference image stars?"} string longList {"-", prompt=" Name of long list of reference image stars"} bool delStar {yes, prompt=" Delete old ref star file? Otherwise append."} struct *flist # list-directed structure begin # Variable Declarations: string currOff # current offset image string rawName # raw (abbreviated) image name string action # keystroke action int j # frame number int k # counter if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } delete (files="temp_*",go_ahea+,ver-) # 1. -------------------------------------------------------- if (defOff==yes) { if (outFile=="-") { print (" ") print (" ") print (" *** ERROR: Need to specify an X-Y offset file name ...") print (" ") print (" Try again.") bye } if (delOld==yes) { delete (files=outFile,go_ahea+,ver-) } # i.e. deleting old output file if requested # Generating appropriate image list if representative offsets sought: if (repOffs==yes) { print (" ") print (" Generating a list of representative images ...") print (" ") delete (files="temp_toff.reps",go_ahea+,ver-) print (" ") print("0 0", > outFile) k=1 while (k> outFile) k=k+1 } if (img1!="=") { print (img1, >> "temp_toff.reps") } if (img2!="=") { print (img2, >> "temp_toff.reps") } offImgs="temp_toff.reps" if (Nsl<2) { print (" ") print (" ") print (" *** ERROR: Need more than "//Nsl//" slices") print (" ") print (" Try again.") bye } } # REFERENCE positions for image offset calculations: if (runAuto==no) { 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 (" --> Note which stars you use and in which order") 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_imexam.ref") } else { print (" ") print (" Measuring reference frame stars ...") print (" ") imexam(inp=refImage,frame=1,image=refImage,logfile="",keeplog-, defkey="a",autored+,allfram+,nframes=0,ncstat=50,nlstat=50,graphcu="", imagecu=coordFil,wcs="logical",graphic="stdgraph",use_dis-, >> "temp_imexam.ref") } fields (files="temp_imexam.ref",fields="1,2",lines="1-9999",quit_if-, print_f-, >> "temp_refcoords1") !awk '{n=n+1; if ( (n/2)!=(int(n/2)) ) print $0}' temp_refcoords1 > temp_refcoords # i.e. printing only each odd-numbered row type (input_fi="temp_refcoords",map_cc+,device="terminal",flpar-) j=1 # Main offset-image loop: ---------------------------------------- print (" ") print ("= = = = = = = = = = = = = = = = = = = = = = = = = = = =") flist = offImgs while ( fscan(flist, rawName) != EOF) { if (abbName==yes) { currOff=rawName//extn } if (abbName==no) { currOff=rawName } j=j+1 if (j>4) { j=j-3 } if (runAuto==no) { display (image=currOff,frame=j,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk.out") print (" ") print (" *** 1. Select measurement stars from OFFSET image: "//currOff//" ***") print (" *** (Currently displayed in Ximtool frame "//j//") ***") print (" --> Use to select each star and type when done.") print (" ") imexam(input=currOff,frame=j,image=currOff,keeplog-,defkey="a",autor+, allfram+,nfram=0,graphcu="",imagecu="",wcs="logical",graphic="stdgraph", display="display(image='$1',frame=$2)",use_dis+,flpar-, >> "temp_imexam.off") } else { print (" ") print (" ") print (" Measuring image "//currOff//" stars ...") imexam(inp=currOff,frame=j,image=currOff,logfile="",keeplog-, defkey="a",autored+,allfram+,nframes=0,ncstat=50,nlstat=50,graphcu="", imagecu=coordFil,wcs="logical",graphic="stdgraph",use_dis-, >> "temp_imexam.off") } fields (files="temp_imexam.off",fields="1,2",lines="1-9999",quit_if-, print_f-, >> "temp_offcoords1") !awk '{n=n+1; if ( (n/2)!=(int(n/2)) ) print $0}' temp_offcoords1 > temp_offcoords2 # i.e. printing only each odd-numbered row joinlines (list1="temp_refcoords,temp_offcoords2",list2="", output="temp_offcoords3",delim="",missing="Missing",maxchar=161,shortes+,verbose+) type (input_fi="temp_offcoords3",map_cc+,device="terminal",flpar-) # Calculating mean offsets using awk/tail: !awk '{print ($1-$3)" "($2-$4)}' temp_offcoords3 > temp_offcoords4 !awk '{n=n+1; a=a+$1; b=b+$2; print (a/n)" "(b/n)}' temp_offcoords4 > temp_offcoords5 print (" "//currOff//":") tail (input_fi="temp_offcoords5",nlines=1) tail (input_fi="temp_offcoords5",nlines=1, >> outFile) if (repOffs==yes) { print (" ") print (" Writing offset value "//Nsl//" times to "//outFile//"...") print (" ") k=1 while (k> outFile) k=k+1 } } # i.e. duplicating offset value if measured from a representative image if (runAuto==no) { print(" ") print (" --> Type to display next image; to quit.") scan (action) if (action=="q") { print(" ") print(" ") print(" Quitting before end of list is reached.") print(" Writing out last offset pair for remaining images") print(" ") print(" *** No long list of reference stars ("//longList//") created ***") print(" ---> Do this in a later re-run.") print(" ") while ( fscan(flist, currOff) != EOF) { print (" "//currOff//":") tail (input_fi="temp_offcoords5",nlines=1) tail (input_fi="temp_offcoords5",nlines=1, >> outFile) } print(" ") print(" Done.") bye } if (action!="n") { print (" --> Type to display next image; to quit.") scan (action) } print (" ") print (" ") } delete (files="temp_imexam.off",go_ahea+,ver-) delete (files="temp_offcoords?",go_ahea+,ver-) } } # ---------------------------------------------------------------- print (" ") print ("= = = = = = = = = = = = = = = = = = = = = = = = = = = =") # 2. -------------------------------------------------------- # REFERENCE positions for long list of reference frame stars: if (defLong==yes) { if (longList=="-") { print (" ") print (" ") print (" *** ERROR: Need to specify an reference image star list name ...") print (" ") print (" Try again.") bye } if (delStar==yes) { delete (files=longList,go_ahea+,ver-) } # i.e. deleting old output file if requested display (image=refImage,frame=1,erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >> "temp_junk.out") print (" ") print (" *** 2. Select COORDINATE STARS (from "//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_imexam.long") fields (files="temp_imexam.long",fields="1,2",lines="1-9999",quit_if-, print_f-, >> "temp_reflong1") !awk '{n=n+1; if ( (n/2)!=(int(n/2)) ) print $0}' temp_reflong1 > temp_reflong # i.e. printing only each odd-numbered row type (input_fi="temp_reflong",map_cc+,device="terminal",flpar-) type (input_fi="temp_reflong",map_cc+,device="terminal",flpar-, >> longList) print (" ") print ("= = = = = = = = = = = = = = = = = = = = = = = = = = = =") } delete (files="temp_*",go_ahea+,ver-) print (" ") print (" ") print ("Done.") end