piel.analysis.signals.frequency.core.extract#

Functions#

extract_phasor_to_dataframe(→ pandas.DataFrame)

Converts a Phasor instance into a pandas DataFrame with equivalent lengths for magnitude, phase, and frequency.

convert_complex_array_to_phasor_dataframe(...)

Converts an array of complex numbers into a pandas DataFrame with magnitude, phase, and frequency.

extract_phasor_type_to_dataframe(→ pandas.DataFrame)

Converts any PhasorTypes instance into a pandas DataFrame.

extract_two_port_network_transmission_to_dataframe(...)

Converts a NetworkTransmission instance into a single pandas DataFrame that includes:

get_s_parameter_start_index(→ int)

Determines the starting index for S-parameters based on the port connectivity in the NetworkTransmission.

Module Contents#

extract_phasor_to_dataframe(phasor: piel.types.Phasor) pandas.DataFrame[source]#

Converts a Phasor instance into a pandas DataFrame with equivalent lengths for magnitude, phase, and frequency.

Parameters: - input (Phasor): The Phasor instance to convert.

Returns: - pd.DataFrame: A DataFrame containing magnitude, phase, and frequency columns with appropriate units.

Raises: - TypeError: If the fields are of unsupported types. - ValueError: If the lengths of the fields do not match.

convert_complex_array_to_phasor_dataframe(complex_array: List[complex] | numpy.ndarray) pandas.DataFrame[source]#

Converts an array of complex numbers into a pandas DataFrame with magnitude, phase, and frequency. Sets frequency to 1 Hz for all entries.

Parameters: - complex_array (List[complex] | np.ndarray): The array of complex numbers to convert.

Returns: - pd.DataFrame: A DataFrame containing magnitude, phase, and frequency columns.

Raises: - TypeError: If the input is not a list or numpy array of complex numbers. - ValueError: If the complex array is empty.

extract_phasor_type_to_dataframe(phasor_type: piel.types.PhasorTypes) pandas.DataFrame[source]#

Converts any PhasorTypes instance into a pandas DataFrame. - If phasor_type is a Phasor instance, uses extract_phasor_to_dataframe. - If phasor_type is an array of complex numbers, converts to magnitude, phase, frequency=1. - If phasor_type is numerical (int or float), treats as scalar input with magnitude=phasor_type,

phase=0, frequency=1.

  • If phasor_type is a list or numpy array of numerical types, treats as magnitude with phase=0 and frequency=1.

Parameters: - phasor_type (PhasorTypes): The input type to convert.

Returns: - pd.DataFrame: A DataFrame containing magnitude, phase, and frequency columns.

Raises: - TypeError: If the phasor_type is of unsupported type. - ValueError: If input data is invalid.

extract_two_port_network_transmission_to_dataframe(network_transmission: piel.types.NetworkTransmission) pandas.DataFrame[source]#

Converts a NetworkTransmission instance into a single pandas DataFrame that includes: - The main input data from NetworkTransmission.input. - The transmission input data from each PathTransmission in NetworkTransmission.network,

with columns prefixed by the corresponding S-parameter name (e.g., s_11, s_21).

This function is generalized to handle both integer-based port tuples (e.g., (0, 0)) and string-based port tuples (e.g., (“in0”, “out0”)).

Parameters: - network_transmission (NetworkTransmission): The NetworkTransmission instance to convert.

Returns: - pd.DataFrame: A combined DataFrame containing the main input and all path transmission phasors.

Raises: - TypeError: If any transmission input is of unsupported type. - ValueError: If any input data is invalid or if DataFrames have mismatched lengths.

get_s_parameter_start_index(network_transmission: piel.types.NetworkTransmission) int[source]#

Determines the starting index for S-parameters based on the port connectivity in the NetworkTransmission.

It determines all the existing ports in all the connections and extracts the minimum port connectivity. Then, based on the minimum port index, it sets the starting index: - If the minimum port index is 0, starting_index is 0 - If the minimum port index is 1, starting_index is 1 - Otherwise, raises a ValueError

Parameters:

network_transmission (NetworkTransmission) – The network transmission instance.

Returns:

The starting index (0 or 1).

Return type:

int

Raises:

ValueError – If the minimum port index is not 0 or 1, or if no ports are found.