def distortion_correct(
        x, y, x_d=3235.8, y_d=2096.1, A=0.0143, B=0.0078, r_d=1888.8):
    """Distortion correct pixel position according to Ken's model
       where
       x'=x_d+(x-x_d)*(1+A*(r/r_d)**2+B*(r/r_d)**4)
       y'=y_d+(y-y_d)*(1+A*(r/r_d)**2+B*(r/r_d)**4)
    """
    # calculate the radius of the source
    r = ((x - x_d) ** 2 + (y - y_d) ** 2) ** 0.5

    # calucluate the x and y corrected positions
    xi = x_d + (x - x_d) * (1 + A * (r / r_d) ** 2 + B * (r / r_d) ** 4)
    yi = y_d + (y - y_d) * (1 + A * (r / r_d) ** 2 + B * (r / r_d) ** 4)

    return xi, yi