pro correct_1802
window,xs=512*2,ys=512

filename=findfile('????????.dat')
fhdr=strmid(filename,0,1)
re=where(fhdr eq 's' or fhdr eq 'd' or  fhdr eq 't' or fhdr eq 'v')
if re(0) ge 0 then begin
   fmon=filename(re)
   fhdr=strmid(fmon,0,1)
   nn=n_elements(fmon)
   hdr=bytarr(79)
  for i=0,nn-1 do begin
   if fhdr(i) ne 'v' then dat=bytarr(512,512)
   if fhdr(i) eq 'v' then dat=intarr(512,512)
   openr,unit,fmon(i),/get_lun
   readu,unit,dat,hdr
   free_lun,unit

;   if fhdr(i) eq 'v' then dat=swap_endian(dat)
   dat=rotate(dat,7)

   sub_correct_1802,dat,dat_out

   if fhdr(i) eq 'v' then begin
	dat_out=fix(dat_out)
;	dat_out=swap_endian(dat_out)
   endif else begin
	re1=where(dat_out lt 0.)
	if re1(0) ge 0 then dat_out(re1)=0
	re1=where(dat_out gt 255.)
	if re1(0) ge 0 then dat_out(re1)=255
	dat_out=byte(dat_out)
   endelse

   dat_out=rotate(dat_out,7)
   openw,unit,fmon(i),/get_lun
   writeu,unit,dat_out,hdr
   free_lun,unit

  endfor
endif



end


