; NAME:
;   amp::read_pix   
;
; PURPOSE:
;   Simulates a MUX readout of an input array representing an IR detector.   
;   
; 
; INPUTS:
;   pix_offset  time to read one pixel of a detector (in nanoseconds)
;   counts      array representing a subsection of a detector which this amp
;               is responsible for reading.   
; 
; KEYWORDS:
;   none  
;
; OUTPUTS:
;   none   
;
Pro amp::read_pix, pix_offset, counts

    ; pix_offset must be in nano-seconds

    ; find row readout-direction
    colstep = (self.first_pix.x gt self.last_pix.x) ? -1 : 1

    ; find column readout-direction
    rowstep = (self.first_pix.y gt self.last_pix.y) ? -1 : 1

    ; get the value of the first pixel to read   
    pbuf = counts[self.first_pix.x, self.first_pix.y]

    ; set up loop to readout counts array
    for row = self.first_pix.y, self.last_pix.y, rowstep do begin
        for col = self.first_pix.x, self.last_pix.x, colstep do begin
            pbuf = pbuf - (pbuf - counts[col,row]) * $
                (1.0 - exp(-pix_offset / self.tau_ns))
            counts[col,row] = pbuf
        endfor
    endfor
End

; NAME:
;   amp::init   
;
; PURPOSE:
;   creates an amp object
;   NOTE:  An amp object is associated with a particular detector object and is
;          assigned a section of the detector array when created.
;   
; 
; INPUTS:
;   tau         readout time constant (nano-seconds)
;   fpix        pixel struct containing coordinates of first detector pixel
;               to read
;   lpix        pixel struct containing coordinates of last detector pixel
;               to read     
; 
; KEYWORDS:
;   none
;
; OUTPUTS:
;   none   
;   
Function amp::init, tau, fpix, lpix

    self.tau_ns = tau
    self.first_pix = fpix
    self.last_pix = lpix

    return, 1
End
