def range_to_range_linear(value, min_old_range, max_old_range, min_new_range,
                          max_new_range):
    """
    Transform a value from one range to another linearly.
        :param value: quantity to be transformed
        :param min_old_range: min
        :param max_old_range: max
        :param min_new_range: min
        :param max_new_range: max
    """
    if value < min_old_range:
        value = min_old_range
    elif value > max_old_range:
        value = max_old_range
    temp = ((value - min_old_range) / (max_old_range - min_old_range)) * \
           (max_new_range - min_new_range) + min_new_range
    return temp