pro pre_oscil1,head

filename=findfile(head)
nn=n_elements(filename)
nx=523
ny=363
limit=500
read_hr_dad,filename(0),l0,r0,hdr,/swap
l0=congrid(l0,nx,ny,/interp)
r0=congrid(r0,nx,ny,/interp)
print,''
print,'press cursor to choose a region for correlation (two point)'
window,0,xs=2*nx,ys=ny
tvscl,l0,0
cursor,x1,y1,3,/device
cursor,x2,y2,3,/device
sub0=l0(x1:x2,y1:y2)
mag=(l0-r0)/(l0+r0+0.0001)*10000.
tvscl,mag>(-limit)<limit,1
out_name,hdr,outname
opw,'l_'+outname,l0
opw,'m_'+outname,mag

window,1,xs=2*nx,ys=ny
for i=1,nn-1 do begin
read_hr_dad,filename(i),l1,r1,hdr,/swap
l1=congrid(l1,nx,ny,/interp)
r1=congrid(r1,nx,ny,/interp)
sub1=l1(x1:x2,y1:y2)
acpole,sub0,sub1,shx,shy
l1=shift(l1,shx,shy)
r1=shift(r1,shx,shy)
tvscl,l1,0
mag=(l1-r1)/(l1+r1+0.0001)*10000.
tvscl,mag>(-limit)<limit,1
out_name,hdr,outname
opw,'l_'+outname,l1
opw,'m_'+outname,mag
endfor


end



pro out_name,hdr,oname

mon=strmid(hdr(1),0,3)
case 1 of
	mon eq 'Jan': mon='01'
	mon eq 'Feb': mon='02'
	mon eq 'Mar': mon='03'
	mon eq 'Apr': mon='04'
	mon eq 'May': mon='05'
	mon eq 'Jun': mon='06'
	mon eq 'Jul': mon='07'
	mon eq 'Aug': mon='08'
	mon eq 'Sep': mon='09'
	mon eq 'Oct': mon='10'
	mon eq 'Nov': mon='11'
	mon eq 'Dec': mon='12'
	else: print,'---- Not a correct Month----'
endcase
year=strmid(hdr(1),7,4)
day=strmid(hdr(1),4,2)
tim=hdr(2)
ut_dot,tim,tim
oname=year+mon+day+'_'+tim

end

