procedure markall(image) char image ="" {prompt="image name"} real zlo =0. {prompt="lower cut level (display)"} real zhi =0. {prompt="upper cut level"} bool gal =yes {prompt="mark galaxies?"} bool star =yes {prompt="mark stars?"} bool cosmic =yes {prompt="mark cosmics?"} bool del =yes {prompt="mark CCD defects?"} bool append =no {prompt="append to existing position files?"} bool redispl =yes {prompt="(re)display image first?"} # @(#) task markall Author: R.A. Jansen -- Apr 19 1996 # @(#) # @(#) task to interactively mark all galaxies, all stars, all cosmic # @(#) ray events and all CCD defects on the image display. This task # @(#) replaces task 'surfphot.mark'. Uses 'tv.tvmark'. # @(#) # @(#) Jun.21 2000 -- Added support for other image formats. (R.A.J.) begin string img, imtyp, imrp, galfile, starfile, crfile, delfile file tmptvmark string cmd, cursor, key, arg, val, tst, previous real rad, x, y, x0, y0, r2, r, t int imglen, l, ncol, nrow img = image rad = 2 # Check whether input image exists unlearn chkimg ; chkimg (img, "access", imtype="", verbose=yes) if (!chkimg.ok) { return } img = chkimg.imroot imglen = chkimg.imglen imtyp = chkimg.imtype imrp = chkimg.imrpstr imgets (img//imtyp//imrp, "naxis1"); ncol = int(imgets.value) imgets (img//imtyp//imrp, "naxis1"); ncol = int(imgets.value) imgets (img//imtyp//imrp, "naxis2"); nrow = int(imgets.value) # Check whether anything is supposed to be marked if ( !gal && !star && !cosmic && !del ) { error (1,"No operations (gal=star=cosmic=del=no)! Exit...") } galfile = img//".pos.gal" starfile = img//".pos.star" crfile = img//".pos.cosmic" delfile = img//".pos.del" # If older versions of positions/regions files are present and append=no, # rename them. NB: The 'verbose' option in task copy seems not to be implemented! if ( (access(galfile)&&gal) || (access(starfile)&&star) || (access(crfile)&&cosmic) || (access(delfile)&&del) ) { if (!append) { print ("Renaming older versions of output files...") if ( access(galfile) && gal ) { if ( access(galfile//"~") ) { delete (galfile//"~", yes, verify=no) } copy (galfile, galfile//"~", verbose=yes) print (" "//galfile//" --> "//galfile//"~") delete (galfile) } if ( access(starfile) && star ) { if ( access(starfile//"~") ) { delete (starfile//"~", yes, verify=no) } copy (starfile, starfile//"~", verbose=yes) print (" "//starfile//" --> "//starfile//"~") delete (starfile) } if ( access(crfile) && cosmic ) { if ( access(crfile//"~") ) { delete (crfile//"~", yes, verify=no) } copy (crfile, crfile//"~", verbose=yes) print (" "//crfile//" --> "//crfile//"~") delete (crfile) } if ( access(delfile) && del ) { if ( access(delfile//"~") ) { delete (delfile//"~", yes, verify=no) } copy (delfile, delfile//"~", verbose=yes) print (" "//delfile//" --> "//delfile//"~") delete (delfile) } } else { print ("Appending to older versions of output files...") } } # Display image is redispl=yes if (redispl) { xdisplay (img//imtyp//imrp, z1=zlo, z2=zhi) } if (gal) { # Mark all galaxies in the image print ("Wait for the cursor cross to appear in the image display area,") print ("then mark all galaxies in the image.") print ("Options: type v twice -- circle") print (" type b twice -- rectangle") print (" type :rad radlen -- set radius of circle to radlen") print (" type c -- circle with radius radlen") print (" type q -- quit") print ("NB: after colon, don't type 'rad' to quickly") sleep(2) tmptvmark=mktemp("tvmark") tvmark (frame=1, coor="", logfile=tmptvmark, autolog=yes, outimage="", mark="plus", radii="0", lengths="0", label=no, number=no, nxoffset=0, nyoffset=0, txsize=1, pointsize=3, font="raster", color=201, commands="", interactive=yes, > "dev$null", >& "STDERR" ) list=tmptvmark previous="" while( fscan(list,x,y,key,cmd,arg,val) != EOF ) { if ( x < 1. ) x = 1. if ( x > ncol) x = ncol if ( y < 1. ) y = 1. if ( y > nrow) y = nrow if ( cmd == ":") { l = strlen(cmd) cursor = substr(cmd,4,l) if (substr(arg,1,3) == "rad") { tst = fscan(val,rad) } else { print("ERROR: Invalid command ",arg, > "STDERR" ) } } else { if (cmd == "c") { print(x,y,rad, >> galfile) } else if (previous =="") { previous=cmd x0=x y0=y } else { if (previous == cmd) { if (previous=="v") { # MASK A CIRCLE !! r2=(x0-x)*(x0-x)+(y0-y)*(y0-y) r=sqrt(r2) print (x0,y0,r, >> galfile) previous="" } else if (previous=="b") { if (x0 > x) { t=x0 x0=x x=t } if (y0 > y) { t=y0 y0=y y=t } print (x0,x,y0,y, >> galfile) previous="" } else { print (" Error: do not recognize ",cmd, > "STDERR") } } else { print(" Error: invalid sequence ",> "STDERR") previous=cmd x0=x y0=y } } } } delete(tmptvmark,verify=no) } if (star) { # Mark all stars (and regions affected by star glow) in the image print ("Wait for the cursor cross to appear in the image display area,") print ("then mark all stars in the image.") sleep(2) tmptvmark=mktemp("tvmark") tvmark (frame=1, coor="", logfile=tmptvmark, autolog=yes, outimage="", mark="point", radii="0", lengths="0", label=no, number=no, nxoffset=0, nyoffset=0, txsize=1, pointsize=3, font="raster", color=204, commands="", interactive=yes, > "dev$null", >& "STDERR" ) list=tmptvmark previous="" while( fscan(list,x,y,key,cmd,arg,val) != EOF ) { if ( x < 1. ) x = 1. if ( x > ncol) x = ncol if ( y < 1. ) y = 1. if ( y > nrow) y = nrow if ( cmd == ":") { l = strlen(cmd) cursor = substr(cmd,4,l) if (substr(arg,1,3) == "rad") { tst = fscan(val,rad) } else { print("ERROR: Invalid command ",arg, > "STDERR" ) } } else { if (cmd == "c") { print(x,y,rad, >> starfile) } else if (previous =="") { previous=cmd x0=x y0=y } else { if (previous == cmd) { if (previous=="v") { # MASK A CIRCLE !! r2=(x0-x)*(x0-x)+(y0-y)*(y0-y) r=sqrt(r2) print (x0,y0,r, >> starfile) previous="" } else if (previous=="b") { if (x0 > x) { t=x0 x0=x x=t } if (y0 > y) { t=y0 y0=y y=t } print (x0,x,y0,y, >> starfile) previous="" } else { print (" Error: do not recognize ",cmd, > "STDERR") } } else { print(" Error: invalid sequence ",> "STDERR") previous=cmd x0=x y0=y } } } } delete(tmptvmark,verify=no) } if (cosmic) { # Mark all cosmics in the image print ("Wait for the cursor cross to appear in the image display area,") print ("then mark all cosmics in the image.") sleep(2) tmptvmark=mktemp("tvmark") tvmark (frame=1, coor="", logfile=tmptvmark, autolog=yes, outimage="", mark="point", radii="0", lengths="0", label=no, number=no, nxoffset=0, nyoffset=0, txsize=1, pointsize=3, font="raster", color=206, commands="", interactive=yes, > "dev$null", >& "STDERR" ) list=tmptvmark previous="" while( fscan(list,x,y,key,cmd,arg,val) != EOF ) { if ( x < 1. ) x = 1. if ( x > ncol) x = ncol if ( y < 1. ) y = 1. if ( y > nrow) y = nrow if ( cmd == ":") { l = strlen(cmd) cursor = substr(cmd,4,l) if (substr(arg,1,3) == "rad") { tst = fscan(val,rad) } else { print("ERROR: Invalid command ",arg, > "STDERR" ) } } else { if (cmd == "c") { print(x,y,rad, >> crfile) } else if (previous =="") { previous=cmd x0=x y0=y } else { if (previous == cmd) { if (previous=="v") { # MASK A CIRCLE !! r2=(x0-x)*(x0-x)+(y0-y)*(y0-y) r=sqrt(r2) print (x0,y0,r, >> crfile) previous="" } else if (previous=="b") { if (x0 > x) { t=x0 x0=x x=t } if (y0 > y) { t=y0 y0=y y=t } print (x0,x,y0,y, >> crfile) previous="" } else { print (" Error: do not recognize ",cmd, > "STDERR") } } else { print(" Error: invalid sequence ",> "STDERR") previous=cmd x0=x y0=y } } } } delete(tmptvmark,verify=no) } if (del) { # Mark all CCD defects in the image print ("Wait for the cursor cross to appear in the image display area,") print ("then mark all CCD defects in the image.") sleep(2) tmptvmark=mktemp("tvmark") tvmark (frame=1, coor="", logfile=tmptvmark, autolog=yes, outimage="", mark="point", radii="0", lengths="0", label=no, number=no, nxoffset=0, nyoffset=0, txsize=1, pointsize=3, font="raster", color=207, commands="", interactive=yes, > "dev$null", >& "STDERR" ) list=tmptvmark previous="" while( fscan(list,x,y,key,cmd,arg,val) != EOF ) { if ( x < 1. ) x = 1. if ( x > ncol) x = ncol if ( y < 1. ) y = 1. if ( y > nrow) y = nrow if ( cmd == ":") { l = strlen(cmd) cursor = substr(cmd,4,l) if (substr(arg,1,3) == "rad") { tst = fscan(val,rad) } else { print("ERROR: Invalid command ",arg, > "STDERR" ) } } else { if (cmd == "c") { print(x,y,rad, >> delfile) } else if (previous =="") { previous=cmd x0=x y0=y } else { if (previous == cmd) { if (previous=="v") { # MASK A CIRCLE !! r2=(x0-x)*(x0-x)+(y0-y)*(y0-y) r=sqrt(r2) print (x0,y0,r, >> delfile) previous="" } else if (previous=="b") { if (x0 > x) { t=x0 x0=x x=t } if (y0 > y) { t=y0 y0=y y=t } print (x0,x,y0,y, >> delfile) previous="" } else { print (" Error: do not recognize ",cmd, > "STDERR") } } else { print(" Error: invalid sequence ",> "STDERR") previous=cmd x0=x y0=y } } } } delete(tmptvmark,verify=no) } list = "" print ("All done.") end