;+ ; ; NAME : SUMER_FLAT ; ; PURPOSE : Applies flat field correction to SUMER data ; ; CALLING SEQUENCE : ; Result= SUMER_FLAT(Data, Refw, Refy, file=file, $ ; decorrect=decorrect) ; INPUTS: ; DATA : SUMER data array ; Nspectral x Ny x Nstep x Nline ; If DATA is a 2-d array, then Nstep=1 and Nline=1 ; If DATA is a 3-d array, then Nline=1 ; REFW : the pixel positions of the left edges ; of sub spectral images measured across the ; slit direction in the detector plane. ; increases with wavelength ; 1-d array with Nline elements or a scalar ; default value =0 ; REFY : the pixel positions of the lower edges ; of sub spectral images measured along the ; the slit direction in the detector plane. ; increases in the S direction ; (upward in the ditector). ; 1-d array with Nline elements or a scalar ; default value=0 ; KEYWORD INPUTS: ; ; FILE : SUMER flat field file name ; If given, the flat image is read from this file. ; Otherwise, the flat image in the common block is used. ; DECORRECT If set , the data are subject the reverse ; process (i.e. decorrected). ; ; OUTPUT: ; DATA : flat field (de) corrected data ; ; HISTORY ; April 1997 Jongchul Chae ;- function sumer_flat, data, refw, refy, $ file=flat_field_file, decorrect=decorrect common flat_block, flat if n_elements(flat_field_file) eq 1 then begin f=findfile(flat_field_file, count=count) if count eq 0 then begin tmp=widget_message('The file ' + flat_field_file+ ' dose not exist.', /error) return, 0 end flat=sumer_fits(f(0)) & flat=flat.data/flat.amp endif if n_elements(data) eq 0 then return, 0 if n_elements(flat) eq 0 then begin tmp=widget_message('The flat image is not defined.', /error) return, 0 endif wldim = n_elements(data(*,0,0,0)) ydim = n_elements(data(0,*,0,0)) xdim = n_elements(data(0,0,*,0)) ndata = n_elements(data(0,0,0,*)) if n_elements(refw) eq 0 then refw=replicate(0, ndata) if n_elements(refy) eq 0 then refy=replicate(0, ndata) for k=0, ndata-1 do begin wl1 = refw(k) wl2 = (wl1+wldim-1) y1 = refy(k) y2=(y1+ydim-1) flat_small = flat(wl1:wl2, y1:y2) value=data*0 for ix=0, xdim-1 do if keyword_set(decorrect) then $ value(*, *, ix, k) = (data(*,*,ix, k)*flat_small) $ else value(*,*,ix, k) = (data(*,*,ix,k)/flat_small) endfor return, value end