procedure autoalign(reference,images,outimage) #This task aligns images based on RA and DEC header information. #Images should #(1) be corrected for geometric distortion #(2) have N up and E to left #(3) have platescale of 0.495 arcsec/pixel # #getshifts.cl is a required task. getshifts.cl assumes N is up, E to #left and the platescale is 0.495 arcsec/pixel. # #autoalign parameters are: # reference = reference image for aligning, all other # images will be mapped to this image # # images = list of images to be aligned. reference image # should be first in the list. # # outimage = name of aligned image # # oldpos = hidden parameter. Default is no, but if you # set this to yes, the task will use the existing # file, if it exists, of star positions in the # reference image # #Add the following lines to your loginuser.cl file: # task autoalign = /path where you keep scripts/autoalign.cl # task getshifts = /path where you keep scripts/getshifts.cl # string reference {prompt="reference image"} string images {prompt="images/image list (@) to be aligned"} string outimage {prompt="final,co-added image"} bool oldpos {no, prompt="use existing star position file?"} struct *inl begin real xref,yref,xin,yin,xshift,yshift,x,y string ref,im,out,c1,list1,list2,current,outlist int i bool dummy # ------------------------------------- ref=reference im=images out = outimage # delete temporary files, if they exist # -------------------------------------- if (access ('shifts')) { del ('shifts') } if (access ('trashbin')) { del ('trashbin') } if (access ('shiftedlist')) { imdelete('@shiftedlist',v-) del ('shiftedlist') } if (!oldpos && access ('pos')) { del ('pos') } if (access ('outlist')) { del ('outlist') } if (!access ('pos')){ # display the reference image and get the coordinates # --------------------------------------------------- print('---------------------------------------') print('Displaying the reference image..') print('Mark (all) stars for shift calculation') print('Exit with CTRL D') print('---------------------------------------') display(ref,1,>>'trashbin') rimcur(ref,wcs="logical",>'pos') } # expand the input template # -------------------------- if (access("tmplst")) { delete("tmplst",v-) } i=strlen(im) c1 = substr(im,1,1) # template or @-list? # -------------------- # if (c1 == "@") { copy(substr(im,2,i),"tmplst",v-) } else { section(im, option="fullname") | sort(> "tmplst") } # Note: now "tmplst" has the list of files to be aligned # Create list of aligned images # ---------------------------------------------- inl="tmplst" while (fscan(inl,current) != EOF) { print("r"//current,>>"outlist") # this is the output list for the next task "imalign" } inl = "tmplst" # get initial estimate of shifts from RA and DEC header info getshifts(ref,im,"shifts") #------------ # align the images...... imalign(im,ref,'pos',"@outlist",shifts='shifts') files("@outlist",>'shiftedlist') # and co-add the aligned images... #( change the following parameters according to the # application) imcombine('@shiftedlist',out,combine='average', scale='none',zero='median',reject='ccdclip', statsec='[400:600,400:600]',rdnoise='RDNOISE', gain='GAIN',lsigma=3,hsigma=3) # display final image print("Displaying final image ",out) display(out,1) end