# task getshifts = /home/bokobs/getshifts.cl #written by rf to automatically get offsets from image headers. Images # can then be aligned noninteractively. procedure getshifts (reference,files,shift_list) string reference {prompt="reference image"} string files {prompt="images/image list (@) to find shifts"} string shift_list {prompt="output filename containing shifts"} struct *inl begin real xref,yref,nx,ny,xshift,yshift int i string flist,c1,current string s1 string ref, fnames,shifts ref=reference fnames=files shifts=shift_list if (access(shifts)) {delete(shifts,v-)} # the following is taken from HW Rix align.cl if (access("tmplst2")) {delete("tmplst2",v-)} i=strlen(fnames) c1=substr(fnames,1,1) # did user enter a filename* or a list (@) of files? if (c1 == "@") { copy(substr(fnames,2,i),"tmplst2",v-) } else { section(fnames,option="fullname") | sort(> "tmplst2") } # now "tmplst2" contains list of files to find shifts of inl = "tmplst2" # end of HW - mouching # read through header of ref image and get RA and Dec. # these are stored in xref and yref, respectively. imgets(ref,"RA") xref = real(imgets.value) imgets(ref,"DEC") yref = real(imgets.value) # read through each file header and extract RA and Dec while (fscan(inl,current) != EOF) { imgets(current,"RA") nx= real(imgets.value) imgets(current,"DEC") ny = real(imgets.value) # print (nx,ny) # calculates relative offset in degrees, then converts to arcseconds, # and then to pixels assuming 0.5 pix xshift = -1*(nx - xref)*15.*3600.*(1/0.495) yshift = (ny - yref)*3600.*(1/0.495) # writes xshift and yshift to output file "shifts" print(xshift,yshift,>>shifts) # print(xref,yref,xshift,yshift) } end