;  
; Apply correction to make image stationary
; in SWRI calibrated eclipse images

pixX = 256
pixY = 1024
xmotion = -19.
ymotion = 48.	; pixels over course of eclipse
window,0,xsize=pixY,ysize=pixX
img = fltarr(pixX,pixY)
x=0.
y=0.

loadct,9
 
filenm=' '
listfile='./elist.cal
 
    close,13 & openr,13,listfile

    close,14 & openr,14,'moonlimbs'

; Initial coordinates of limb used for x and y changes respectively
    oldx0 = 440.
    oldy0 = 90.

    ii=0 
    while ( not eof(13) ) do begin ;{
	img=fltarr(pixX,pixY)
        readf,13,filenm
	print,filenm
	close,1 & openr,1,filenm
	readu,1,img
; Swap X and Y coordinates
	img=rotate(img,4)
	fimg = sobel(img)
	fimg = 512.*fimg/(float(img)+200)
	readf,14,x,y
; Kentucky windage to remove Moon's motion
	x = oldx0 - x + xmotion*float(ii)/79.
	y = oldy0 - y + ymotion*(float(ii)/79. - .5 )
	simg=shift(img,x,y)
	tv,simg/16.
	str = string(filenm,'.sft')
	close,15 & openw,15,str & writeu,15,simg & close,15
        ii=ii+1
    endwhile ;} 
 
    close,14
    close,13

    stop

end 
