;************************************************************************** ;NAME : f1data (procedure) ;FUNCTION : reformat and read f1 vect. data ; + read dark/flat/data images ; + subtract dark ; + make flat correction ; + calculate sbtraction & average of data ; + " polarization dgree in unit of 10-4 ; + correct the displacements between images ; + save results (in *.p or .q .u .v files) ; filename should be following ; dark --- fd** --> read dark ; flat --- ff**.v, .q, .u 3 files shuld exist --> read flat ; data --- ****.v, .q, .u " ;MODIFICATION HISTORY : ; K.Ichimoto, 92/10/25 direct read, add delete keyword ; K.Ichimoto,'93/02/06 one keyword ;========================================================================== pro f1data,fnam,h,img,q,u,v,hd,drk,hf,flt,save=save,psave=psave,dir=dir, $ noshift=noshift,ver=ver,delete=delete,one=one ; INPUT ; fnam : file name without '.v','.u','.q' ; if 'fd*' read dark in drk ; if 'ff*' read 3-flats in flt ; others (usualy 'f1*' or 'fb*') read 3-images ; and make dark & flat corrections if drk and flt exist ; drk : dark image ; hd : header of dark data ; flat : flat image (*,*,6) ; hf : header of flat data (6) ; dir : directory where files exist ; /save : save results in each v,q,u files ; /psave : save results in a unique file of '.p' ; noshift : don't make co-alignment correction fot q,u images ; /ver : display part images for co-arignments ; /delete : delete .q .u .v files after psave ; one : if set, 100% pol. is 10000. else is 20000. ; OUTPUT ; h : header for img,q,u,v, h(4) ; img,q,u,v : i,q,u,v images if not keyword_set(dir) then dir='' if keyword_set(ver) then ver=1 else ver=0 if keyword_set(one) then one=1 else one=0 rfact=10000. change=0 case strmid(fnam,strpos(fnam,'/')+1,2) of 'fd': begin ; ============== dark ============== nkrget,dir+fnam,hd,drk if keyword_set(save) then $ nkrsave,dir+fnam,hd,drk,/nocheck end 'ff': begin ; ============== flat ============== nkrgeth,dir+fnam+'.q',h if h.nbyt eq 2 then flt=intarr(h.nx,h.ny,6) if h.nbyt eq 1 then flt=bytarr(h.nx,h.ny,6) h1=nkrhead() hf=replicate(h1,6) ext=['.q','.q','.u','.u','.v','.v'] imn=[1,2,1,2,1,2] for i=0,5 do begin nkrget,dir+fnam+ext(i),h1,img1,img_no=imn(i) if h1.correct eq 1 then begin sbtdrk,h1,img1,hd,drk change=1 endif hf(i)=h1 flt(*,*,i)=img1 endfor if keyword_set(save) and (change eq 1) then begin nkrsave,dir+fnam+'.q',hf(0),flt(*,*,0),/nocheck nkrsave,dir+fnam+'.q',hf(1),flt(*,*,1),/nocheck,/append nkrsave,dir+fnam+'.u',hf(2),flt(*,*,2),/nocheck nkrsave,dir+fnam+'.u',hf(3),flt(*,*,3),/nocheck,/append nkrsave,dir+fnam+'.v',hf(4),flt(*,*,4),/nocheck nkrsave,dir+fnam+'.v',hf(5),flt(*,*,5),/nocheck,/append endif end else: begin ; ============== data ============== if not keyword_set(drk) then drk=0 if not keyword_set(hd) then hd=0 if not keyword_set(hf) then hf1=0 h1=nkrhead() h2=replicate(h1,2) ; header for i and q,u,v h=replicate(h1,4) ; header for i,q,u,v ff=findfile(dir+fnam,count=count) if count eq 0 then exist=0 else exist=1 ff=findfile(dir+fnam+'.*',count=count1) ff=[ff,findfile(dir+fnam,count=count2)] count=count1+count2 if count eq 0 then begin print,'file: '+dir+fnam+'.* not found in "f1data" !' return endif else begin ; examine the kind of file '.p' or '.v,q,u' p_exist=0 & v_exist=0 for i=0,count-1 do begin if strmid(ff(i),strlen(ff(i))-2,2) eq '.v' then v_exist=1 if strmid(ff(i),strlen(ff(i))-2,2) eq '.p' then p_exist=1 endfor if v_exist and (exist or p_exist) then begin ans='' print,'"" & "*.v" both files exist.' read,' Which do you use (*/v) ? : ',ans if ans ne 'v' then v_exist=0 endif if not v_exist then begin if exist then begin fext='' endif else begin fext='.p' endelse nkrget,dir+fnam+fext,h1,img,img_no=1 & h(0)=h1 nkrget,dir+fnam+fext,h1,q,img_no=2 & h(1)=h1 nkrget,dir+fnam+fext,h1,u,img_no=3 & h(2)=h1 nkrget,dir+fnam+fext,h1,v,img_no=4 & h(3)=h1 goto,endlab endif endelse ; ------------ v ------------- if keyword_set(hf) then hf1=hf(4) if keyword_set(flt) then $ ftgetar,dir+fnam+'.v',h2,img,v,dark=drk,hd=hd, $ flat=flt(*,*,4:5),hf=hf1,info=info,one=one $ else ftgetar,dir+fnam+'.v',h2,img,v,dark=drk,hd=hd,info=info,one=one if info eq -1 then begin print,dir+fnam+'.v not found!' return endif else begin h(0)=h2(0) h(3)=h2(1) & h(3).value='V' if keyword_set(save) and info eq 1 then begin nkrsave,dir+fnam+'.v',h(3),v,/nocheck nkrsave,dir+fnam+'.v',h(0),img,/nocheck,/append endif endelse ; ------------ q ------------- if keyword_set(hf) then hf1=hf(0) if keyword_set(flt) then $ ftgetar,dir+fnam+'.q',h2,img0,q,dark=drk,hd=hd, $ flat=flt(*,*,0:1),hf=hf1,info=info,one=one $ else ftgetar,dir+fnam+'.q',h2,img0,q,dark=drk,hd=hd,info=info,one=one if info eq -1 then begin print,dir+fnam+'.q not found!' endif else begin h(1)=h2(1) & h(1).value='Q' if keyword_set(save) and info eq 1 then begin nkrsave,dir+fnam+'.q',h(1),q,/nocheck nkrsave,dir+fnam+'.q',h2(0),img0,/nocheck,/append endif if not keyword_set(noshift) then begin displace,img,img0,dx,dy,ver=ver q=rshift(q,dx,dy,missing=0) endif endelse ; ------------ u ------------- if keyword_set(hf) then hf1=hf(2) if keyword_set(flt) then $ ftgetar,dir+fnam+'.u',h2,img0,u,dark=drk,hd=hd, $ flat=flt(*,*,2:3),hf=hf1,info=info,one=one $ else ftgetar,dir+fnam+'.u',h2,img0,u,dark=drk,hd=hd,info=info,one=one if info eq -1 then begin print,dir+fnam+'.u not found!' endif else begin h(2)=h2(1) & h(2).value='U' if keyword_set(save) and info eq 1 then begin nkrsave,dir+fnam+'.u',h(2),u,/nocheck nkrsave,dir+fnam+'.u',h2(0),img0,/nocheck,/append endif if not keyword_set(noshift) then begin displace,img,img0,dx,dy,ver=ver u=rshift(u,dx,dy,missing=0) endif endelse if keyword_set(psave) then begin if strmid(fnam,strlen(fnam)-2,2) eq '.p' then fext='' $ else fext='.p' nkrsave,dir+fnam+fext,h(0),img,/nocheck nkrsave,dir+fnam+fext,h(1),q,/append nkrsave,dir+fnam+fext,h(2),u,/append nkrsave,dir+fnam+fext,h(3),v,/append if keyword_set(delete) then begin spawn,'rm '+dir+fnam+'.q' spawn,'rm '+dir+fnam+'.u' spawn,'rm '+dir+fnam+'.v' endif endif endlab: if n_params() eq 3 then begin s=size(img) tmp=img img=make_array(s(1),s(2),4,type=s(0)) img(*,*,0)=tmp img(*,*,1)=q img(*,*,2)=u img(*,*,3)=v endif end endcase end