C+ C NAME: C smei_cal_read C PURPOSE: C Read closed shutter calibration pattern file C CATEGORY: C ucsd/camera/for/lib C CALLING SEQUENCE: subroutine smei_cal_read(cFile, mode, mask, pattern_dark, nx, ny, pattern) C INPUTS: C cFile*(*) character fully qualified Fits pattern file name C mode integer camera mode (0,1,2) C mask integer C3 mask applied or not (0=No,1=Yes) C OUTPUTS: C pattern_dark real dark current in pattern C pattern(*) real engineering mode (1272x256) pattern array C nfrm integer # frames used to calculate the pattern C cfrm(nfrm) character names of frames used to calculate the pattern C TBeg(2) integer Begin time of closed shutter calibration data C TEnd(2) integer End time of closed shutter calibration data C All engineering mode frames between TBeg and TEnd C are used for the performance test. C ncr_count integer cosmic ray count (from href=smei_cal_add=) C INCLUDE: include 'filparts.h' include 'smei_frm_layout.h' include 'ftspar.h' C CALLS: C iSetFileSpec, iGetFileSpec, iFilePath, iGetLun, iFreeLun C say_fts, Int2Str, Str2Str, Say, cInt2Str C FTNOPN, FTGKYS, FTGKNS, FTGKYE, FTGKYL, FTGKYJ, FTMAHD, FTGISZ C FTGPVE, FTCLOS, smei_Time2Split C RESTRICTION: C If mask=1 then extensions 3,4 and 5 are accessed (where the patterns C with mask applied are stored). No check is made whether these C extensions are present. C MODIFICATION HISTORY: C JUN-2004, Paul Hick (UCSD/CASS) C MAR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added argument 'mask' to deal with patterns with c3 "bad pixel" C mask applied. C- character cFile*(*) integer mode integer mask real pattern_dark real pattern(*) character cSay*8 /'cal_read'/ save cSay character cSeverity /'E'/ character cStr *(FIL__LENGTH) character cTemp*50 character cInt2Str*14 integer Str2Str logical anyf integer nAxes(2) character cPat*(*) integer TPat(2) integer TBeg(2) integer TEnd(2) logical bTfloat double precision Version character cfrm(*)*(*) character cPat_fts*50 save cPat_fts integer TBeg_fts(2) save TBeg_fts integer TEnd_fts(2) save TEnd_fts logical bTfloat_fts save bTfloat_fts double precision Version_fts save Version_fts integer CAL__NFRM_MAX parameter (CAL__NFRM_MAX = 25) character cfrm_fts(CAL__NFRM_MAX)*50 save cfrm_fts integer ncr_fts save ncr_fts integer nfrm_fts save nfrm_fts iU = iGetLun(cFile) istat = 0 i = 0 i = i+Str2Str(cFile ,cStr(i+1:))+1 i = i+Str2Str('(ext' ,cStr(i+1:))+1 i = i+Int2Str(1+3*mask ,cStr(i+1:)) i = i+Str2Str(')' ,cStr(i+1:)) call Say(cSay,'I','#'//cStr,'mode '//cInt2Str(mode)) call FTNOPN(iU, cFile, FTS__READONLY, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) ! Move to extension for mode 0 pattern to extract ! parameters from headers. ! (1 or 4, depending on setting of 'mask') call FTMAHD(iU, 1+3*mask, ihdutype, istat) call FTGKYS(iU, 'NAME', cPat_fts, cStr, istat) if (istat .ne. 0) then if (istat .eq. 202) then I = iSetFileSpec(cFile) I = iGetFileSpec(FIL__NAME, FIL__NAME, cPat_fts) istat = 0 else call say_fts(cSay,cSeverity,istat) end if end if call FTGKNS(iU, 'FRAME', 1, CAL__NFRM_MAX, cfrm_fts, nfrm_fts, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) if (nfrm_fts .eq. CAL__NFRM_MAX) call Say(cSay,'W','frames','only 25 frame names read') call FTGKYS(iU, 'T_BEG', cTemp, cStr, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) call smei_Time2Split(2,cTemp,TBeg_fts) call FTGKYS(iU, 'T_END', cTemp, cStr, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) call smei_Time2Split(2,cTemp,TEnd_fts) call FTGKYE(iU, 'DARK_VAL', pattern_dark, cStr, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) call FTGKYL(iU ,'CCD_TEMP', bTfloat_fts, cStr, istat) if (istat .ne. 0) then call Say(cSay,'W','CCD_TEMP','keyword not found') istat = 0 end if call FTGKYJ(iU, 'N_CRAYS', ncr_fts, cStr, istat) if (istat .ne. 0) then call Say(cSay,'W','N_CRAYS','keyword not found') istat = 0 end if call FTGKYD(iU, 'SMEI_CAL', Version_fts, cStr, istat) if (istat .ne. 0) then Version_fts = 1.0d0 istat = 0 end if ! Move to proper extension (depending on mode and mask ! settings to extract dimensions and data array. call FTMAHD(iU, mode+1+3*mask, ihdutype, istat) call FTGISZ(iU, 2, nAxes, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) nx = nAxes(1) ny = nAxes(2) anyf = .FALSE. call FTGPVE(iU, 1, 1, nx*ny, 0.0, pattern, anyf, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) ! Replace zero by bad values !call ArrR4Copy(SMEI__FRM_NPIX,pattern,pat_mode_0) !call ArrR4Mask(SMEI__FRM_NPIX,pattern,BadR4(),0.0,0.0,0.0,1.0,pat_mode_0) ! Close pattern fts file call FTCLOS(iU, istat) if (istat .ne. 0) call say_fts(cSay,cSeverity,istat) iU = iFreeLun(iU) return entry smei_cal_name(cPat) cPat = cPat_fts return entry smei_cal_camera(icam) read (cPat_fts(2:2),'(I1)') icam return entry smei_cal_time(TPat) call smei_Time2Split(0,cPat_fts, TPat) return entry smei_cal_caltime(TBeg, TEnd) TBeg(1) = TBeg_fts(1) TBeg(2) = TBeg_fts(2) TEnd(1) = TEnd_fts(1) TEnd(2) = TEnd_fts(2) return entry smei_cal_frames(nfrm, cfrm) do i=1,min(nfrm,nfrm_fts) cfrm(i) = cfrm_fts(i) end do if (nfrm_fts .gt. nfrm) call Say(cSay,'W','frames','not all names returned') entry smei_cal_cr_count(ncr_count) ncr_count = ncr_fts return entry smei_cal_tfloat(bTfloat) bTfloat = bTfloat_fts return entry smei_cal_version(Version) Version = Version_fts return end