XMM-Newton SAS Home Page
XMM-Newton Science Analysis System


emframes (emframes-5.11) [xmmsas_20230412_1735-21.0.0]


Algorithm

MODULE em_frames_module
 
   Read the file names of frames files (input and output) and events file

   Opening of input auxiliary and events file
   Select CCD/node in auxiliary file
   Copy of input events file header keywords to output frames file

   parameters read : choice of sub_tasks to execute

   Loop over input task parameters
      Read the task parameter / 1 to perform the procedure,
                                0 not to perform it  /
   End loop

   Get the values of files columns in memory

SUBROUTINE FRAMES 
      frame time calculation as difference between successive read-out times
             use only if constant 3 times in a row
             otherwise keep original value
      Read counting mode file if any
      Renumber frames and associated events if times indicate
             that frame number was lost.
      Build complete arrays of flags and times
             including missing frames and correcting wrong times
      Write columns to output file
      Put the keyword FRMTIME on file
 
SUBROUTINE FLAG_HK
      if flag_hk requested  then
           read the gti file name parameter
           Read GTI file  
           Loop over the rows of frames file
               Loop over good time intervals
                  flag frame outside intervals 
               end loop
           end loop
      endif
 
SUBROUTINE FIFO  check the FIFOOVF
   if fifo requested  then
      Loop over frame rows
         flag frames with FIFOOVF not equal to 0 
      end loop
   endif
 
SUBROUTINE VALID    check the number of events for each frame
    if valid requested  then
      Loop over frame rows 
        count the number of rows in the events file for each frame
        and compare with the NVALID value
        flag the frame if not equivalence      
      end loop
    endif
 
SUBROUTINE CR_DEAD 
   identify the “cosmic-ray” patterns,
   and get the number of pixels above threshold for each type of pattern
   for patterns CRPATi we put 0 to avoid subtracting cosmic-rays
   if cr_dead requested then
      Read cosmicsize and cosmicoutoverin values from CAL
      Loop over frame rows
        calculate crratio as 
        ( NPIXEL(frame) - NPIXEL(events) - NBELOW ) / ( DX * DY )
        check  crratio > NABOVE / ( DX * DY )
        apply correction factor
        crratio = crratio * cosmicsize / (ratarea+(1-ratarea)*cosmicoutoverin)
        ratarea = fraction of window in open view of the sky
      end loop 
      write CRRATIO column on file 
    endif   

SUBROUTINE MAKE_GTI    Build new GTI from unflagged frames
    if make_gti requested then
      Loop over the frames
        Reconstruct new GTI intervals excluding all flagged frames
      end loop
    endif
 
SUBROUTINE PUT_GATTI    check the gatti flag and write the gatti value
    if put_gatti requested then
       Loop over frame rows
          Look for GATTI flag = 1
          recompute the gatti value in previous 510 frames
       end loop
       Recompute GATTI in last frames
       write GATTIVAL column on file 
    endif
 
    write FLAG column on file

    Closing files
 
end module



XMM-Newton SOC -- 2023-04-16