procedure tpipe (skiplist,convFits,skipRenSub,obsdate1,obsdate2,obsdate3,start1, end1,start2,end2,start3,end3,nScans,impref,subSBias,supBias,biasect,trisect, medavg,dirn,divflat,flatlist,oneflat,flatImg,subSky,maxs,smooth,boxs,nm,min, tflatreg, delbmaps, delbias) bool skiplist {no, prompt="Skip list generation if lists already exist?"} bool convFits {no, prompt="Convert input images to FITS (incl bias/flats)?"} bool skipRenSub {no, prompt="Skip initial image renaming and bias-subtraction?"} string obsdate1 {prompt="Date prefix, scan 1"} string obsdate2 {prompt="Date prefix, scan 2"} string obsdate3 {prompt="Date prefix, scan 3"} int start1 {prompt=" Image number of starting image, scan 1"} int end1 {prompt=" Image number of ending image, scan 1"} 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)"} string impref {"s", prompt="Image prefix (string) to assign all scans"} bool subSBias {yes, prompt="Subtract a preliminary super-bias?"} string supBias {"bias04apr", prompt="Name of super-bias image"} string biasect {"[1605:1620,1:1600]", prompt="colbias: Bias section"} string trisect {"[1:1600,1:1600]", prompt="colbias: Trim section (**SAME SIZE AS FLAT-FIELD)"} bool medavg {yes, prompt="colbias: Use med instead of avg in column bias?"} int dirn {3, prompt="0=no flip; 1=x-flip; 2=y-flip; 3=both x and y-flip"} 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 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?"} bool delbias {no, prompt="Delete raw bias-subtracted images when done?"} struct *flist # 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 print (" ") print (" Start time:") time # 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 } # 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 (skipRenSub==no) { 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 ** --------------------------------------: # 1. Renaming raw image files (and converting to fits if requested): print (" ") print (" ") 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 (" ") print ("2. Subtract bias using superbias/colbias:") print (" (Takes approx. 5 min on 30 images.)") if (subSBias==yes) { print (" ") print(" Subtracting super-bias ...") imarith (operand1="@list2",op="-",operand2=supBias, 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) } 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+) } # end of skipRenSub 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 } flatfile = "@"//flatlist 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 } if ((nScans>=1)&&(nScans<=3)) { imarith (operand1="@list4//b",op="/",operand2=flatImg, result="@list4//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if ((nScans>=2)&&(nScans<=3)) { imarith (operand1="@list5//b",op="/",operand2=flatImg, result="@list5//ff",title="",divzero=0.,hparams="",pixtype="",calctyp="", verbose+,noact-,flpar-) } if (nScans==3) { imarith (operand1="@list6//b",op="/",operand2=flatImg, 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+) } # 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.") } } 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