docs: def remap( x, oMin, oMax, nMin, nMax ):
      """Map to a 0 to 1 scale
          http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
  
      """
  
      #range check
      if oMin == oMax:
          log.warning("Zero input range, unable to rescale")
          return x
  
      if nMin == nMax:
          log.warning("Zero output range, unable to rescale")
          return x
  
      #check reversed input range
      reverseInput = False
      oldMin = min( oMin, oMax )
      oldMax = max( oMin, oMax )
      if not oldMin == oMin:
          reverseInput = True
  
      #check reversed output range
      reverseOutput = False
      newMin = min( nMin, nMax )
      newMax = max( nMin, nMax )
      if not newMin == nMin :
          reverseOutput = True
  
      portion = (x-oldMin)*(newMax-newMin)/(oldMax-oldMin)
      if reverseInput:
          portion = (oldMax-x)*(newMax-newMin)/(oldMax-oldMin)
  
      result = portion + newMin
      if reverseOutput:
          result = newMax - portion
  
      return result