def _linearly_scale(inputmatrix, inputmin, inputmax, outputmin, outputmax):
inputrange = inputmax - inputmin<EOL>outputrange = outputmax - outputmin<EOL>delta = outputrange/inputrange  <EOL>inputmin = inputmin + <NUM_LIT:1.0> / delta / <NUM_LIT>  <EOL>outputmax = outputmax - <NUM_LIT:1>  <EOL>outputmatrix = (inputmatrix - inputmin) * delta + outputmin<EOL>err = IndexError('<STR_LIT>' %<EOL>(inputmatrix, inputmax - inputrange, inputmax))<EOL>if outputmatrix > outputmax:<EOL><INDENT>if np.around(outputmatrix - outputmax, <NUM_LIT:1>) <= <NUM_LIT:0.5>:<EOL><INDENT>outputmatrix = outputmax<EOL><DEDENT>else:<EOL><INDENT>raise err<EOL><DEDENT><DEDENT>elif outputmatrix < outputmin:<EOL><INDENT>if np.around(outputmin - outputmatrix, <NUM_LIT:1>) <= <NUM_LIT:0.5>:<EOL><INDENT>outputmatrix = outputmin<EOL><DEDENT>else:<EOL><INDENT>raise err<EOL><DEDENT><DEDENT>return outputmatrix<EOL>
linearly scale input to output, used by Linke turbidity lookup