1. Bias Time Calculations

     - Prepared by Gregg Germain, November 2011 (Updated June 5, 2022).

This document describes how to calculate the total time for a Bias run, and the individual times for each of the 4 phases of a Bias run (where applicable).

NOTE:The formulae and method presented are not appropriate for observations in which there is deadtime.

Information has been drawn from these primary sources:

[1] ACIS Science Instrument Software Requirements Specification
[2] ACIS Science Instrument Software User's Guide
[3] ACIS Science Instrument Software Detailed Design Specification
[4] Flight software source code

1. Introduction.

When an observation is executed *with* Bias, the bias action roughly begins with the start science. If all you want is the total bias calculation time, you can calculate it quickly and easily using the method shown below in Section I. However, the entire Bias procedure is done in several steps. There will be occasions when you will want to know when one or more of these phases will be done. The formulas to do this are shown in Section II, and an example of the calculation of each phase is shown in Section III.

Section I - Calculating the Total Bias Time.

   [1] CC mode - a flat 13 minutes no matter what the configuration.

   [2] TE mode

     13 minutes to take the bias no matter how many chips are used
            - all chips take bias in parallel

     Then add 2 * the number of Chips * the fraction of the 1024
     array: 

         13 minutes + ((2 * number of chips) * Fraction of 1024
         array)


  Examples for TE mode:

            1 chip, 1024 rows:
               13 + ((2 * 1) * 1.0)

            1 chip, 512 rows:
               13 + ((2  * 1) * .5)

            2 chips, 1024 rows:
               13 + ((2 * 2) * 1.0)

            6 chips, 1024 rows:
               13 + ((2 * 6) * 1.0) = 13 + 12 minutes = 25 minutes.

Section II - Calculating the time for several phases of the Bias .

The on-board Bias processing can be divided into these phases:

    a) initial flushing                    (flush_phase_time)
    b) conditioning phase                  (conditioning_phase_time)
    c) bias frame accumulation/computation (accumulation_time)
    d) compression/telemetering            (comp_telem)
To compute the times, you need to extract these values from the Parameter Block (PB):

   fepCcdSelect  ( Count of the number of chips on; "10" means 
                   an unused FEP)
   fepMode       (if rawmode, no bias taken. If an event histogram, 
                  No telemetering of bias)        
   recomputeBias       
   trickleBias         
   subarrayRowCount    
   primaryExposure  
   secondaryExposure
   dutyCycle
   ignoreInitialFrames 
   biasArg0   ( all six numbers should be the same - use the number)         
   biasArg1   ( all six numbers should be the same - use the number)

   NOTE: the units of primaryExposure, as seen in the PB, are tenths
         of a second:  e.g. a PB value of 15 = 1.5 sec

   NOTE: There will be 6 biasArg0 and biasArg1 values in the PB. They
         should be all the same value. Use that value. 

   NOTE: you use fepMode only to determine if this is a CC or TE
         observation; and you use recomputeBias only to assure that
         bias is actually being taken, and trickleBias to be sure you
         are in format 2.

   NOTE: when there's a duty cycle. It takes just as long to process 
         a short exposure as it does to process a long one. So for
         these, we base our calculations on either primaryExposure or 
	 secondaryExposure whichever is bigger.


You will also need to use these constants:

   framesPerCondFrame = 3.0
   framesperAccumFrame = 7.0
   telemSecsPerRow = 0.13

   NOTE: These three parameters are not deterministic, and can vary with
         background rate. These values are moderately conservative, assuming
         somewhat poorer than average performance.

Lastly, you will need the following equation for frametime:

  No Duty Cycle:
  --------------
    frametime = (primaryExposure/10) + 0.041
          i.e. you are adding 41 milliseconds to primaryExposure

  Duty Cycle:
  -----------
    frametime = (max(primaryExposure, secondaryExposure)/10) + 0.041
          i.e. you are adding 41 milliseconds to either the primaryExposure
               or the secondary exposure, whichever is largest.


Calculating the initial phases:
------------------------------- 

a) Initial flushing; Ignore Initial Frames Completion time

       flush_phase_time = frametime * ignoreInitialFrames

