MS2760A module

Created on Wed Dec 1 13:11:32 2021

@author: Martin.Mihaylov

class Instruments_Libraries.MS2760A.MS2760A(ip='127.0.0.1', port=59001, visa_library='@py')[source]

Bases: BaseInstrument

Driver for Anritsu MS2760A Spectrum Analyzer using BaseInstrument. Handles the socket-specific read/write terminations.

abort()[source]

Resets the trigger system. This has the effect of aborting the sweep or any measurement that is currently in progress. Additionally, any pending operation flags that were set by initiation of the trigger system will be set to false. If :INITiate:CONTinuous is OFF (i.e. the instrument is in single sweep mode), send the command :INITiate[:IMMediate] to trigger the next sweep. If :INITiate:CONTinuous is ON (i.e. the instrument is in continuous sweep mode) a new sweep will start immediately

Return type:

None

clear()[source]

Clears input and output buffers

Return type:

None

clear_trace(trace_num=1)[source]

Clear the trace.

Parameters:

trace_num (int, optional) – Trace number to clear. Default: 1.

Return type:

None

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. Matches FSWP50 interface. Does NOT trigger a new measurement (use measure_and_get_trace for that).

Parameters:
  • trace (int) – Trace number (1-6)

  • window (int) – Window number (Ignored for MS2760A)

  • 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]

extract_trace_data_legacy(trace_num=1)[source]

Old function to keep legacy scripts working. Better use: ExtractTraceData()

!!!!!USE IT AT YOUR OWN RISK is not an official function, but a workaround!!!!!

1 - This Function will set the continues Measurement to ‘OFF’. 2 - Will set the Data Format to ASCii. This is needed since :TREACE:DATA? <num> is defect!! 3 - Will write TRACE:DATA? <num>. Will return only 3 bits. The rest will be packed in the next command asked. 4 - Will ask for the Data Format. This is dummy command that will have the data and the Data Format. 5 - Make manupulations to separate the actual data from the rest and return the data in Output np.array() form.

Parameters:

trace_num (int) – Trace Number from which the data is taken: Can be set to [1,2,3,4,5,6].

Returns:

Measured spectrum on the given trace.

Return type:

np.ndarray

get_capture_time()[source]

Returns the capture time in ms. Range 0 ms to 10000 ms.

Return type:

float

get_center_frequency()[source]

Query the center frequency in Hz.

Return type:

float

get_ch_power_state()[source]

Query the channel power measurement state.

Returns:

1 if State is ON, 0 if OFF.

Return type:

int

get_configuration()[source]

Query the instrument configuration information. This command returns a quoted string of characters readable only by Anritsu Customer Service. Only instrument configuration information is returned. No setup information is included.

Return type:

str

get_continuous()[source]

Query whether the instrument is in continuous or single sweep mode.

Returns:

1 for continuous sweep, 0 for single sweep.

Return type:

int

get_data(marker_num=1, return_array=False)[source]

This function will stop temporally set Continuous Measurement to OFF, extract the max. peak value and frequency and restore the Continuous Measurement to ON.

Returns:

Measured frequency in Hz and peak power in dBm.

Return type:

dict | np.ndarray

Parameters:
  • marker_num (int)

  • return_array (bool)

get_data_format()[source]

Returns a string indicating the data format.

Return type:

str

get_detector_type(trace_number=1)[source]

Query the detector type.

Parameters:

trace_number (int) – Trace number (1 to 6).

Returns:

Detector type (e.g., POS, RMS, NEG).

Return type:

str

get_if_gain_state()[source]

Query the IF gain state (1=on, 0=off).

Return type:

int

get_marker_excursion()[source]

Query the marker excursion data. The excursion is the vertical distance from the peak to the next highest valley which must be exceeded for a peak to be considered a peak in marker max commands.

Return type:

str

get_marker_excursion_state()[source]

Query the peak marker excursion state. (1=on, 0=off).

Return type:

int

get_marker_values(marker_num=None)[source]

Query the marker values.

Parameters:

marker_num (int, optional) – Marker number (1 to 12). If omitted, returns all markers. Default: None.

Return type:

list | tuple

get_opc_status(delay=5.0)[source]

Places a 1 into the output queue when all device operations have been completed.

Parameters:

delay (float, optional) – Delay between write and read in seconds. Default: 5.0.

Returns:

1 if operation is completed, 0 otherwise.

Return type:

int

get_operation_status()[source]

Returns the operation status of the instrument.

Returns:

256 if operation is completed, 0 otherwise.

Return type:

int

