There is a NumPy function that does these sorts of transformation
numpy.interp(value, [input_start, input_end], [output_start, output_end])