def detection_time_to_impact(detection_time, impact_data):
    """
    Coverts detection time to an impact/damage metric.
    
    The impact DataFrame returned from this function can be used as input to
    :py:class:`ImpactFormulation<chama.optimization.ImpactFormulation>`.
    
    Parameters
    ----------
    detection_time : pandas DataFrame
        Detection time for each scenario-sensor pair. The DataFrame has 
        columns 'Scenario', 'Sensor', and 'T'. Note the 'T' column here is a
        single time and not a list of detection times.
    impact_data : pandas DataFrame
        Impact data for each scenario and time. The DataFrame has
        columns 'T' and one column for each scenario (user defined names)
        containing the impact/damage if each scenario was first detected at
        the times in 'T'.
        
    Returns
    ----------
    det_damage : pandas DataFrame
        DataFrame with columns 'Scenario', 'Sensor', and 'Impact'.
    """
    impact_data = impact_data.set_index('T')
    allT = list(set(detection_time['T']) | set(impact_data.index))
    impact_data = impact_data.reindex(allT)
    impact_data.sort_index(inplace=True)
    impact_data.interpolate(inplace=True)
    det_damage = detection_time.copy()
    det_damage['T'] = impact_data.lookup(detection_time['T'],
        detection_time['Scenario'])
    det_damage.rename(columns={'T': 'Impact'}, inplace=True)
    return det_damage
