pro vmg_flat, files, vflat, jflat ;+ ; NAME: VMG_FLAT ; PURPOSE: Produced the flat patterns for VMG observations ; INPUT: ; files an array of V and J file names ; files(*,0) V files ; files(*,1) J files ; OUPUT: ; vflat a flat pattern for V images ; jflat a flat pattern for J images ; ; RESTRICTION: ; Each pair of V files and J files should taken from ; the same integration. ; HISTROY: ; August 1998 J. Chae ;- nf = n_elements(files(*,0)) a=replicate(0., 512, 512, nf) x1=16 & x2 = 505 & y1 =5 & y2=470 dy=15 mm = 0. for k=0, nf -1 do begin tmp = readfits(files(k,0), /sil) m=median(tmp) mm=mm+m tmp = (tmp-m) a(x1:x2, y1+dy:y2+dy, k) = (tmp)(x1:x2, y1:y2) tvscl, a(*,*,k)>(-100)<100 endfor tmp=fltarr(512, 512) for x=x1, x2 do for y=y1, y2 do tmp(x, y, *) = median(a(x, y+dy, *)) tmp1=congrid(tmp(x1:x2, y1:y2), 200, 200, /interp) get_bg, tmp1, bg, $ region=where(abs(tmp1) le 20), degree=2 bg=congrid(bg, x2-x1+1, y2-y1+1, /interp) for k=0, nf-1 do begin a(x1:x2, y1+dy:y2+dy, k) = a(x1:x2, y1+dy:y2+dy, k) -bg a(*, *, k)=a(*,*,k)>(-10)<10 tvscl, a(*,*,k) endfor mm=mm/nf vflat=fltarr(512, 481) vflat(x1:x2, y1:y2)=$ (gaincalib(a, x0, y0, add=1, shift=1))(x1:x2, y1+dy:y2+dy) vflat(x1:x2, y1:y2) = ringfilter(vflat(x1:x2, y1:y2),0,2)+bg vflat=vflat+mm a=replicate(1., 512, 512, nf) for k=0, nf -1 do begin tmp = readfits(files(k, 1), /sil) m=float(median(tmp)) tmp = tmp/m a(x1:x2, y1+dy:y2+dy, k) = (tmp)(x1:x2, y1:y2) endfor c=total(a(x1:x2, y1+dy:y2+dy, *), 3)/n_elements(a(0,0,*)) get_bg, c, bg, degree=2 for k=0, nf-1 do begin a(x1:x2, y1+dy:y2+dy, k) = a(x1:x2, y1+dy:y2+dy,k)/bg tvscl, a(*,*,k)>0.8<1.2 endfor jflat = (gaincalib(a, x0, y0)) jflat(x1:x2, y1+dy:y2+dy) = jflat(x1:x2, y1+dy:y2+dy)*bg jflat = jflat(0:511, dy:dy+480) end