b) Conditioning phase 

       conditioning_phase_time = biasArg0 * framesPerCondFrame * frametime

c) Bias frame accumulation

       accumulation_time = frametime * framesPerAccumFrame *(biasArg1 - biasArg0)


d) Compression/Telemetering 

       comp_telem = chipsInUse * subarrayRowCount *telemSecsPerRow - 27

    NOTE: This assumes format 2


Section III - Example - Observation, using SI Mode TE_009F0B.

SIMODE TE_009F0B which has: 

loadTeBlock[0] = {
  commandLength              = 150
  commandIdentifier          = 11873
  commandOpcode              = 9 # CMDOP_LOAD_TE
  teBlockSlotIndex           = 4
  checksum                   = 36515
  parameterBlockId           = 0x009f0024
  fepCcdSelect               =    4    7    5    6    8    9 
  fepMode                    = 2 # FEP_TE_MODE_EV3x3
  bepPackingMode             = 0 # BEP_TE_MODE_FAINT
  onChip2x2Summing           = 0
  ignoreBadPixelMap          = 0
  ignoreBadColumnMap         = 0
  recomputeBias              = 1
  trickleBias                = 1
  subarrayStartRow           = 14
  subarrayRowCount           = 439
  overclockPairsPerNode      = 8
  outputRegisterMode         = 0 # QUAD_FULL
  ccdVideoResponse           = 0 0 0 0 0 0 
  primaryExposure            = 15
  secondaryExposure          = 0
  dutyCycle                  = 0
  lowerEventAmplitude        = 20
  eventAmplitudeRange        = 3250
  gradeSelections            = 0xfeffffff 0xffffffff 0xfffffffb 0xfffff7ff 
                               0xffffffff 0xffffffff 0xffbfffff 0x7fffffff 
  windowSlotIndex            = 65535
  histogramCount             = 0
  biasCompressionSlotIndex   =    1    3    3    1    1    1 
  rawCompressionSlotIndex    = 2
  ignoreInitialFrames        = 233
  biasAlgorithmId            =    1    1    1    1    1    1 
  biasArg0                   =   20   20   20   20   20   20 
  biasArg1                   =   41   41   41   41   41   41 
  biasArg2                   =   20   20   20   20   20   20 
  biasArg3                   =   50   26   26   50   50   50 
  biasArg4                   =   20   20   20   20   20   20 
  fep0VideoOffset            =   73   75   73   83 
  fep1VideoOffset            =   79   79   79   77 
  fep2VideoOffset            =   79   94   76   95 
  fep3VideoOffset            =   90   82   79   94 
  fep4VideoOffset            =   72   72   78   71 
  fep5VideoOffset            =   81   87   80   82 
  deaLoadOverride            = 0x00000000
  fepLoadOverride            = 0x00000000
}

Relevant values are:

   fepCcdSelect        = 6
   fepMode             = 2 # FEP_TE_MODE_EV3x3
   recomputeBias       = 1 
   trickleBias         = 0 
   subarrayRowCount    = 439
   primaryExposure     = 15
   dutyCycle           = 0
   ignoreInitialFrames = 233
   biasArg0            = 20
   biasArg1            = 41

   framesPerCondFrame = 3.0 
   framesperAccumFrame = 7.0 

Calculate frametime:

    frametime = (primaryExposure/10) + 0.041
              = (15/10) +  0.041
              = 1.541


Now calculate the times for the 4 phases:

a) flush_phase_time = frametime * ignoreInitialFrames
                    = 1.541 * 233
		    = 359.05 seconds

b) conditioning_phase_time = biasArg0 * framesPerCondFrame * frametime
                           = 20 * 3.0 * 1.541
                           = 92.46 seconds

c) accumulation_time = frametime * framesPerAccumFrame *(biasArg1 - biasArg0)
                    = 1.541 * 7.0 * ( 41 - 20)
                    = 226.53 seconds

d) comp_telem = chipsInUse * subarrayRowCount *telemSecsPerRow - 27
             = (6 * 439 * 0.13) - 27
	     = 369.42