get_reference_level()[source]

Query the reference level in dBm.

Return type:

float

get_resolution_bandwidth()[source]

Query the resolution bandwidth in Hz.

Return type:

float

get_resolution_bandwidth_auto()[source]

Query the automatic resolution bandwidth setting.

Returns:

1 if in automatic mode (ON), 0 if not (OFF).

Return type:

int

get_span()[source]

Query the frequency span in Hz.

Return type:

float

get_start_frequency()[source]

Query for the start frequency in Hz.

Return type:

float

get_stop_frequency()[source]

Query for the stop frequency in Hz.

Return type:

float

get_sweep_points()[source]

Query the display point count.

Return type:

int

get_sweep_time()[source]

Query the measured sweep time (in milliseconds).

Returns:

Measured sweep time in ms. Returns nan if not available.

Return type:

float

get_trace_mode(trace_number=1, **kwargs)[source]

Query the trace mode for a given trace number.

Parameters:

trace_number (int) – Trace number (1 to 6).

Returns:

Trace mode (e.g., NORM, MIN, MAX, AVER, RMAX, RMIN, RAV).

Return type:

str

get_trace_selected()[source]

Returns the currently selected trace. The max number of traces available to select is model specific.

Return type:

int

get_trace_state(trace_number=1)[source]

Query the display state of a given trace. If it is OFF, the :TRAC:DATA? command will return nan.

Parameters:

trace_number (int) – Trace number (1 to 6).

Return type:

int

get_trace_xy(trace_number=1)[source]

Queries both X (Frequency) and Y (Amplitude) trace data. Calculates X data based on start/stop frequency and sweep points.

Parameters:

trace_number (int) – Trace number (1-6).

Returns:

(x_array, y_array)

Return type:

tuple[np.ndarray, np.ndarray]

init()[source]

Initialize measurement.

Return type:

None

measure_and_get_trace(trace_number=1, clear_trace=True, timeout=20)[source]

Initiate a new measurement and return the trace Y-data (Blocking). Renamed from ‘extract_trace_data’ to match FSWP50 interface.

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.

Raises:

TimeoutError

Returns:

Amplitude data.

Return type:

np.ndarray

set_capture_time(capture_time=0, unit='ms')[source]

Determines how much time to spend taking samples for each portion of the spectrum.

Parameters:
  • capture_time (float, optional) – Capture time. Range: 0.0 to 10000.0. Default: 0.0.

  • unit (str, optional) – Default: MS. Options: {PS | NS | US | MS | S | MIN | HR}

Return type:

None

set_center_frequency(value, unit='Hz')[source]

Sets the center frequency. Note that changing the value of the center frequency will change the value of the coupled parameters Start Frequency and Stop Frequency. It might also change the value of the span.

Parameters:
  • value (int | float) – Sets the center frequency.

  • unit (str) – Default: HZ. Options: {HZ | KHZ | MHZ | GHZ}

Return type:

None

set_ch_power_state(state)[source]

Sets the channel power measurement state. Sets the state of the channel power measurement, ON or OFF. When using :CONFigure:CHPower, the state is automatically set to ON.

Parameters:

state (str | int) – Channel power measurement state. Options: {1 | 0 | ON | OFF}

Return type:

None

set_continuous(state)[source]

Specifies whether the sweep/measurement is triggered continuously. If the value is set to ON or 1, another sweep/measurement is triggered as soon as the current one completes. If continuous is set to OFF or 0, the instrument remains initiated until the current sweep/measurement completes, then enters the ‘idle’ state and waits for the :INITiate[:IMMediate] command or for :INITiate:CONTinuous ON.

Parameters:

state (str | int) – Sets the continuous measurement state. Options: {1 | 0 | ON | OFF}

Return type:

None

set_data_format(state='ASCii')[source]

Sets the data format. Only ASCii works!!!

Parameters:

state (str) – Set Data Format. Options: {ASCii | INTeger | REAL}

Return type:

None

set_detector_mode(mode='POSitive', trace_number=1, **kwargs)[source]

Sets the detector mode.

Parameters:
  • mode (str) – Detector mode. Options: {POSitive | RMS | NEGative}

  • trace_number (int) – Trace number (1 to 6). Default: 1.

Return type:

None

set_if_gain_state(state)[source]

Sets the state of the IF gain ON or OFF. ON is only possible when reference level is set to <-10 dBm.

Parameters:

state (str | int) – IF gain state. Options: {1 | 0 | ON | OFF}

Return type:

None

set_marker_excursion(value)[source]

