C+ C NAME: C smei_get_lsff C PURPOSE: C Get flat field correction. C CALLING SEQUENCE: subroutine smei_get_lsff(mode,icam,flatfield) C INPUTS: C icam integer camera number (1,2,3) C mode integer camera mode (0,1,2) C OUTPUTS: C flatfield(*) real flatfield correction C INCLUDE: include 'filparts.h' include 'dirspec.h' include 'smei_frm_layout.h' include 'ftspar.h' C CALLS: C iFilePath, iGetLun, iFreeLun, Say, GridFill, BadR4Set C FTNOPN, FTGISZ, FTGPVE, FTCLOS, say_fts C PROCEDURE: C The first nX * nY elements of flatfield will be filled where C nX = 1272, 636 or 318 and nY = 256, 128, 64 for mode 0,1 and C 2, respectively. C MODIFICATION HISTORY: C DEC-2004, Paul Hick (UCSD/CASS) C JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Replaced all zeroes by one in output array. C- integer icam integer mode real flatfield(*) character cSay*13 /'smei_get_lsff'/ character cSeverity /'E'/ character cStr*(FIL__LENGTH) integer y_offset(3) /17,11,13/ save y_offset integer x_offset(3) / 2, 2, 2/ save x_offset parameter (NXFF = 1280) parameter (NYFF = 301) real clsff(NXFF*NYFF) integer*1 bside(SMEI__FRM_NPIX/16*9) logical anyf integer nAxes(2) aloc(i,j,nX) = (j-1)*nX+i write (cStr,'(A,I1,A)') 'c',icam,'_clsff.fts.gz' i = iFilePath(cEnvi(:iEnvi)//'SMEIDB',0,' ',cStr,cStr) iU = iGetLun(cStr) istat = 0 call FTNOPN(iU, cStr, FTS__READONLY, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) call FTGISZ(iU, 2, nAxes, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) anyf = .FALSE. call FTGPVE(iU, 1, 1, nAxes(1)*nAxes(2), 0.0, clsff, anyf, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) call FTCLOS(iU, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) iU = iFreeLun(iU) nbin = 4 nX = SMEI__FRM_NX/nbin nY = SMEI__FRM_NY/nbin ! The array in the Fits file contains duplicate values in blocks of 4x4 ! Pick one from every block to make a mode 2 flat field map. do j=1,nY do i=1,nX clsff(aloc(i,j,nX)) = clsff(aloc(x_offset(icam)+nbin*(i-1),y_offset(icam)+nbin*(j-1),NXFF)) end do end do ! Fill in a couple of zeroes by averaging over neighbors rbad = BadR4Set(0.0) ! Set 0.0 as bad value; save old bad value call GridFill(6,nX,nY,clsff,bside,zmin,zmax) rbad = BadR4Set(rbad) ! Restore old bad value ! Set up a flat field for the requested mode. ! All remaining zeroes are set to one here. mag = 4/2**mode do j=1,nY do i=1,nX val = clsff(aloc(i,j,nX)) if (val .eq. 0.0) val = 1.0 ! 0.0 -> 1.0 do jj=1,mag do ii=1,mag flatfield(aloc(mag*(i-1)+ii,mag*(j-1)+jj,mag*nX)) = val end do end do end do end do return end