def correct_angles(xarr, start, end):
    """
    performs a linear mapping such that the first and last value are as expected
    e.g. 0 and 180 instead of 0.3 and 179.1
    :param xarr:
    :param start:
    :param end:
    :return:
    """

    # model = y = m*x + n

    m = (start-end) / (xarr[0] - xarr[-1])
    n = start - m*xarr[0]

    return xarr*m + n