MS2760A module

Created on Wed Dec 1 13:11:32 2021

@author: Martin.Mihaylov

class Instruments_Libraries.MS2760A.MS2760A(resource_str='127.0.0.1', port=59001)[source]

Bases: object

This function is using pyvisa to connect to Instruments. Please install PyVisa before using it.

Parameters:
  • resource_str (str)

  • port (int)

ClearTrace(traceNumber=1)[source]

Clear the trace.

Parameters:

traceNumber (int, optional) – DESCRIPTION. The default is 1.

Return type:

None

Close()[source]
ExtractTraceData(traceNumber=1, clearTrace=True, timeout=20)[source]

Uses a workaround to read the trace data. Clears the Trace before taking the measurement and returns the data. Set Continuous Measurement to ‘OFF’.

Parameters:
  • traceNumber (int) – Trace Number: Can be set to [1,2,3,4,5,6].

  • clearTrace (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:

Output

Return type:

np.array

ExtractTtraceData(traceNumber=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:

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

Returns:

Output – Measured Spectrum on Trace {num}.

Return type:

np.ndarray

Idn()[source]

Identify the Insturment.

Returns:

A string with the Instrument name.

Return type:

str

Init()[source]

Initialize measurement.

Return type:

None

OPC(delay=5.0)[source]

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

Parameters:

delay (float, optional) – DESCRIPTION. The default is 5s delay between write and read.

Returns:

1 if device operation is completed. 0 if device operation is not completed.

Return type:

int

StatusOperation()[source]

Returns the operation status of the instrument

Returns:

256 if device operation is completed. 0 if device operation is not completed.

Return type:

int

abort()[source]

Description: 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

ask_CHPowerState()[source]

Query the channel power measurement state.

Returns:

1 if State is ON. 0 if State is OFF

Return type:

str

ask_CaptureTime()[source]

Query the capture time in ms.

Returns:

Capture Timte in ms. Range 0 ms to 10000 ms.

Return type:

float

ask_CenterFreq()[source]

Query the center frequency.

Returns:

Center Frequency in Hz

Return type:

float

ask_Configuration()[source]

Query the instrument configuration information.

Returns:

Description: 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

ask_DataFormat()[source]

Query the data format.

Returns:

A string indicating the data format.

Return type:

str

ask_DataPointCount()[source]

Query the display point count.

Returns:

Query the data point count.

Return type:

int

ask_DetectorType(traceNumber=1)[source]

Query the detector type.

Parameters:

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

Returns:

Detector Type: POS|RMS|NEG

Return type:

str

ask_FreqSpan()[source]

Query the frequency span.

Returns:

Frequency Span in Hz

Return type:

float

ask_IFGainState()[source]

Query the IF gain state.

Returns:

1 if State is ON. 0 if State is OFF.

Return type:

int

ask_MarkerExcursion()[source]

Query the marker excursion data.

Returns:

Query 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

Return type:

str

ask_MarkerExcursionState()[source]

Query the peak marker excursion state.

Returns:

Excursion on/off

Return type:

int

ask_MarkerValues(markerNumber=None)[source]

Query the marker values.

Parameters:

markerNumber (int, optional) – Marker Number between 1 - 12. The default is None.

Returns:

List of tuples with all marker values. Tuple with the specified marker value

Return type:

list

ask_RefLevel()[source]

Query the reference level.

Returns:

Reference Level in dBm

Return type:

float

ask_ResBwidth()[source]

Query the resolution bandwidth.

Returns:

Resolution Bandwidth in Hz

Return type:

float

ask_ResBwidthAuto()[source]

Query the automatic resolution bandwidth setting.

Returns:

1 if in automatic mode (“ON”) 0 if not in automatic mode (“OFF”)

Return type:

int

ask_SingleOrContinuesMeas()[source]

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

Returns:

1 if the instrument is in continuously sweeping/measuring. 0 if the instrument is in single sweep/measurement mode.

Return type:

int

ask_TraceSelected()[source]

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

Returns:

Returns selected trace.

Return type:

str

ask_TraceState(traceNumber=1)[source]

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

Parameters:

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

Raises:

ValueError – Error message

Returns:

1 if State is ON. 0 if State is OFF.

Return type:

int

ask_TraceType(traceNumber=1)[source]

Query the trace type for a given trace number.

Parameters:

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

Raises:

ValueError – Error message

Returns:

Trace Type: NORM|MIN|MAX|AVER|RMAX|RMIN|RAV

Return type:

str

ask_freq_Start()[source]

Query for the start frequency.

Returns:

Start Frequency in Hz.

Return type:

float

ask_freq_Stop()[source]

Query for the stop frequency.

Returns:

Stop Frequency in Hz.

Return type:

str

ask_sweepTime()[source]

Query the measured sweep time (in milliseconds).

Returns:

measured sweep time in milliseconds. “nan” if no measured sweep time is available.

Return type:

float

clear()[source]

Clears input and output buffers

Return type:

None

get_Data(markerNumber=1, returnArray=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:

OutPut – Return a dictionary with the measured frequency in Hz and peak power in dBm.

Return type:

dict/np.ndarray

Parameters:
  • markerNumber (int)

  • returnArray (bool)

query(message)[source]
query_ascii_values(message, **kwargs)[source]
read()[source]
reset()[source]

Resets the instrument.

Return type:

None

set_CHPowerState(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) – state = [‘ON’,’OFF’,1,0]

Raises:

ValueError – Error message

Return type:

None

set_CaptureTime(captureTime=0, unit='ms')[source]

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

Parameters:
  • captureTime (float, optional) – default: 0 ms, Range: 0 ms to 10000 ms

  • unit (str, optional) – default: ‘ms’

Raises:

ValueError – Error message

Return type:

None

set_CenterFreq(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 (float) – Sets the center frequency.

  • unit (str) – Unit value. Can be [‘HZ’,’KHZ’,’MHZ’,’GHZ’]

Raises:

ValueError – Error message

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. <1 | 0 | ON | OFF>

Raises:

ValueError – Error message

Return type:

None

set_ContinuousMeas(state)

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. <1 | 0 | ON | OFF>

Raises:

ValueError – Error message

Return type:

None

set_DataFormat(state='ASCii')[source]

Sets the data format. Only ASCii works!!!

Parameters:

state (str) – Set Data Format = [‘ASCii’,’INTeger’,’REAL’]

Raises:

ValueError – Error message

Return type:

None

set_DataPointCount(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) – Default Value: 501 Range: 10 to 10001

Raises:

ValueError – Error message

Return type:

None

set_DetectorType(state='POSitive', traceNumber=1)[source]

Sets the detector type.

Parameters:
  • state (str) – state = [‘POSitive’, ‘RMS’, ‘NEGative’]

  • traceNumber (int) –

    Trace Number:

    Can be set to [1,2,3,4,5,6]

Raises:

ValueError – Error message

Return type:

None

set_FreqSpan(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 (float) – Sets the frequency span.

  • unit (str) – Unit value. Can be [‘HZ’,’KHZ’,’MHZ’,’GHZ’]

Raises:

ValueError – Error message

Return type:

None

set_IFGainState(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) – state = [‘ON’,’OFF’,1,0]

Raises:

ValueError – Error message

Return type:

None

set_MarkerExcursion(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) – Sets the excursion for a marker in dB. Range 0dB to 200 dB.

Return type:

None

set_MarkerExcursionState(state)[source]

Turn on/off marker excursion state.

Parameters:

state (str/int) – Can be state = [‘ON’,’OFF’,1,0]

Raises:

ValueError – Error message

Return type:

None

set_MarkerPreset()[source]

Presets all markers to their preset values.

Return type:

None

set_MaxPeak(markerNum=1)[source]

Moves the marker to the highest peak.

Parameters:

markerNum (int) – Marker number. Can be 1 to 12.

Raises:

ValueError

Return type:

None

set_NextPeak(markerNum=1)[source]

Moves the marker to the next highest peak.

Parameters:

markerNum (int) – Marker number. Can be 1 to 12.

Raises:

ValueError

Return type:

None

set_RefLevel(level)[source]

Set the reference level in dBm.

Parameters:

level (float) – Reference level in dBm.

Raises:

ValueError – Error message

Return type:

None

set_ResBwidth(value, 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:
  • value (int/float) – Sets the resolution bandwidth.

  • unit (str) – Parameters: <numeric_value> {HZ | KHZ | MHZ | GHZ} Default Unit: Hz

Raises:

ValueError – Error message

Return type:

None

set_ResBwidthAuto(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. Setting the value to OFF or 0 will result in the resolution bandwidth being decoupled from the span. That is, changing the span will not change the resolution bandwidth. When this command is issued, the resolution bandwidth setting itself will not change.

Parameters:

state (int/str) – Sets the state of the coupling of the resolution bandwidth to the frequency span. Parameters:<1 | 0 | ON | OFF> Default Value: ON

Raises:

ValueError – Error message

Return type:

None

set_TraceSelected(traceNumber=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:

traceNumber (int) –

Trace number:

Can be set to [1,2,3,4,5,6]

Raises:

ValueError – Error message

Return type:

None

set_TraceState(state='ON', traceNumber=1)[source]

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

Parameters:
  • state (str) – [‘ON’,’OFF’,0,1]

  • traceNumber (int) –

    Trace Number:

    Can be set to [1,2,3,4,5,6]

Raises:

ValueError – Error message

Return type:

None

set_TraceType(state='NORM', traceNumber=1)[source]

Sets the trace type.

Parameters:
  • state (str) –

    Sets Trace Type:

    Normal - NORM Hold the Minimum - MIN Hold the Maximum - MAX Average - AVER Rolling Max Hold - RMAX Rolling Min Hold - RMIN Rolling Average - RAV

  • number (int) –

    Trace number:

    Can be set to [1,2,3,4,5,6]

  • traceNumber (int)

Raises:

ValueError – Error message

Return type:

None

set_freq_Start(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) – Parameters: <numeric_value> {HZ | KHZ | MHZ | GHZ}

Raises:

ValueError – Error message

Return type:

None

set_freq_Stop(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) – Parameters: <numeric_value> {HZ | KHZ | MHZ | GHZ}

Raises:

ValueError – Error message

Return type:

None

write(message)[source]