pro zzalign If ( !version.os eq 'Win32' ) Then st = '\' If ( !version.os eq 'linux' ) Then st = '/' Print, 'Where is the sav file after rotation?' dir_read = DIALOG_PICKFILE( /DIRECTORY ) file_mkdir,dir_read+'aln' dir_write = dir_read+'aln'+st list = file_search(dir_read + '*aln.fts',count=nn) pos = STRPOS(list[0], 'aln.fts') spos = Strpos( list[0], st, /reverse_search ) sn = pos - spos listname = STRMID(list, spos+1, sn-1) img = readfits(list[0],head) WRITEFITS, dir_write+listname[0]+'aln.fts', img, head sz = size(img) print,sz xtvscl,img print,'Selet the area used for alignment' box_cursor,x,y,dx,dy imgg = fltarr(dx,dy) imgg1 = fltarr(dx,dy) imgg=img[round(x):round(x)+dx-1,round(y):round(y)+dy-1] j = 0 for i = 1,nn-1 do begin print,i img =readfits(list[i],head) imgg1 = img[round(x):round(x)+dx-1,round(y):round(y)+dy-1] offset = ch_alignoffset(imgg1,imgg,cor) print,cor if cor gt 0.6 then begin img=ch_shift_sub(img,-offset(0),-offset(1)) imgg = img[round(x):round(x)+dx-1,round(y):round(y)+dy-1] WRITEFITS, dir_write+listname[i]+'aln.fts', img, head j=j+1 endif endfor print,nn,j+1 end