parameters: (AP, BP, CP, nDets)
return_statement: return x_bin_new
docstring: Corrects position errors in a tube in the same manner as is done for MERLIN
         according to an algorithm used by Rob Bewley in his MATLAB code.
  
         @param AP: Fit position of left (in pixels)
         @param BP: Fit position of right (in pixels)
         @param CP: Fit position of centre (in pixels)
         @param nDets: Number of pixel detectors in tube
  
         Return Value: Array of corrected Xs  (in pixels)
docstring_summary: Corrects position errors in a tube in the same manner as is done for MERLIN
         according to an algorithm used by Rob Bewley in his MATLAB code.
docstring_tokens: Corrects position errors in a tube in the same manner as is done for MERLIN according to an algorithm used by Rob Bewley in his MATLAB code .
function: def correct_tube(AP, BP, CP, nDets):
      """
         Corrects position errors in a tube in the same manner as is done for MERLIN
         according to an algorithm used by Rob Bewley in his MATLAB code.
  
         @param AP: Fit position of left (in pixels)
         @param BP: Fit position of right (in pixels)
         @param CP: Fit position of centre (in pixels)
         @param nDets: Number of pixel detectors in tube
  
         Return Value: Array of corrected Xs  (in pixels)
      """
  
      AO = AP / (nDets - AP)
      BO = (nDets - BP) / BP
      # First correct centre point for offsets
      CPN = CP - (AO * (nDets - CP)) + BO * CP
      x = []
      for i in range(nDets):
          xi = i + 1.0
          x.append(xi - ((nDets - xi) * AO) + (xi * BO))  # this is x corrected for offsets
  
      # Now calculate the gain error
      gain_error = ((nDets + 1) / 2.0 - CPN) / (CPN * (nDets - CPN))
      x_bin_new = []
      for i in range(nDets):
          xo = x[i]
          # Final bin position values corrected for offsets and gain
          x_bin_new.append(xo + (xo * (nDets - xo) * gain_error))
  
      return x_bin_new
function_tokens: def correct_tube ( AP , BP , CP , nDets ) : AO = AP / ( nDets - AP ) BO = ( nDets - BP ) / BP # First correct centre point for offsets CPN = CP - ( AO * ( nDets - CP ) ) + BO * CP x = [ ] for i in range ( nDets ) : xi = i + 1.0 x . append ( xi - ( ( nDets - xi ) * AO ) + ( xi * BO ) ) # this is x corrected for offsets # Now calculate the gain error gain_error = ( ( nDets + 1 ) / 2.0 - CPN ) / ( CPN * ( nDets - CPN ) ) x_bin_new = [ ] for i in range ( nDets ) : xo = x [ i ] # Final bin position values corrected for offsets and gain x_bin_new . append ( xo + ( xo * ( nDets - xo ) * gain_error ) ) return x_bin_new