def bit_errors(tx_data,rx_data,Ncorr = <NUM_LIT>,Ntransient = <NUM_LIT:0>):
<EOL>tx_data = <NUM_LIT:2>*tx_data[Ntransient:]-<NUM_LIT:1><EOL>rx_data = <NUM_LIT:2>*rx_data[Ntransient:]-<NUM_LIT:1><EOL>R0 = np.fft.ifft(np.fft.fft(rx_data,Ncorr)*<EOL>np.conj(np.fft.fft(tx_data,Ncorr)))<EOL>R1 = np.fft.ifft(np.fft.fft(-<NUM_LIT:1>*rx_data,Ncorr)*<EOL>np.conj(np.fft.fft(tx_data,Ncorr)))<EOL>R0 = np.fft.fftshift(R0)<EOL>R1 = np.fft.fftshift(R1)<EOL>R0max = np.max(R0.real)<EOL>R1max = np.max(R1.real)<EOL>R = np.array([R0max,R1max])<EOL>Rmax = np.max(R)<EOL>kphase_max = np.where(R == Rmax)[<NUM_LIT:0>]<EOL>kmax = kphase_max[<NUM_LIT:0>]<EOL>if kmax == <NUM_LIT:0>:<EOL><INDENT>lagmax = np.where(R0.real == Rmax)[<NUM_LIT:0>] - Ncorr/<NUM_LIT:2><EOL><DEDENT>elif kmax == <NUM_LIT:1>:<EOL><INDENT>lagmax = np.where(R1.real == Rmax)[<NUM_LIT:0>] - Ncorr/<NUM_LIT:2><EOL><DEDENT>taumax = lagmax[<NUM_LIT:0>]<EOL>print('<STR_LIT>' % (kmax, taumax))<EOL>if taumax < <NUM_LIT:0>:<EOL><INDENT>tx_data = tx_data[int(-taumax):]<EOL>tx_data = tx_data[:min(len(tx_data),len(rx_data))]<EOL>rx_data = (-<NUM_LIT:1>)**kmax*rx_data[:len(tx_data)]<EOL><DEDENT>else:<EOL><INDENT>rx_data = (-<NUM_LIT:1>)**kmax * rx_data[int(taumax):]<EOL>rx_data = rx_data[:min(len(tx_data),len(rx_data))]<EOL>tx_data = tx_data[:len(rx_data)]<EOL><DEDENT>Bit_count = len(tx_data)<EOL>tx_I = np.int16((tx_data.real + <NUM_LIT:1>)/<NUM_LIT:2>)<EOL>rx_I = np.int16((rx_data.real + <NUM_LIT:1>)/<NUM_LIT:2>)<EOL>Bit_errors = tx_I ^ rx_I<EOL>return Bit_count,np.sum(Bit_errors)<EOL>
Count bit errors between a transmitted and received BPSK signal.
Time delay between streams is detected as well as ambiquity resolution
due to carrier phase lock offsets of :math:`k*\\pi`, k=0,1.
The ndarray tx_data is Tx 0/1 bits as real numbers I.
The ndarray rx_data is Rx 0/1 bits as real numbers I.
Note: Ncorr needs to be even