def calculate_vs30(vmodel_file):
    """
    Calculates the Vs30 from the velocity model file
    """
    # Need to calculate Vs30 by adding each layer's up to 30m
    total_time = 0.0
    remaining_width = 30.0

    input_file = open(vmodel_file, 'r')
    for line in input_file:
        line = line.strip()
        if not line:
            continue
        tokens = [float(item) for item in line.split()]
        if len(tokens) != 6:
            continue
        layer_width = tokens[0] * 1000 # Convert to meters
        layer_vs = tokens[2] * 1000
        if layer_width <= remaining_width:
            remaining_width = remaining_width - layer_width
            total_time = total_time + (layer_width / layer_vs)
        else:
            total_time = total_time + (remaining_width / layer_vs)
            remaining_width = 0.0
        # Check if all done
        if remaining_width == 0.0:
            break
    input_file.close()

    # Calculate Vs30 based on total_time
    return (30.0 / total_time)