def ABCDFrequencyList_to_SFrequencyList(ABCD_frequency_list,Z01=complex(50,0),Z02=complex(50,0)):
    """ Converts ABCD parameters into s-parameters. ABCD-parameters should be in the form [[f,A,B,C,D],...]
    Returns data in the form
    [[f,S11,S12,S21,S22],...],
    """
    s_frequency_list=[]
    for row in ABCD_frequency_list[:]:
        [frequency,A,B,C,D]=row
        denominator=A*Z02+B+C*Z01*Z02+D*Z01
        S11=(A*Z02+B-C*Z01.conjugate()*Z02-D*Z01.conjugate())/denominator
        S12=-1*(2*(Z01.real*Z02.real)**(.5))/denominator
        S21=-1*(2*(Z01.real*Z02.real)**(.5))/denominator
        S22=(-1*A*Z02.conjugate()+B-C*Z01*Z02+D*Z01)/denominator
        s_frequency_list.append([frequency,S11,S12,S21,S22])
    return s_frequency_list