dso_spectrum module

Spectrum mode control on the DSO.

Basic control functions for the spectrum mode.

Typical usage example:

import dso2ke as gds

# Create a Dso instance, myDso, and get connected to it.
myDso = gds.Dso()
ret = myDso.connect(host='localhost', port=3000)
if ret != 0:
    raise ValueError('Socket connection failed.')

# Activate spectrum mode
myDso.sa.set_spectrum_mode('ON')

# Configure SA parameters: center and span frequency
myDso.sa.set_freq(10e6)
myDso.sa.set_span(10e6)

# Exit the spectrum mode
myDso.sa.set_spectrum_mode('OFF')

myDso.close() # Clean-up
class dso_spectrum.Spectrum(parent=None, max_instances: int = 1)

Bases: object

This module controls the spectrum analyzer(SA) on the DSO.

get_freq(_id: int = SA) float

Get center frequency of a SA instance

get_rbw(_id: int = SA) float

Get RBW of a SA instance

get_source(_id: int = SA) int

Get input source of a SA instance

Parameters:

_id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

1:CH1, 2:CH2, and etc.

Return type:

ch (int)

get_span(_id: int = SA) float

Get span frequency of a SA instance

get_start(_id: int = SA) float

Get start frequency of a SA instance

get_state(_id: int = SA) bool

Get ON/OFF state of a SA instance

Parameters:

_id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

True for the ‘ON’ state, False otherwise.

Return type:

bool

get_stop(_id: int = SA) float

Get stop frequency of a SA instance

get_trace(trace_type: str, _id: int = SA) list

Get trace data of a SA instance

Parameters:
  • trace_type (str) – NORMAL, AVERAGE, MAXHOLD, MINHOLD

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

spectrum data represented in 8-bit wordlength.

Return type:

trace_data (list)

get_trace_data_type(_id: int = SA)

Get trace data type after set_trace_data_type().

Parameters:

_id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

NORMAL, AVERAGE, MAXHOLD, MINHOLD

Return type:

ret (str)

is_RBW_Manual(_id: int = SA) bool

Check for manual-RBW mode

Parameters:

_id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

True if manual-RBW mode, False otherwise.

is_spectrum_mode() bool

Get state of the spectrum mode

Returns:

True if present state is the spectrum mode. False otherwise.

Return type:

bool

is_spectrum_trace(trace_type: str, _id: int = SA) bool

Get display state of a given spectrum trace

Parameters:
  • trace_type (str) – NORMAL, AVERAGE, MAXHOLD, or MINHOLD

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

True if the trace is ‘ON’. False otherwise.

set_RBW_Manual(rbw: float, _id: int = SA) None

Set manual-RBW value

Parameters:
  • rbw (float) – manual-RBW value to set

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_Span2RBW_Ratio(ratio: str, _id: int = SA) None

Set ratio of span over rbw in auto-RBW mode.

Parameters:
  • ratio (str) – RATIO_1K, RATIO_2K, or RATIO_5K

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_freq(freq: float, _id: int = SA) None

Set center frequency of a SA instance

Parameters:
  • freq (float) – frequency in Hz

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_position(position: float, _id: int = SA) None

Vertical offset for spectrum traces

Parameters:
  • position (float) – set value in unit of Div.

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_scale(scale: float, unit: int = kUnit_db, _id: int = SA) None

Scale of spectrum magnitude

Parameters:
  • scale (float) – value of scale

  • unit (int, optional) – unit of the scale, kUnit_db, kUnit_Lin, or kUnit_dbm

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_source(ch: int, _id: int = SA)

Set input source for a SA instance

Parameters:
  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

  • source (int) – 1:CH1, 2:CH2, and etc.

set_span(freq: float, _id: int = SA) None

Set span frequency of a SA instance

Parameters:
  • freq (float) – frequency in Hz

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_spectrum_mode(state: str) None

Set state of the spectrum mode

Parameters:

state (str) – ON or OFF

set_spectrum_trace(trace_type: str, state: str, _id: int = SA) None

Set traces on and off

Parameters:
  • trace_type (str) – NORMAL, AVERAGE, MAXHOLD, or MINHOLD

  • state (str) – ON or OFF

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_start(freq: float, _id: int = SA) None

Set start frequency of a SA instance

Parameters:
  • freq (float) – frequency in Hz

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_state(state: str, _id: int = SA) None

Set ON/OFF state of a SA instance

Parameters:
  • state (str) – ON or OFF

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_stop(freq: float, _id: int = SA) None

Set stop frequency of a SA instance

Parameters:
  • freq (float) – frequency in Hz

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

set_trace_data_type(trace_type: str, _id: int = SA) bool

Set trace type before retrieving the trace data

Parameters:
  • trace_type (str) – NORMAL, AVERAGE, MAXHOLD, MINHOLD

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs

Returns:

True if set successfully. False otherwise.

set_window(window: int = kHanningWin, _id: int = SA) None

Window function for spectrum analysis

Parameters:
  • window (int, optional) –

    Choose one of the following window functions to trade-off amplitude accurary and side-lobe reduction.

    kRectWin for Rectangular kHammingWin for Hamming kHanningWin for Hann(default) kBlackmanWin for Blackman

  • _id (int) – 0 for single SA(optional) while 1,2, .. and etc for multi-SAs