Sets the excursion for a marker. The excursion is the vertical distance from the peak to the next highest valley which must be exceeded for a peak to be considered a peak in marker max commands.

Parameters:

value (int | float) – Excursion for a marker in dB. Range: 0.0 to 200.0.

Return type:

None

set_marker_excursion_state(state)[source]

Turn on/off marker excursion state.

Parameters:

state (str | int) – Marker excursion state. Options: {1 | 0 | ON | OFF}

Return type:

None

set_marker_preset()[source]

Presets all markers to their preset values.

Return type:

None

set_max_peak(marker_num=1)[source]

Moves the marker to the highest peak.

Parameters:

marker_num (int) – Marker number (1 to 12). Default: 1.

Return type:

None

set_next_peak(marker_num=1)[source]

Moves the marker to the next highest peak.

Parameters:

marker_num (int) – Marker number (1 to 12). Default: 1.

Return type:

None

set_reference_level(level)[source]

Set the reference level in dBm.

Parameters:

level (float) – Reference level in dBm.

Return type:

None

set_resolution_bandwidth(res_bw, unit='Hz')[source]

Sets the resolution bandwidth. Note that using this command turns the automatic resolution bandwidth setting OFF. In Zero Span, the range will change to allow a minimum of 5 KHz to the maximum of 20 MHz.

Parameters:
  • res_bw (int | float) – Sets the resolution bandwidth.

  • unit (str) – Default: HZ. Options: {HZ | KHZ | MHZ | GHZ}

Return type:

None

set_resolution_bandwidth_auto(state)[source]

Sets the automatic resolution bandwidth state. Setting the value to ON or 1 will result in the resolution bandwidth being coupled to the span. That is, when the span changes, the resolution bandwidth changes. When this command is issued, the resolution bandwidth setting itself will not change.

Parameters:

state (int | str) – Coupling state of resolution bandwidth to span. Default: ON. Options: {1 | 0 | ON | OFF}

Return type:

None

set_span(value, unit='Hz')[source]

Sets the frequency span. Setting the value of <freq> to 0 Hz is the equivalent of setting the span mode to zero span. Note that changing the value of the frequency span will change the value of the coupled parameters Start Frequency and Stop Frequency and might change the Center Frequency.

Parameters:
  • value (int | float) – Sets the frequency span.

  • unit (str) – Default: HZ. Options: {HZ | KHZ | MHZ | GHZ}

Return type:

None

set_start_frequency(value, unit='Hz')[source]

Sets the start frequency. Note that in the spectrum analyzer, changing the value of the start frequency will change the value of the coupled parameters, Center Frequency and Span.

Parameters:
  • value (int | float) – Sets the start frequency.

  • unit (str) – Default: HZ. Options: {HZ | KHZ | MHZ | GHZ}

Return type:

None

set_stop_frequency(value, unit='Hz')[source]

Sets the stop frequency. Note that in the spectrum analyzer, changing the value of the start frequency will change the value of the coupled parameters, Center Frequency and Span.

Parameters:
  • value (int | float) – Sets the stop frequency.

  • unit (str) – Default: HZ. Options: {HZ | KHZ | MHZ | GHZ}

Return type:

None

set_sweep_points(datapoints=501)[source]

Changes the number of display points the instrument currently measures. Increasing the number of display points can improve the resolution of measurements but will also increase sweep time.

Parameters:

datapoints (int) – Number of points. Range: 10 to 10001. Default: 501.

Return type:

None

set_trace_mode(mode='NORM', trace_number=1, **kwargs)[source]

Sets the trace mode.

Parameters:
  • mode (str) –

    • Normal - NORM or WRITE

    • Hold the Minimum - MIN or MINHOLD

    • Hold the Maximum - MAX or MAXHOLD

    • Average - AVER or AVERAGE

    • Rolling Max Hold - RMAX

    • Rolling Min Hold - RMIN

    • Rolling Average - RAV

  • trace_number (int) – Trace number (1 to 6). Default: 1.

Return type:

None

set_trace_selected(trace_number=1)[source]

The selected trace will be used by operations that use a single trace. The max number of traces available to select is model specific.

Parameters:

trace_number (int) – Trace number (1 to 6). Default: 1.

Return type:

None

set_trace_state(state='ON', trace_number=1)[source]

The trace visibility state status. If it is OFF, the :TRAC:DATA? command will return NaN.

Parameters:
  • state (str | int) – Trace visibility state. Options: {1 | 0 | ON | OFF}

  • trace_number (int) – Trace number (1 to 6). Default: 1.

Return type:

None