def linear_map(src_value, src_domain, dst_range):
    """Maps source value (src_value) in the source domain
    (source_domain) onto the destination range (dest_range) using linear
    interpretation.

    Except that at the moment src_value is a bytes value that once converted
    to integer that it then is on the src_domain.

    Ideally would like to move the conversion from bytes to int externally.

    Once value is same base and format as src_domain (i.e. converted from bytes),
    it should always fall within the src_domain. If not, that's a problem.
    """
    src_min, src_max, dst_min, dst_max = src_domain + dst_range
    if not src_min <= src_value <= src_max:
        raise ValueError
    slope = (dst_max - dst_min) / (src_max - src_min)
    dst_value = slope * (src_value - src_min) + dst_min
    if not dst_min <= dst_value <= dst_max:
        raise ValueError
    return dst_value
