Produce the osculating orbital elements for a position.

    The ``position`` should be an :class:`~skyfield.positionlib.ICRF`
    instance like that returned by the ``at()`` method of any Solar
    System body, specifying a position, a velocity, and a time.  An
    instance of :class:`~skyfield.elementslib.OsculatingElements` is
    returned.

def osculating_elements_of(position, reference_frame=None):
    """Produce the osculating orbital elements for a position.

    The ``position`` should be an :class:`~skyfield.positionlib.ICRF`
    instance like that returned by the ``at()`` method of any Solar
    System body, specifying a position, a velocity, and a time.  An
    instance of :class:`~skyfield.elementslib.OsculatingElements` is
    returned.

    """
    mu = GM_dict.get(position.center, 0) + GM_dict.get(position.target, 0)
    
    if reference_frame is not None:
        position_vec = Distance(reference_frame.dot(position.position.au))
        velocity_vec = Velocity(reference_frame.dot(position.velocity.au_per_d))
    else:
        position_vec = position.position
        velocity_vec = position.velocity
        
    return OsculatingElements(position_vec,
                              velocity_vec,
                              position.t,
                              mu)