from typing import List


def get_scenario_start_index(base_times: List[float], start_time: float):
    """
    Returns the index of the closest time step that is at, or before the scenario start time.
    """
    msg = f"Scenario start time {start_time} is before baseline has started"
    assert base_times[0] <= start_time, msg
    indices_after_start_index = [idx for idx, time in enumerate(base_times) if time > start_time]
    if not indices_after_start_index:
        raise ValueError(f"Scenario start time {start_time} is set after the baseline time range")

    index_after_start_index = min(indices_after_start_index)
    start_index = max([0, index_after_start_index - 1])
    return start_index