procedure tstar (skiplist,skipRen,convFits,obsdate1,start1,end1,skipBias, impref,biasect,x1,x2, y1, y2, xoff, yoff, xZero, yZero, medavg,divflat,flatlist,oneflat,flatImg, delbias) bool skiplist {no, prompt="Skip list generation if lists already exist?"} bool skipRen {no, prompt="Skip image rename and bias subtraction?"} bool convFits {no, prompt="Convert input images to FITS (incl bias/flats)?"} string obsdate1 {prompt="Date prefix, scan 1"} int start1 {prompt=" Image number of starting image, scan 1"} int end1 {prompt=" Image number of ending image, scan 1"} bool skipBias {no,prompt="Skip rename/bias-subtn if *b imgs exist?"} string impref {"s", prompt="Image prefix (string) to assign all scans"} string biasect {"[305:320,1:300]", prompt="colbias: Bias section"} int x1 {1, prompt="colbias: Trim section, x1"} int x2 {300, prompt="colbias: Trim section, x2"} int y1 {1, prompt="colbias: Trim section, y1"} int y2 {300, prompt="colbias: Trim section, y2"} int xoff {975, prompt="Lower LH (small central frame) wrt FULL CCD: X"} int yoff {1999, prompt="Lower LH (small central frame) wrt FULL CCD: Y"} int xZero {201, prompt=" Lower LH (larger frame) wrt to FULL CCD: X"} int yZero {1301, prompt=" Lower LH (larger frame) wrt to FULL CCD: Y"} bool medavg {yes, prompt="colbias: Use med instead of avg in column bias?"} bool divflat {no, prompt="Divide each image by a matching flat-field?"} string flatlist {"-", prompt="-> List of flat-fields (unflipped; ready to use; full names)"} bool oneflat {no, prompt="OR Divide all images by a common flat-field?"} string flatImg {"-", prompt="-> Single flat-field (unflipped; ready to use; full name)"} bool delbias {no, prompt="Delete raw bias-subtracted images when done?"} struct *flist # list-directed structure to go thru a scan file struct *flist2 # list-directed structure to go thru a scan file begin # Variable Declarations: string refImage # Full name of chosen reference image string coordFile # Name of coordinate file assoc with ref image string dummy # dummy string to store input read in from # a scan file string dummy2 # shortened version of dummy string action # action on whether to bail out after imalign int k1, k2 # character lengths of image prefix and dummy string region # region around first star in the reference # image coords file, for modal scaling string flatfile string flatfile2 # names of files listing scan flat-fields # string bias1 # string bias2 # names of the super-bias during FITS-ing string trisect # trim-section string for colbias string fullsect # same region as trim-sect wrt to large frame # (and NOT wrt to full chip) int xw, yw # top RH corner of regions wrt full chip string flatImg2 # string containing image name with region int nScans # number of scans (1 always, here) int xLH, yLH, xRH, yRH # dimensions of small window measured wrt # to large frame (NOT full chip) print (" ") print (" Start time:") time # Defining regions: trisect = "["//x1//":"//x2//","//y1//":"//y2//"]" xLH=(xoff-(xZero-1)+(x1-1)) yLH=(yoff-(yZero-1)+(y1-1)) xw = (x2-x1) yw = (y2-y1) xRH = xLH+xw yRH = yLH+yw fullsect = "["//xLH//":"//xRH//","//yLH//":"//yRH//"]" print (" ") print ("Trim Section: "//trisect) print ("wrt to large image: "//fullsect) print (" ") # Cleaning-up stray files: delete (files="temp_*.out",go_ahea+,ver-) if (skiplist==no) { delete (files="list?",go_ahea+,ver-) delete (files="list??",go_ahea+,ver-) } if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } if (! defpac ("bias")) { print("Package NOAO.IMRED.BIAS needs to be loaded.") bye } if (! defpac ("generic")) { print("Package NOAO.IMRED.GENERIC needs to be loaded.") bye } nScans=1 # Creating Lists: ---------------------------------------------- # (a) Creating individual scan lists (4,5,6) ------------------- # in addition to full scan list (2): ----------------------- # # list1 - (redundant) # list1a - list 4 with date prefix # list1b - list 5 with date prefix # list1c - list 6 with date prefix # list2 - full scan list # list3 - (redundant) # list4 - scan 1 # list5 - scan 2 # list6 - scan 3 # list7 - list 2 with rm prefix # list8 - list 2 with r suffix (extension) # list9 - list 2 with .fits extension # list10 - list 2 with tmp extension (i.e. temporary files) if (skiplist==no) { if ((nScans>=1)&&(nScans<=3)) { tmakefile (file_out="list4",startNum=start1,stopNum=end1, prefixOU=impref,anyExtn-,extnOU="",padOU+,listImgs-) tmakefile (file_out="list1a",startNum=start1,stopNum=end1, prefixOU=obsdate1,anyExtn-,extnOU="",padOU+,listImgs-) !cp list4 list2 } if ((nScans>=2)&&(nScans<=3)) { tmakefile (file_out="list5",startNum=start2,stopNum=end2, prefixOU=impref,anyExtn-,extnOU="",padOU+,listImgs-) tmakefile (file_out="list1b",startNum=start2,stopNum=end2, prefixOU=obsdate2,anyExtn-,extnOU="",padOU+,listImgs-) ! cat -s list2 list5 >> list2 } if (nScans==3) { tmakefile (file_out="list6",startNum=start3,stopNum=end3, prefixOU=impref,anyExtn-,extnOU="",padOU+,listImgs-) tmakefile (file_out="list1c",startNum=start3,stopNum=end3, prefixOU=obsdate3,anyExtn-,extnOU="",padOU+,listImgs-) ! cat -s list2 list6 >> list2 } if (nScans>3) { print (" ") print (" *** Invalid number of scans *** ") bye } if (nScans<1) { print (" ") print (" *** Invalid number of scans *** ") bye } # (b) Creating variations on the full scan list (1,3,7): -------- k1 = strlen(impref) flist = "list2" while ( fscan(flist, dummy) != EOF) { k2 = strlen(dummy) dummy2 = substr(dummy, k1+1, k2) # print (obsdate//dummy2, >> "list1") # print (dummy//"[*,-*]", >> "list3") print ("rm"//dummy, >> "list7") print (dummy//"r", >> "list8") print (dummy//".fits", >> "list9") print (dummy//"tmp", >> "list10") } } # i.e. end of (skiplist==no) option # --------------------------------------------------------------- # ** Background Removal ** --------------------------------------: if (skipRen==no) { # 1. Renaming raw image files (and converting to fits if requested): print (" ") print (" ") if (skipBias==no) { print ("1. Renaming raw image files ...") imrename (oldnames="@list1a",newnames="@list4",verbose+) if ((nScans>=2)&&(nScans<=3)) { imrename (oldnames="@list1b",newnames="@list5",verbose+) } if (nScans==3) { imrename (oldnames="@list1c",newnames="@list6",verbose+) } } if (convFits==yes) { # print (" (Converting to fits format ...)") # imdelete (images="@list9",verify=no,default=yes, go_ahead=yes) # i.e. deleting poss FITS files with these names; precautionary # imrename (oldnames="@list2",newnames="@list10",verb=no) # wfits(iraf_fil="@list10",fits_fil="@list9", make_im+,long_he-, short_h+,bitpix=0,blockin=0,scale+,autosca+, bscale=1.,bzero=0.) # imdelete (images="@list10",verify=no,default=yes, go_ahead=yes) # i.e. deleting IRAF format images (which have the tmp extn) # flatfile = "@"//flatlist # flatfile2 = "@"//flatlist//"tmp" # imrename (oldnames=flatfile,newnames=flatfile2,verb=no) # flatfile = "@"//flatlist//".fits" # imdelete (images=flatfile,verify=no,default=yes, go_ahead=yes) # i.e. deleting poss FITS files with these names; precautionary # wfits(iraf_fil=flatfile2,fits_fil=flatfile, make_im+,long_he-, short_h+,bitpix=0,blockin=0,scale+,autosca+, bscale=1.,bzero=0.) # imdelete (images=flatfile2,verify=no,default=yes, go_ahead=yes) # bias1 = supBias//".fits" # bias2 = supBias//"tmp" # imrename (oldnames=supBias,newnames=bias2,verb=no) # imdelete (images=bias1,verify=no,default=yes, go_ahead=yes) # i.e. deleting poss FITS files with these names; precautionary # wfits(iraf_fil=bias2,fits_fil=bias1, make_im+,long_he-, short_h+,bitpix=0,blockin=0,scale+,autosca+, bscale=1.,bzero=0.) # imdelete (images=bias2,verify=no,default=yes, go_ahead=yes) } # 2. Subtract bias using super-bias/colbias (no extn --> b): print (" ") if (skipBias==no) { print ("2. Subtract bias using colbias:") print (" ") print(" Using colbias (please wait; this takes time ...)") colbias (input="@list2",output="@list2//b",bias=biasect,trim=trisect, median=medavg,interac-,functio="chebyshev",order=5,low_rej=3,high_rej=3,niter=3, logfile-) imdelete (images="@list2",verify-,default+,go_ahead+) } } # i.e. end of (skipRen==no) option # 3. Dividing by flat-fields (b --> ff): if ((divflat==yes)&&(oneflat==no)) { print (" ") print (" ") print ("3. Dividing each image by its matching flat-field ...") if (flatlist=="-") { print (" ") print (" *** NO FLAT-FIELD LIST SPECIFIED ***") print (" --> Try again.") print (" ") bye } # Appending region to file names in list: ================ delete (files="temp_app.out", ver-, default+, allvers+, subfile+, go_ahead+, flpar-) flist2=flatlist while ( fscan(flist2, dummy) != EOF) { print (dummy//fullsect, >> "temp_app.out") } # copy (input=flatlist, output="temp_app.out", verb+) flatfile = "@"//"temp_app.out" if ((nScans>=1)&&(nScans<=3)) { imarith (operand1="@list4//b",op="/",operand2=flatfile, result="@list4//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if ((nScans>=2)&&(nScans<=3)) { imarith (operand1="@list5//b",op="/",operand2=flatfile, result="@list5//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if (nScans==3) { imarith (operand1="@list6//b",op="/",operand2=flatfile, result="@list6//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } } if ((divflat==no)&&(oneflat==yes)) { print (" ") print (" ") print ("3. Dividing each image by the same flat-field ...") if (flatImg=="-") { print (" ") print (" *** NO FLAT-FIELD IMAGE SPECIFIED ***") print (" --> Try again.") print (" ") bye } # Appending region to file name: ================ flatImg2 = flatImg//fullsect if ((nScans>=1)&&(nScans<=3)) { imarith (operand1="@list4//b",op="/",operand2=flatImg2, result="@list4//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if ((nScans>=2)&&(nScans<=3)) { imarith (operand1="@list5//b",op="/",operand2=flatImg2, result="@list5//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if (nScans==3) { imarith (operand1="@list6//b",op="/",operand2=flatImg2, result="@list6//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } } if ((divflat==no)&&(oneflat==no)) { print ("(3. Not using any flat-fields but renaming biases for next step ...)" imcopy (input="@list2//b",output="@list2//ff",verbose+) } if (delbias==yes) { imdelete (images="@list2//b",verify-,default+,go_ahead+) } if (delbias==no) { print (" --> Bias-subtracted original images retained.") } # ** End of Background Removal ** ----------------------------------- # Cleaning-up stray temp files (image lists remain): delete (files="temp_*.out",go_ahea+,ver-) # Writing out list summary: print(" ") print(" ") print("Summary of image lists:") print("-----------------------") print ("Individual scan lists: (4,5,6)") print ("Full scan list: (2)") print ("list1 - (redundant)") print ("list1a - list 4 with date prefix") print ("list1b - list 5 with date prefix") print ("list1c - list 6 with date prefix") print ("list2 - full scan list") print ("list3 - (redundant)") print ("list4 - scan 1") print ("list5 - scan 2") print ("list6 - scan 3") print ("list7 - list 2 with rm prefix") print ("list8 - list 2 with r suffix (extension)") print ("list9 - list 2 with .fits extension") print ("list10 - list 2 with tmp extension (i.e. temporary files)") print (" ") # UNCOMMENT OUT BITS COMMENTED OUT BEFORE. print(" ") print (" Finish time:") time print(" ") print(" ") print ("Done.") print(" ") print(" ") end # bool subSBias {yes, prompt="Subtract a preliminary super-bias?"} # string supBias {"bias04apr", prompt="Name of super-bias image"} # int dirn {3, prompt="0=no flip; 1=x-flip; 2=y-flip; 3=both x and y-flip"} # string obsdate2 {prompt="Date prefix, scan 2"} # string obsdate3 {prompt="Date prefix, scan 3"} # string trisect {"[1:300,1:300]", prompt="colbias: Trim section"} # int start2 {prompt=" Image number of starting image, scan 2"} # int end2 {prompt=" Image number of ending image, scan 2"} # int start3 {prompt=" Image number of starting image, scan 3"} # int end3 {prompt=" Image number of ending image, scan 3"} # int nScans {3,prompt="Number of image scans (<=3)"} # bool subSky {no, prompt="Subtract sky rings? (tringSub)"} # real maxs {20., prompt=" tringSub: Amount of shift (in pix) for 9 images"} # bool smooth {no, prompt=" tringSub: Smooth background map before applying?"} # int boxs {40, prompt=" tringSub: -> Size of box for background smoothing"} # real nm {INDEF, prompt=" tflat: Normalization if not INDEF"} # real min {0., prompt=" tflat: Minimum data value to use in the FF"} # string tflatreg {"[440:1180,260:1220]", prompt=" tflat: Region to do stats on"} # bool delbmaps {no, prompt=" Delete background maps when done?"} # 4. Flipping (ff --> ff): # print (" ") # print (" ") # print ("4. Flipping ...") # tflip (imglist="list2",abbName+,extn="ff",flipdir=dirn,clobber+, outextn="") # 5. Generating normalised versions of images using tflat: # if (subSky==yes) { # print (" ") # print (" ") # print ("5. Generating normalised version of images ...") # tflat (imageFil="list2",normaliz=nm,minim=min,imageReg=tflatreg) # 6. Producing background maps and subtracting: # print (" ") # print (" ") # print (" ") # print (" ") # print ("6. Producing background maps and subtracting ...") # print (" (Takes approx. 45 min on 30 images.)") # tringSub (imageFil="list2",maxShift=maxs,smth=smooth,boxSize=boxs, doSubtra+,report-) # imdelete (images="@list2//f",verify-,default+,go_ahead+) # print (" ") # if (delbmaps==yes) { # imdelete (images="@list2//flat",verify-,default+,go_ahead+) # } # if (delbmaps==no) { # print (" --> Background maps from tringSub retained.") # } # } # print (" (Takes approx. 5 min on 30 images.)") # if (subSBias==yes) { # print (" ") # print(" Subtracting super-bias ...") # supBias2=supBias//fullsect # imarith (operand1="@list2",op="-",operand2=supBias2, result="@list10",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) # imdelete (images="@list2",verify-,default+,go_ahead+) # imrename (oldnames="@list10",newnames="@list2",verb=no) # }