peng/touchstone.py
def _chunk_pars(freq_vector, data_matrix, pformat):
    """Chunk input data into valid Touchstone file rows."""
    pformat = pformat.upper()
    length = 4
    for freq, data in zip(freq_vector, data_matrix):
        data = data.flatten()
        for index in range(0, data.size, length):
            fpoint = [freq] if not index else [None]
            cdata = data[index : index + length]
            if pformat == "MA":
                vector1 = np.abs(cdata)
                vector2 = np.rad2deg(np.angle(cdata))
            elif pformat == "RI":
                vector1 = np.real(cdata)
                vector2 = np.imag(cdata)
            else:  # elif pformat == 'DB':
                vector1 = 20.0 * np.log10(np.abs(cdata))
                vector2 = np.rad2deg(np.angle(cdata))
            sep_data = np.array([])
            for item1, item2 in zip(vector1, vector2):
                sep_data = np.concatenate((sep_data, np.array([item1, item2])))
            ret = np.concatenate((np.array(fpoint), sep_data))
            yield ret
def _chunk_pars(freq_vector, data_matrix, pformat):
    """Chunk input data into valid Touchstone file rows."""
    pformat = pformat.upper()
    length = 4
    for freq, data in zip(freq_vector, data_matrix):
        data = data.flatten()
        for index in range(0, data.size, length):
            fpoint = [freq] if not index else [None]
            cdata = data[index : index + length]
            if pformat == "MA":
                vector1 = np.abs(cdata)
                vector2 = np.rad2deg(np.angle(cdata))
            elif pformat == "RI":
                vector1 = np.real(cdata)
                vector2 = np.imag(cdata)
            else:  # elif pformat == 'DB':
                vector1 = 20.0 * np.log10(np.abs(cdata))
                vector2 = np.rad2deg(np.angle(cdata))
            sep_data = np.array([])
            for item1, item2 in zip(vector1, vector2):
                sep_data = np.concatenate((sep_data, np.array([item1, item2])))
            ret = np.concatenate((np.array(fpoint), sep_data))
            yield ret
Chunk input data into valid Touchstone file rows.