procedure tcull (cpAcross, toCull, concatRes, prevExtn, appRes, inExtn, numCols, takeAll, i1, i2, imgFile, abbName, extnAbb, halfL, a1, a2, a3, a4, loc, anoth, outExtn) bool cpAcross {yes, prompt="Copy and compile idpick2.f?"} string toCull {"both", prompt="Cull which? (contin|non-contin|both|none)"} bool concatRes {no, prompt="Attach output to an existing FULL file-set?"} string prevExtn {"-", prompt=" -> Extension for existing files"} bool appRes {yes, prompt=" -> Append results? Otherwise precede"} string inExtn {"two", prompt="Extension for input files"} int numCols {3, prompt=" Number of columns in strip mosaic"} bool takeAll {yes, prompt=" Select all candidates (contin|non-contin separately)?"} int i1 {1, prompt=" -> if not, START row"} int i2 {62, prompt=" -> if not, END row"} string imgFile {"-",prompt="List of images (full or abbreviated names)"} bool abbName {no, prompt=" Are image names abbreviated?"} string extnAbb {prompt=" Extension appended to abbreviated image names"} int halfL {20, prompt="Half-length of box (in pix)"} real a1 {6, prompt=" Aperture 1 (diameter)"} real a2 {9, prompt=" Aperture 2 (diameter)"} real a3 {12, prompt=" Aperture 3 (diameter)"} real a4 {20, prompt=" Aperture 4 (diameter)"} int loc {1, prompt="Frame to display in"} bool anoth {yes, prompt="Display a second strip-mosaic without apertures?"} string outExtn {"out", prompt="Extension for output files"} struct *flist # list-directed structure to go thru filenames begin # Variable declarations: real xc, yc # current candidate coordinates int j # input file line counter real jR, numColsR # real-number equivalents of these variables real quot # quotient int quotIR # real-valued version of the int(quot) int numPads # number of pads real numPadsR # real-valued version of number of pads int n # counter string fullName string rawName int nSlices # number of slices string action # action command entered at run time if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } if (! defpac ("nproto")) { print("Package NPROTO needs to be loaded.") bye } if (! defpac ("sdisplay")) { print("STSDAS.GRAPHICS.SDISPLAY package not loaded") bye } if ((numCols!=1)&&(numCols!=2)&&(numCols!=3)) { print (" ") print (" *** ERROR: Illegal value for numCols") print (" Please try again.") print (" ") print (" ") bye } if ((takeAll==yes)&&(i1<=0)) { print (" ") print (" *** ERROR: Illegal value for i1") print (" Please try again.") print (" ") print (" ") bye } if ((takeAll==yes)&&(i2<=0)) { print (" ") print (" *** ERROR: Illegal value for i2") print (" Please try again.") print (" ") print (" ") bye } if (outExtn==inExtn) { print (" ") print (" *** ERROR: outExtn!= inExtn") print (" Please try again.") print (" ") print (" ") bye } if (cpAcross==yes) { print (" ") print (" Copying idpick2.f across...") !cp /home/dhj/iraf/TFred/idpick2.f . print (" ") print (" Compiling...") !f77 -C idpick2.f -o idpick2 print (" ") } delete (files="elgRed."//outExtn,go_ahea+,ver-) delete (files="elgLine."//outExtn,go_ahea+,ver-) delete (files="elgLnFlx."//outExtn,go_ahea+,ver-) delete (files="elgLnUnc."//outExtn,go_ahea+,ver-) delete (files="elgsigdv."//outExtn,go_ahea+,ver-) delete (files="elgLnID."//outExtn,go_ahea+,ver-) delete (files="tempTCids*",go_ahea+,ver-) # CONTINUUM-FIT CASE: ============================================= if ((toCull=="contin")||(toCull=="both")) { # Clean-up before start: imdelete (image="tempTC_img*", ver-, def+, go_ahead+) delete (files="tempTC_*",go_ahea+,ver-) # Main AWK script is in tempTC_0; other files are tempTC_? delete (files="idpick2.in",go_ahea+,ver-) print (" ") print (" ") print ("==============================================================") print (" ") print (" 1. CONTINUUM-FIT CANDIDATES:") if (takeAll==yes) { print (" (full list)") print ("awk '{print $2, $3}' elgLnFlx."//inExtn//" > tempTC_1", > "tempTC_0") print ("awk '{print $4, $1}' elgLine."//inExtn//" > tempTC_3", >> "tempTC_0") print ("awk '{print $1}' elgLine."//inExtn//" > tempTCids1", >> "tempTC_0") print ("awk '{if ($17!=5.0) {print $0}}' elgRed."//inExtn//" > tempTC_4", >> "tempTC_0") } else { print (" ("//i1//"-"//i2//")") print ("awk '{a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $2, $3}}' elgLnFlx."//inExtn//" > tempTC_1", > "tempTC_0") print ("awk '{a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $4, $1}}' elgLine."//inExtn//" > tempTC_3", >> "tempTC_0") print ("awk '{a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $1}}' elgLine."//inExtn//" > tempTCids1", >> "tempTC_0") print ("awk '{if ($17!=5.0) {a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $0}} }' elgRed."//inExtn//" > tempTC_4", >> "tempTC_0") } print (" ") print (" Extracting candidates (please wait)...") !chmod 777 tempTC_0 !tempTC_0 flist="tempTC_1" j=0 while ( fscan(flist, xc, yc) != EOF) { j=j+1 } print (" -> there are "//j//" candidates") print (" ") # Working out if objects divide evenly among columns; # padding if not: ------------------------------------------------ numPadsR=0.0 jR=j*1.0 numColsR=numCols*1.0 quot=(jR+numPadsR)/numColsR quotIR=1.0*(int(quot)) while (quot!=quotIR) { numPadsR=numPadsR+1.0 quot=(jR+numPadsR)/numColsR quotIR=1.0*int(quot) } numPads=int(numPadsR) if (numPads>0) { print (" "//j//" candidates do not divide evenly into "//numCols//" columns") } else { if (numCols>1) { print (" "//j//" candidates divide evenly into "//numCols//" columns") } else { print (" "//j//" candidates divides evenly into "//numCols//" column") } } print (" ") print (" -> Number of columns: "//numCols) print (" -> Rows per column: "//quotIR) print (" -> Rows of padding included: "//numPads) print (" ") n=1 while (n<=numPads) { print ("100.0 100.0", >> "tempTC_1") n=n+1 } if (j>0) { # Creating strip-mosaic (tstrip etc) and displaying (tapdraw): ------- flist = imgFile nSlices=0 while ( fscan(flist, rawName) != EOF) { if (abbName==yes) { fullName=rawName//extnAbb } if (abbName==no) { fullName=rawName } print(fullName, >> "tempTC_2") nSlices=nSlices+1 } # i.e. "tempTC_2" is the list of full image names print (" Number of slices: "//nSlices) print (" Half-length of box: "//halfL//" pix") print (" ") print (" Creating strip-mosaic (please wait)...") if (numCols==1) { print (" -> Using tstrip") tstrip (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, verb-) } else if (numCols==2) { print (" -> Using ts2") ts2 (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, nObjCol=quotIR, verb-) } else { print (" -> Using ts3") ts3 (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, nObjCol=quotIR, verb-) } print (" ") print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -") print (" ") print (" Displaying (please wait)...") print (" ") if (anoth==yes) { n=loc+1 if (n>4) { n=1 } tapdraw (readAps-, elgFile="-", colQnt=1, apFile="tempTC_3", mosImage="tempTC_img1", frm=n, ap1=a1, ap2=a2, ap3=a3, ap4=a4, nSl=nSlices, hf=halfL, Nc=quotIR, hs=2, ws=10, vs=5, wrtcoord+, verb-, inclIDs+, txtheight=2, inclAps-, firstFrm-, saveImg-, outImg="=", stdX=2048, stdY=2048) # display (image="tempTC_img1", fra=n, bpdispl="none", erase+, bord-, sele+, repe-, fill-, zscal+, ztrans="linear", >> "tempTC_JNK") } !textedit tempTCids1 & tapdraw (readAps-, elgFile="-", colQnt=1, apFile="tempTC_3", mosImage="tempTC_img1", frm=loc, ap1=a1, ap2=a2, ap3=a3, ap4=a4, nSl=nSlices, hf=halfL, Nc=quotIR, hs=2, ws=10, vs=5, wrtcoord+, verb-, inclIDs+, txtheight=2, inclAps+, firstFrm-, saveImg-, outImg="=", stdX=2048, stdY=2048) print (" ") print (" --> Use imexam commands now and type when done.") imexam print (" ") print (" **** Edit textfile of ID no.s ****") print (" -> Save file and enter a character to continue (q to quit)...") scan(action) if (action=="q") { print (" ") print (" --> Leaving tcull early.") print (" ") print (" Bye.") print (" ") print (" ") bye } print (" -> thank you") print (" ") print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -") print (" ") # Reducing catalogues using new ID-list (idpick.f on elgRed; # tchoose on remaining catalogues): -------------------------------- print (" ") print (" Modifying files according to new ID-list (please wait)...") print (" ") print (" -> tchoose (elgLine, elgLnFlx, elgLnUnc, elgsigdv, elgLnID)") tchoose (cpAcross+, fileSet=3, Nsl=nSlices, inPref=inExtn, choose1="0. - 0. - 0.", choose2="0. - 0. - 0.", howSelec="file", idFile="tempTCids1", outPref=outExtn, verb-) print (" ") print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -") print (" ") print (" -> idpick2 (elgRed)") print (" ") # Forming idpick2.in input file: -------- print ("tempTCids1", > "idpick2.in") print ("tempTC_4", >> "idpick2.in") print ("17", >> "idpick2.in") print ("1", >> "idpick2.in") print ("elgRed."//outExtn, >> "idpick2.in") !idpick2 } else { print(" -> NO INPUTS TO EXAMINE IN THAT INPUT LINE RANGE") print (" ") print ("", >> "elgRed."//outExtn) print ("", >> "elgLine."//outExtn) print ("", >> "elgLnFlx."//outExtn) print ("", >> "elgLnUnc."//outExtn) print ("", >> "elgsigdv."//outExtn) print ("", >> "elgLnID."//outExtn) } } # end of main contin-fit if-then # NON-CONTINUUM FIT CASE: ============================================ if ((toCull=="non-contin")||(toCull=="both")) { # Clean-up before start: imdelete (image="tempTC_img*", ver-, def+, go_ahead+) delete (files="tempTC_*",go_ahea+,ver-) # Main AWK script is in tempTC_0; other files are tempTC_? delete (files="idpick2.in",go_ahea+,ver-) print (" ") print (" ") print ("==============================================================") print (" ") print (" 2. NON-CONTINUUM FIT CANDIDATES:") if (takeAll==yes) { print (" (full list)") print ("awk '{if ($17==5.0) {print $2, $3}}' elgRed."//inExtn//" > tempTC_1", > "tempTC_0") print ("awk '{if ($17==5.0) {print $4, $1}}' elgRed."//inExtn//" > tempTC_3", >> "tempTC_0") print ("awk '{if ($17==5.0) {print $1}}' elgRed."//inExtn//" > tempTCids2", >> "tempTC_0") print ("awk '{if ($17==5.0) {print $0}}' elgRed."//inExtn//" > tempTC_4", >> "tempTC_0") } else { print (" ("//i1//"-"//i2//")") print ("awk '{if ($17==5.0) {a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $2, $3}} }' elgRed."//inExtn//" > tempTC_1", > "tempTC_0") print ("awk '{if ($17==5.0) {a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $4, $1}} }' elgRed."//inExtn//" > tempTC_3", >> "tempTC_0") print ("awk '{if ($17==5.0) {a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $1}} }' elgRed."//inExtn//" > tempTCids2", >> "tempTC_0") print ("awk '{if ($17==5.0) {a=a+1; if ((a>="//i1//")&&(a<="//i2//")) {print $0}} }' elgRed."//inExtn//" > tempTC_4", >> "tempTC_0") } print (" ") print (" Extracting candidates (please wait)...") !chmod 777 tempTC_0 !tempTC_0 flist="tempTC_1" j=0 while ( fscan(flist, xc, yc) != EOF) { j=j+1 } print (" -> there are "//j//" candidates") print (" ") # Working out if objects divide evenly among columns; # padding if not: ------------------------------------------------ numPadsR=0.0 jR=j*1.0 numColsR=numCols*1.0 quot=(jR+numPadsR)/numColsR quotIR=1.0*(int(quot)) while (quot!=quotIR) { numPadsR=numPadsR+1.0 quot=(jR+numPadsR)/numColsR quotIR=1.0*int(quot) } numPads=int(numPadsR) if (numPads>0) { print (" "//j//" candidates do not divide evenly into "//numCols//" columns") } else { if (numCols>1) { print (" "//j//" candidates divide evenly into "//numCols//" columns") } else { print (" "//j//" candidates divides evenly into "//numCols//" column") } } print (" ") print (" -> Number of columns: "//numCols) print (" -> Rows per column: "//quotIR) print (" -> Rows of padding included: "//numPads) print (" ") n=1 while (n<=numPads) { print ("100.0 100.0", >> "tempTC_1") n=n+1 } # Creating strip-mosaic (tstrip etc) and displaying (tapdraw): ------- flist = imgFile nSlices=0 while ( fscan(flist, rawName) != EOF) { if (abbName==yes) { fullName=rawName//extnAbb } if (abbName==no) { fullName=rawName } print(fullName, >> "tempTC_2") nSlices=nSlices+1 } # i.e. "tempTC_2" is the list of full image names print (" Number of slices: "//nSlices) print (" Half-length of box: "//halfL//" pix") print (" ") print (" Creating strip-mosaic (please wait)...") if (j>0) { if (numCols==1) { print (" -> Using tstrip") tstrip (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, verb-) } else if (numCols==2) { print (" -> Using ts2") ts2 (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, nObjCol=quotIR, verb-) } else { print (" -> Using ts3") ts3 (imageFil="tempTC_2", outImage="tempTC_img1", genforma-, coordFil="tempTC_1", nSlices=nSlices, hl=halfL, nObjCol=quotIR, verb-) } print (" ") print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -") print (" ") print (" Displaying (please wait)...") print (" ") if (anoth==yes) { n=loc+1 if (n>4) { n=1 } tapdraw (readAps-, elgFile="-", colQnt=1, apFile="tempTC_3", mosImage="tempTC_img1", frm=n, ap1=a1, ap2=a2, ap3=a3, ap4=a4, nSl=nSlices, hf=halfL, Nc=quotIR, hs=2, ws=10, vs=5, wrtcoord+, verb-, inclIDs+, txtheight=2, inclAps-, firstFrm-, saveImg-, outImg="=", stdX=2048, stdY=2048) # display (image="tempTC_img1", fra=n, bpdispl="none", erase+, bord-, sele+, repe-, fill-, zscal+, ztrans="linear", >> "tempTC_JNK") } !textedit tempTCids2 & tapdraw (readAps-, elgFile="-", colQnt=1, apFile="tempTC_3", mosImage="tempTC_img1", frm=loc, ap1=a1, ap2=a2, ap3=a3, ap4=a4, nSl=nSlices, hf=halfL, Nc=quotIR, hs=2, ws=10, vs=5, wrtcoord+, verb-, inclIDs+, txtheight=2, inclAps+, firstFrm-, saveImg-, outImg="=", stdX=2048, stdY=2048) print (" ") print (" --> Use imexam commands now and type when done.") imexam print (" ") print (" **** Edit textfile of ID no.s ****") print (" -> Save file and enter a character to continue (q to quit)...") scan(action) if (action=="q") { print (" ") print (" --> Leaving tcull early.") print (" ") print (" Bye.") print (" ") print (" ") bye } print (" -> thank you") print (" ") print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -") print (" ") # Reducing catalogues using new ID-list (idpick.f on elgRed) # ----------------------------------------------------------------- print (" ") print (" Modifying files according to new ID-list (please wait)...") print (" ") print (" -> idpick2 (elgRed); tchoose not req'd here") print (" ") # Forming idpick2.in input file: -------- print ("tempTCids2", > "idpick2.in") print ("tempTC_4", >> "idpick2.in") print ("17", >> "idpick2.in") print ("1", >> "idpick2.in") print ("tempTC_5", >> "idpick2.in") # i.e. "tempTC_5" is the temporary name for non-contin-fit output !idpick2 } else { print(" -> NO INPUTS TO EXAMINE IN THAT INPUT LINE RANGE") print (" ") print ("", >> "tempTC_5") } if (toCull=="non-contin") { rename (files="tempTC_5", newname="elgRed."//outExtn) } else if (toCull=="both") { rename (files="elgRed."//outExtn, newname="tempTC_6") # i.e. since earlier elgRed output written to elgRed//outExtn !cat tempTC_5 tempTC_6 > tempTC_7 rename (files="tempTC_7", newname="elgRed."//outExtn) print (" -> non-contin and contin elgRed files joined" print (" ") } } # end of main non-contin-fit if-then # Concatenating object catalogues (if req'd): --------------------- if (concatRes==yes) { delete (files="tempTC_*",go_ahea+,ver-) print (" ") print ("==============================================================") print (" ") print (" Concatenating object catalogues:") if (appRes==yes) { print (" -> "//prevExtn//" + "//inExtn//" = "//outExtn) } else { print (" -> "//inExtn//" + "//prevExtn//" = "//outExtn) } print (" ") if (toCull!="none") { rename (files="elgLine."//outExtn, newname="tempTC_21") rename (files="elgLnFlx."//outExtn, newname="tempTC_22") rename (files="elgLnUnc."//outExtn, newname="tempTC_23") rename (files="elgsigdv."//outExtn, newname="tempTC_24") rename (files="elgLnID."//outExtn, newname="tempTC_25") rename (files="elgRed."//outExtn, newname="tempTC_30") } else { rename (files="elgLine."//inExtn, newname="tempTC_21") rename (files="elgLnFlx."//inExtn, newname="tempTC_22") rename (files="elgLnUnc."//inExtn, newname="tempTC_23") rename (files="elgsigdv."//inExtn, newname="tempTC_24") rename (files="elgLnID."//inExtn, newname="tempTC_25") rename (files="elgRed."//inExtn, newname="tempTC_30") } !awk '{if ($17==5.0) print $0}' tempTC_30 > tempTC_31 !awk '{if (($17<5.0)||($17>5.0)) print $0}' tempTC_30 > tempTC_32 rename (files="elgRed."//prevExtn, newname="tempTC_40") !awk '{if ($17==5.0) print $0}' tempTC_40 > tempTC_41 !awk '{if (($17<5.0)||($17>5.0)) print $0}' tempTC_40 > tempTC_42 if (appRes==yes) { concat (input_fi="elgLine."//prevExtn//",tempTC_21", output_f="", >> "elgLine."//outExtn) concat (input_fi="elgLnFlx."//prevExtn//",tempTC_22", output_f="", >> "elgLnFlx."//outExtn) concat (input_fi="elgLnUnc."//prevExtn//",tempTC_23", output_f="", >> "elgLnUnc."//outExtn) concat (input_fi="elgsigdv."//prevExtn//",tempTC_24", output_f="", >> "elgsigdv."//outExtn) concat (input_fi="elgLnID."//prevExtn//",tempTC_25", output_f="", >> "elgLnID."//outExtn) concat (input_fi="tempTC_41,tempTC_31,tempTC_42,tempTC_32", output_f="", >> "elgRed."//outExtn) } else { concat (input_fi="tempTC_21,elgLine."//prevExtn, output_f="", >> "elgLine."//outExtn) concat (input_fi="tempTC_22,elgLnFlx."//prevExtn, output_f="", >> "elgLnFlx."//outExtn) concat (input_fi="tempTC_23,elgLnUnc."//prevExtn, output_f="", >> "elgLnUnc."//outExtn) concat (input_fi="tempTC_24,elgsigdv."//prevExtn, output_f="", >> "elgsigdv."//outExtn) concat (input_fi="tempTC_25,elgLnID."//prevExtn, output_f="", >> "elgLnID."//outExtn) concat (input_fi="tempTC_31,tempTC_41,tempTC_32,tempTC_42", output_f="", >> "elgRed."//outExtn) } } # Counting objects in output files: --------------------------------- print (" ") print ("==============================================================") print (" ") print (" Output Catalogue Lengths:") print (" ") # if ((toCull=="non-contin")||(toCull=="both")) { # i.e. comment out, since elgRed applies to *both* contin/non-contin fields (files="elgRed."//outExtn, fields="1", lines="1-", quit_if-, print_f-, >> "tempTC_10") flist="tempTC_10" j=0 while ( fscan(flist, xc) != EOF) { j=j+1 } print (" -> elgRed."//outExtn//": "//j) # } if ((toCull=="contin")||(toCull=="both")) { fields (files="elgLine."//outExtn, fields="1", lines="1-", quit_if-, print_f-, >> "tempTC_11") flist="tempTC_11" j=0 while ( fscan(flist, xc) != EOF) { j=j+1 } print (" -> elgLine."//outExtn//": "//j) print (" -> elgLnFlx."//outExtn//": "//j) print (" -> elgLnUnc."//outExtn//": "//j) print (" -> elgsigdv."//outExtn//": "//j) print (" -> elgLnID."//outExtn//": "//j) } print (" ") # # *** COPY tapdraw.out to something permanent !!! **** # copy ids file to something permanent. # # Clean-up at end: imdelete (image="tempTC_img*", ver-, def+, go_ahead+) delete (files="tempTC_*",go_ahea+,ver-) # Main AWK script is in tempTC_0; other files are tempTC_? print (" ") print (" ") print ("==============================================================") print (" ") print (" Done. (tempTCids1 and tempTCids2 store saved IDs)") print (" ") end