FSWP50 module
Created on Wed Feb 26 20:21:23 2025
@author: Maxim Weizel @contributor: Rakibul Islam
- class Instruments_Libraries.FSWP50.FSWP50(resource_str, visa_library='@py', **kwargs)[source]
Bases:
BaseInstrumentThis class is using PyVISA to connect. Requires NI-VISA or Keysight VISA backend.
- Parameters:
resource_str (str)
visa_library (str)
- create_channel(channel_type, channel_name)[source]
Creates a new measurement channel.
- Parameters:
channel_type (str) – Available types are: *
PNOISE: ‘Phase Noise’ *SMONITOR: ‘Spectrum Monitor’ *SANALYZER: ‘Spectrum (R&S FSWP-B1)’ *IQ: ‘I/Q Analyzer’ *PULSE: ‘Pulse Measurement’ *ADEMOD: ‘Analog modulation analysis’ *NOISE: ‘Noise Figure Measurements’ *SPUR: ‘Fast Spur Search’ *TA: ‘Transient Analysis’ *DDEM: ‘VSA - Vector Signal Analysis’channel_name (str) – Unique name for the new channel.
- Raises:
ValueError – If channel type is invalid or name already exists.
RuntimeError – If instrument command fails.
- Return type:
None
- delete_channel(channel_name)[source]
Deletes a channel. If you delete the last channel, the default “Phase Noise” channel is activated.
- Parameters:
channel_name (str) – Your Channel Name.
- Return type:
None
- disable_spot_noise()[source]
Turns off all spot noise information. Reference: R&S FSWP User Manual, Page 496.
- Return type:
None
- duplicate_selected_channel(channel_name)[source]
Duplicates the specified channel.
- Parameters:
channel_name (str) – The name of the channel to duplicate.
- enable_spur_removal(window=1, trace=1, state=1)[source]
Enables or disables spur removal for a specific trace. Reference: Page 500.
- Parameters:
window (int)
trace (int)
state (int | str)
- Return type:
None
- export_trace_to_csv(y_data, x_data=None, filename='trace_output.csv')[source]
Exports trace data to a CSV file using pandas.
- Parameters:
y_data (np.ndarray) – The amplitude/phase noise data (Y-axis).
x_data (np.ndarray, optional) – The frequency/offset data (X-axis). If None, an index column is created.
filename (str, optional) – The name of the CSV file.
- extract_trace_data(trace=1, window=1, points=False, num_of_points=None, export=False, filename='trace_export.csv')[source]
Advanced extraction: Gets X and Y data, with optional downsampling and CSV export.
- Parameters:
trace (int) – Trace number (1-6)
window (int) – Window number (1-16)
points (bool) – Whether to limit number of points in output (downsample)
num_of_points (int, optional) – Desired number of output points if points=True
export (bool) – If True, saves the data to a CSV file
filename (str) – Output CSV file name (used if export=True)
- Return type:
tuple[ndarray, ndarray]
- get_input_attenuation_auto()[source]
Queries whether input attenuation auto mode is ON or OFF.
- Return type:
str
- get_rbw_pn()[source]
Queries the current Resolution Bandwidth (RBW) setting for phase noise.
Automatically detects if the mode is ‘NORM’ (automatic ratio) or ‘MAN’ (manual).
Returns the RBW ratio (%) or manual RBW values per half-decade.
- Reference:
RBW Ratio: LIST:BWID:RAT? (Page 485)
Manual RBW: LIST:RANG<ri>:BWID? (Page 485)
Mode: SWE:MODE? (Page 488)
- Return type:
float | dict
- get_reference_level_lower()[source]
Queries the minimum level displayed on the y-axis.
- Return type:
float
- get_resolution_bandwidth()[source]
Queries the current resolution bandwidth in Hz.
- Return type:
float
- get_spur_filter_harmonics()[source]
Queries whether harmonics are included in the spurious filter.
- Return type:
str
- get_spur_filter_name()[source]
Queries the name of the currently selected spurious filter.
- Return type:
str
- get_start_offset(unit='Hz')[source]
Queries the current start offset frequency for phase noise measurement.
- Parameters:
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}- Return type:
float
- get_stop_offset(unit='Hz')[source]
Queries the stop offset frequency for phase noise measurement.
- Parameters:
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}- Return type:
float
- get_trace_data(trace_number, window_number=1)[source]
Queries current trace Y-data (Amplitudes) from the instrument.
- Parameters:
trace_number (int) – Trace number between 1 and 6
window_number (int, optional) – Window number between 1 and 16, by default 1
- Return type:
ndarray
- get_trace_xy(trace_number=1, window_number=1)[source]
Queries both X (Frequency/Offset) and Y (Amplitude) trace data. Often used in Phase Noise application where X-axis spacing is non-linear.
- Parameters:
trace_number (int, optional) – The trace number to query. Default is 1.
window_number (int, optional) – The window number to query. Default is 1.
- Return type:
tuple[ndarray, ndarray]
- init_single_measurement()[source]
Restarts a (single) measurement that has been stopped (using ABORt) or finished in single measurement mode.
- Return type:
None
- list_channels()[source]
Queries all active channels. The query is useful to obtain the names of the existing channels, which are required to replace or delete the channels.
- Return type:
list
- measure_and_get_trace(trace_number=1, window_number=1, clear_trace=True, timeout=20)[source]
Initiate a new measurement and return the trace Y-data (Blocking). Matches standard legacy spectrum analyzer behavior.
- Parameters:
trace_number (int) – Trace Number: Can be set to [1,2,3,4,5,6].
clear_trace (bool, optional) – Clears the trace before taking the data measurement. The default is True.
timeout (float, optional) – Defines the timeout for the operation. The default is 20s.
window_number (int, optional) – Window number between 1 and 16, by default 1
- Return type:
ndarray
- reset_integration_range_to_meas(range_index)[source]
Resets the integration range to default full measurement range (MEAS).
- Parameters:
range_index (int) – The index of the integration range to reset (1-10).
- Return type:
None
- set_capture_range(mode)[source]
Set the Capture Range for Phase Noise measurement.
- Parameters:
mode (str) – Capture Range mode. Options: {
NORMAL|WIDE|40MHZ}- Return type:
None
- set_center_frequency(center_freq, unit='Hz')[source]
Sets the center frequency for pulsed and VCO measurements.
- Parameters:
center_freq (int | float) – Frequency value (e.g., 1, 2.5) to be combined with unit.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}
- Return type:
None
- set_continuous(state)[source]
Controls the measurement mode for an individual channel.
- Parameters:
state (int | str) – Options: {
1|0|ON|OFF}- Return type:
None
- set_decade_spot_noise(state, trace=1, display='ON')[source]
Enables or disables decade spot noise and assigns it to a trace.
- Parameters:
state (str) – Options: {
ON|OFF}trace (int, optional) – Trace number (1-6). Default is 1.
display (str, optional) – Options: {
ON|OFF}
- set_detector_mode(mode, trace_number=1, window_number=1, **kwargs)[source]
Defines the trace detector to be used for trace analysis
- Parameters:
mode (str) – Detector mode. Options: {
APEAK|NEGATIVE|POSITIVE|RMS|AVERAGE|SAMPLE}trace_number (int, optional) – Trace number, by default 1.
window_number (int, optional) – Window number, by default 1.
- Return type:
None
- set_input_attenuation(atten)[source]
Set the input attenuation.
- Parameters:
atten (float) – Attenuation value.
- Return type:
None
- set_input_attenuation_auto(state)[source]
Set the input attenuation auto mode to ON or OFF.
- Parameters:
state (str | int) – Options: {
1|0|ON|OFF}- Return type:
None
- set_integration_manual(range_index, start_freq, stop_freq)[source]
Sets a custom integration range for the Integrated Measurement tab. Reference: Page 173-174.
- Parameters:
range_index (int) – Integration range index (1-10).
start_freq (str) – Start frequency with unit (e.g., ‘10Hz’, ‘1kHz’).
stop_freq (str) – Stop frequency with unit.
- Return type:
None
- set_manual_spot_noise(marker, offset, enable='ON', display='ON', trace=1)[source]
Enables or disables a custom (manual) spot noise marker.
- Parameters:
marker (int) – Spot noise marker index (1-6).
offset (str) – Frequency offset with unit (e.g., “100kHz”).
enable (str, optional) – Options: {
ON|OFF}display (str, optional) – Options: {
ON|OFF}trace (int, optional) – Trace number (1-6).
- set_multiview_tab(state)[source]
Toggles the MultiView tab display.
- Parameters:
state (bool | int) – True/1 to enable MultiView (ON), False/0 to disable (OFF). Options: {
1|0|ON|OFF}- Return type:
None
- set_rbw_absolute(half_decade, bandwidth, unit='Hz')[source]
Set absolute RBW for a specific half-decade (manual mode).
- Parameters:
half_decade (int) – Half-decade index (1 … N).
bandwidth (float) – RBW value.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ}
- Return type:
None
- set_rbw_ratio(percentage)[source]
Set RBW as a ratio (%) of start offset (automatic mode).
- Parameters:
percentage (float) – RBW ratio in percent (0.1 to 30).
- Return type:
None
- set_reference_level(ref_level)[source]
This command defines the maximum level displayed on the y-axis.
- Parameters:
ref_level (float) – Default unit: Depending on the selected diagram.
- Return type:
None
- set_reference_level_lower(ref_level=0)[source]
This command defines the minimum level displayed on the y-axis.
- Parameters:
ref_level (float, optional) – Default unit: Depending on the selected diagram.
- Return type:
None
- set_resolution_bandwidth(res_bw, unit='Hz')[source]
Sets the resolution bandwidth.
- Parameters:
res_bw (int | float) – Sets the resolution bandwidth.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}
- Return type:
None
- set_span(span, unit='Hz')[source]
Sets the frequency span for the spectrum analyzer.
- Parameters:
span (int | float) – Span value.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}
- Return type:
None
- set_spur_filter_harmonics(state='OFF')[source]
Sets whether harmonics are included in the spurious filter.
- Parameters:
state (str | int)
- Return type:
None
- set_spur_filter_mode(mode='OFF')[source]
Sets the spurious filter mode. Options: {
OFF|SUPPress|SHOW} Reference: Page 177.- Parameters:
mode (str)
- Return type:
None
- set_spur_hide(window=1, trace=1, state='ON')[source]
Enables or disables hiding of spurs in display
SCPI Reference: DISP:WIND<n>:TRAC<t>:SPUR:SUPP
- Parameters:
window (int)
trace (int)
state (str | int)
- Return type:
None
- set_spur_sort_order(order='POWer')[source]
Sets the sorting order of the spurs: “POWer” or “OFFSet”. Reference: Page 501.
- Parameters:
order (str)
- Return type:
None
- set_spur_threshold(window=1, trace=1, threshold_dB=10.0)[source]
Sets the detection threshold for spur removal in dB. Reference: Page 500.
- Parameters:
window (int)
trace (int)
threshold_dB (float)
- Return type:
None
- set_start_frequency(start_freq, unit='Hz')[source]
This command defines the start frequency offset of the measurement range.
- Parameters:
start_freq (float) – Start frequency.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}
- Return type:
None
- set_start_offset(start_offset, unit='Hz')[source]
Sets the start offset frequency for phase noise measurement. Reference: User manual, page number 481
- Parameters:
start_offset (int or float) – The numeric value of the start offset.
unit (str, optional) – Unit of the offset: ‘Hz’, ‘kHz’, ‘MHz’, ‘GHz’. Default is ‘Hz’.
- Return type:
None
- set_stop_frequency(stop_freq, unit='Hz')[source]
This command defines the stop frequency offset of the measurement range.
- Parameters:
stop_freq (float) – Stop frequency.
unit (str, optional) – Default:
HZ. Options: {HZ|KHZ|MHZ|GHZ}
- Return type:
None
- set_stop_offset(stop_offset, unit='Hz')[source]
Sets the stop offset frequency for phase noise measurement. Reference: User manual, page number 482
- Parameters:
stop_offset (int or float) – The numeric value of the stop offset.
unit (str, optional) – Unit of the offset: ‘Hz’, ‘kHz’, ‘MHz’, ‘GHz’. Default is ‘Hz’.
- Return type:
None
- set_sweep_points(datapoints)[source]
This command defines the number of measurement points to analyze after a measurement.
- Parameters:
datapoints (int) – Number of data points. Range: 101 to 100001.
- Return type:
None
- set_trace_mode(trace_mode, trace_number=1, window_number=1)[source]
Selects the trace mode (WRITE, AVERAGE, MAXHOLD, etc).
- Parameters:
trace_mode (str)
trace_number (int)
window_number (int)
- Return type:
None
- set_trace_smoothing(window=1, trace=1, state='ON')[source]
Enables or disables smoothing for a trace.
SCPI Reference: DISP:WIND<n>:TRAC<t>:SMO:STAT
- Parameters:
window (int)
trace (int)
state (str | int)
- Return type:
None