piel.experimental.measurements.data.frequency#
Attributes#
Functions#
|
Extracts numerical data from an S2P (Touchstone) file and returns it as a pandas DataFrame. |
Converts a pandas DataFrame containing S2P power sweep data into a NetworkTransmission object. |
|
Extracts power sweep data from an S2P file and converts it into a NetworkTransmission object. |
|
|
Converts a single DataFrame row containing S-parameter data into an SDict. |
Module Contents#
- logger#
- extract_s_parameter_data_from_vna_measurement(measurement: piel.types.experimental.VNASParameterMeasurement, **kwargs) piel.types.experimental.VNASParameterMeasurementData[source]#
- extract_power_sweep_data_from_vna_measurement(measurement: piel.types.VNAPowerSweepMeasurement, **kwargs) piel.types.VNAPowerSweepMeasurementData[source]#
- extract_power_sweep_s2p_to_dataframe(file_path: piel.types.PathTypes, input_frequency_Hz: float = 0, **kwargs)[source]#
Extracts numerical data from an S2P (Touchstone) file and returns it as a pandas DataFrame.
This function reads an S2P file, parses its numerical data, and organizes it into a structured pandas DataFrame. It skips comment lines and ensures that each data line contains the expected number of columns. If discrepancies are found, warnings are printed, and those lines are skipped.
Parameters:#
- file_pathPathTypes
The path to the S2P file to be processed. Can be a string or a Path-like object.
- input_frequency_Hzfloat, optional (default=0)
The input frequency in Hertz to be added as a column in the resulting DataFrame.
- **kwargs :
Additional keyword arguments to pass to the pandas DataFrame constructor.
Returns:#
: pd.DataFrame
A DataFrame containing the extracted data with the following columns: - p_in_dbm : Input power in dBm. - s_11_db : S-parameter S11 in dB. - s_11_deg : S-parameter S11 in degrees. - s_21_db : S-parameter S21 in dB. - s_21_deg : S-parameter S21 in degrees. - s_12_db : S-parameter S12 in dB. - s_12_deg : S-parameter S12 in degrees. - s_22_db : S-parameter S22 in dB. - s_22_deg : S-parameter S22 in degrees. - input_frequency_Hz : The input frequency provided as a parameter.
Example:#
>>> df = extract_power_sweep_s2p_to_dataframe('path_to_file.s2p', input_frequency_Hz=1e9) >>> print(df.head()) p_in_dbm s_11_db s_11_deg s_21_db s_21_deg s_12_db s_12_deg s_22_db s_22_deg input_frequency_Hz 0 -10.0000 -8.311036 90.38824 -11.35558 137.4781 -55.67513 54.62733 -8.564775 -164.7370 1000000000.0 1 -9.9977 -8.307557 90.38396 -11.34543 137.4497 -55.04230 53.47807 -8.555398 -164.7173 1000000000.0 2 -9.9953 -8.309752 90.35067 -11.35137 137.4250 -55.01111 48.11482 -8.562661 -164.6533 1000000000.0 3 -9.9930 -8.310988 90.35760 -11.34326 137.3693 -56.74514 39.34027 -8.559170 -164.7386 1000000000.0
Notes:#
Lines in the S2P file starting with ‘!’ or ‘#’ are treated as comments or headers and are skipped.
Each valid data line is expected to have exactly 9 numerical values corresponding to the defined columns.
If a line does not have 9 values or contains non-numeric data, a warning or error is printed, and the line is skipped.
- convert_power_sweep_s2p_to_network_transmission(dataframe) piel.types.NetworkTransmission[source]#
Converts a pandas DataFrame containing S2P power sweep data into a NetworkTransmission object.
- The DataFrame is expected to have the following columns:
‘input_frequency_Hz’: Frequency in Hz.
‘p_in_dbm’: Input power in dBm.
S-parameter magnitude and phase columns for each S-parameter, e.g., ‘s_11_db’, ‘s_11_deg’, etc.
- Assumptions:
All rows correspond to the same input frequency. If multiple frequencies are present, the first one is used.
Each row represents a different input power level.
- extract_power_sweep_s2p_to_network_transmission(file_path: piel.types.PathTypes, input_frequency_Hz: float = 0, **kwargs) piel.types.NetworkTransmission[source]#
Extracts power sweep data from an S2P file and converts it into a NetworkTransmission object.
This function combines the functionalities of extracting data from an S2P file into a pandas DataFrame and then converting that DataFrame into a NetworkTransmission instance. It serves as a convenient single-step process for obtaining structured transmission state data from an S2P file.
Parameters:#
- file_pathPathTypes
The path to the S2P file to be processed. Can be a string or a Path-like object.
- input_frequency_Hzfloat, optional (default=0)
The input frequency in Hertz to be added to the DataFrame before conversion.
- **kwargs :
Additional keyword arguments to pass to the extract_power_sweep_s2p_to_dataframe function.
Returns:#
: NetworkTransmission
An instance of NetworkTransmission populated with the extracted and converted data.
Example:#
>>> state = extract_power_sweep_s2p_to_network_transmission('path_to_file.s2p',input_frequency_Hz=1e9) >>> print(state) NetworkTransmission(p_in_dbm=[-10.0, -9.9977, ...], s_11_db=[-8.311036, -8.307557, ...], ...)
Notes:#
This function internally calls extract_power_sweep_s2p_to_dataframe and convert_power_sweep_s2p_to_frequency_array_state.
Ensure that the NetworkTransmission class is properly defined and accessible in your environment.
- convert_row_to_sdict(row)[source]#
Converts a single DataFrame row containing S-parameter data into an SDict.
Parameters:#
- rowpd.Series
A pandas Series containing S-parameter data with the following indices: - p_in_dbm - s_11_db - s_11_deg - s_21_db - s_21_deg - s_12_db - s_12_deg - s_22_db - s_22_deg
Returns:#
: SDict
A dictionary mapping PortCombination tuples to complex S-parameter arrays.
Example:#
>>> sdict = convert_row_to_sdict(df.iloc[0]) >>> print(sdict) { ('in0', 'in0'): DeviceArray(-0.03295842+0.0313j, dtype=float32), ('in0', 'out0'): DeviceArray(-0.03361994+0.0325j, dtype=float32), ('out0', 'in0'): DeviceArray(0.03118884+0.0477j, dtype=float32), ('out0', 'out0'): DeviceArray(-0.03206138-0.0143j, dtype=float32) }