procedure tapdraw (readAps, elgFile, colQnt, apFile, mosImage, frm, ap1, ap2, ap3, ap4, nSl, hf, Nc, hs, ws, vs, wrtcoord, verb, inclIDs, txtheight, inclAps, firstFrm, saveImg, outImg, stdX, stdY) bool readAps {no, prompt="Read apertures from elgLine files?"} string elgFile {"-", prompt=" -> Emission catalogue filename?"} int colQnt {1, prompt=" -> File column to take IDs from"} string apFile {"aps.best", prompt=" OR File listing apertures and IDs"} string mosImage {"d13e7strips",prompt="Mosaic image (full name)"} int frm {1,prompt="Frame to display in"} int ap1 {7,prompt=" Aperture 1 to draw"} int ap2 {13,prompt=" Aperture 2 to draw"} int ap3 {19,prompt=" Aperture 3 to draw"} int ap4 {32,prompt=" Aperture 4 to draw"} int nSl {10,prompt="Number of image slices"} int hf {25,prompt="Half-length of box (in pix)"} int Nc {7,prompt="Number of objects per column"} int hs {2, prompt="Horizontal spacing between slices (pix)"} int ws {10, prompt="Horizontal spacing between scan cols (pix)"} int vs {5, prompt="Vertical spacing between scans (pix)"} bool wrtcoord {yes, prompt="Write mosaic coords to tapdraw.out?"} bool verb {yes,prompt="Verbose output?"} bool inclIDs {yes, prompt="Include object IDs on mosaic?"} int txtheight {2, prompt=" -> Text font size"} bool inclAps {yes, prompt="Include apertures on mosaic?"} bool firstFrm {yes, prompt=" -> apertures on first frame only?"} bool saveImg {yes, prompt="Save labelled image to file?"} string outImg {"d13e7mos10", prompt=" -> Name of output image"} int stdX {2048, prompt=" Size of STDIMAGE in X"} int stdY {2048, prompt=" Size of STDIMAGE in Y"} struct *clist # list-directed structure to go thru coordFile begin # Variable Declarations: int candNo, apert # candidate number and its aperture int x,y # coords of each aperture circle (in turn) int row, col # current row and column string awkLine # awk executable string int apRad # aperture radius int j # counter int Ymax # maximum in Y-dirn int colwidth # width (in pix) of a whole column real id # ID of the current object string symb # "circle" or "none" mark-type in tvmark int mosX, mosY # dimensions of mosaic-strip image int x1, x2, y1, y2 string trimStr # string for trimming tvmark output images # Make sure the IMAGES and IMGTOOLS packages are loaded: if (! defpac ("images")) { print("IMAGES package not loaded") bye } if (! defpac ("sdisplay")) { print("STSDAS.GRAPHICS.SDISPLAY package not loaded") bye } if (saveImg==yes) { imdelete (image=outImg, ver-, def+, go_ahead+) } imdelete (image="tapImg*", ver-, def+, go_ahead+) delete (files="temp_tapdraw*",go_ahea+,ver-) if (wrtcoord==yes) { delete (files="tapdraw.out",go_ahea+,ver-) } if (saveImg==yes) { print (" ") print ("*****************************************************") print (" ") imhead (images=" ", imlist=mosImage, longhead-, userfie+) print (" ") print ("*****************************************************") print (" ") print (" -> Please input these values from information above") print (" 1. Size of strip-mosaic in X:") scan (mosX) print (" 2. Size of strip-mosaic in Y:") scan (mosY) print (" ") print (" -> thank you (please wait)...") print (" ") print (" ") x1=int((stdX-mosX)/2) x2=int(x1+mosX) y1=int((stdY-mosY)/2) y2=int(y1+mosY) trimStr="tapImg1["//x1//":"//x2//","//y1//":"//y2//"]" } # Extracting a file of apertures from elgFile (if requested): if (readAps==yes) { if (elgFile=="-") { print (" ") print (" *** ERROR: No elgFile specified. ***") print (" --> Please try again.") print (" ") bye } # i.e. checking that elgFile has been specified if (verb==yes) { print (" ") print (elgFile//":") print ("Extracting apertures from col 4 (please wait)...") print (" ") } awkLine="awk '{print $4, $"//colQnt//"}' "//elgFile awkLine=awkLine//" > temp_tapdraw20" print (awkLine, > "temp_tapdraw30") !chmod 777 temp_tapdraw30 !temp_tapdraw30 apFile="temp_tapdraw20" } if (elgFile=="=") { print (" ") print (" *** ERROR: No apFile specified. ***") print (" --> Please try again.") print (" ") bye } # Grouping objects on the basis of aperture: if (verb==yes) { print (" ") print ("Grouping objects on the basis of aperture (please wait)...") print (" ") } awkLine="awk '{a=a+1; if ($1=="//ap1//") {print a, " awkLine=awkLine//ap1//", $2}}' "//apFile//" > temp_tapdraw2" print (awkLine, > "temp_tapdraw1") awkLine="awk '{a=a+1; if ($1=="//ap2//") {print a, " awkLine=awkLine//ap2//", $2}}' "//apFile//" > temp_tapdraw3" print (awkLine, >> "temp_tapdraw1") awkLine="awk '{a=a+1; if ($1=="//ap3//") {print a, " awkLine=awkLine//ap3//", $2}}' "//apFile//" > temp_tapdraw4" print (awkLine, >> "temp_tapdraw1") awkLine="awk '{a=a+1; if ($1=="//ap4//") {print a, " awkLine=awkLine//ap4//", $2}}' "//apFile//" > temp_tapdraw5" print (awkLine, >> "temp_tapdraw1") !chmod 777 temp_tapdraw1 !temp_tapdraw1 !cat temp_tapdraw2 temp_tapdraw3 temp_tapdraw4 temp_tapdraw5 > temp_tapdraw6 # Displaying image: if (verb==yes) { print (" ") print ("Displaying apertures in frame "//frm//" ...") print (" ") } display (image=mosImage,fra=frm,bpdispl="none",erase+,bord-, sele+,repe-,fill-,zscal+,ztrans="linear", >>"temp_tapdrawJNK") Ymax=Nc*(2*hf+1+vs)-vs+1 colwidth=int((nSl*(2*(hf+0.5)+hs)+ws-hs)) if (verb==yes) { print (" ") print (" Width of a complete column: "//colwidth) print (" ") } # Main aperture-plotting loop: -------------------------------- clist = "temp_tapdraw6" while ( fscan(clist,candNo,apert, id) != EOF) { # print (candNo, apert) delete (files="temp_tapdraw7",go_ahea+,ver-) col=int((candNo-1)/Nc)+1 row=candNo-(col-1)*Nc # Calculating coords for mosaic image and writing to file: j=1 while (j<=nSl) { x=(2*j-1)*(hf+0.5)+(j-1)*hs x=x+(col-1)*colwidth x=int(x)+1 y=Ymax-((2*row-1)*(hf+0.5)+(row-1)*vs) y=int(y) if (j==1) { if (inclIDs==yes) { print (x, y, id, >> "temp_tapdraw7") } else { print (x, y, >> "temp_tapdraw7") } } # i.e. ID only written on frame 1 if requested if ((j>1)&&(firstFrm==no)){ print (x, y, >> "temp_tapdraw7") } # i.e. id only written on remaining frames if requested if (wrtcoord==yes) { print (candNo, x, y, id, >> "tapdraw.out") } j=j+1 } apRad = int(apert/2) if (inclAps==yes) { symb="circle" } else { symb="none" } tvmark(frame=frm,coords="temp_tapdraw7",logfile="",autolog-, outimag="", mark=symb,radii=apRad,lengths=0,font="raster",color=200, label+,number-,nxoffse=5,nyoff=10,pointsi=3,txsize=txtheight,interac-) } # -------------------------------------------------------------- if (saveImg==yes) { print (" Saving image...") print (" ") dsimg (frame=frm, image="tapImg1", maxrange+) print (" ------") print (frm) print ("trimStr = "//trimStr) print ("outImg = "//outImg) imcopy(input=trimStr, output=outImg, verb-) # imdelete (image="tapImg1", ver-, def+, go_ahead+) } print(" ") # imdelete (image="tapImg*", ver-, def+, go_ahead+) delete (files="temp_tapdraw*",go_ahea+,ver-) if (verb==yes) { if (wrtcoord==yes) { print (" ") print (" File tapdraw.out written.") print (" ") } print (" ") print ("Done.") print (" ") } end