def vbar(vmodel, event_depth, station_elevation):
    """
    Calculates the average velocity between source and receiver for a given
    velocity model.

    Only need the difference in the vertical axis as sines of angles will
    cancel.

    Parameters
    ----------
    vmodel : pandas DataFrame
        Contains the velocity model, ordered by deepest layer first.
    event_depth : float
        Depth of event. Units should be consistent with station_elevation.
    station_elevation : float
        Elevation of event. Units should be consistent with depth of event.

    Returns
    -------
    vbar : float
        Average velocity within the model.

    """

    average = 0.0

    for i, layer in vmodel.iterrows():
        layer_top = vmodel.iloc[i+1][0]
        layer_bottom = layer[0]

        if station_elevation < layer_bottom and station_elevation > layer_top:
            layer_top = station_elevation
        if layer_top == -100.0:
            break
        if event_depth <= layer_top:
            continue
        elif event_depth > layer_top and event_depth <= layer_bottom:
            # Handle interpolated distance
            dist_in_layer = abs(event_depth - layer_top)
        else:
            # Handle full layer
            dist_in_layer = abs(layer_bottom - layer_top)

        average += dist_in_layer * layer[2]

    return average / (event_depth - station_elevation)