def wrap360deg(deg: 'np.ndarray') ->'np.ndarray':
    """
    Make sure that degrees (e.g. heading) is within 360 range.

    Ref: https://www.movable-type.co.uk/scripts/latlong-vincenty.html
    """
    mask = (deg < 0) | (deg > 360)
    deg[mask] = (deg[mask] % 360 + 360) % 360
    return deg
