dso_math module

Perform math operations on the DSO.

Basic signal processing functions, including dual-waveform math, FFT, and advanced math.

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.')

myDso.math.set_math_on() # Trun on MATH

# Run dual-waveform math as CH1*CH1
myDso.math.run_dual_wfrm_math('CH1*CH1')
myDso.math.set_dual_wfrm_math_scale_and_pos(0.5, 1.0)

# Run FFT with default hann window and decibel output
myDso.math.run_fft('CH1')

# FFT using hamming window
myDso.math.run_fft('CH1', window = kHammingWin)

# Run advanced math
myDso.math.run_advanced_math('CH1+CH1')

myDso.math.set_math_off() # Trun off MATH

myDso.close() # Clean-up
class dso_math.Math(parent=None)

Bases: object

This module controls the math function on the DSO.

is_math_on() bool

Check status of MATH display

Returns:

True if MATH display is ‘ON’, False otherwise.

run_advanced_math(equation: str) None

Run advanced math

Parameters:

equation (str) – equation for the advanced math.

run_dual_wfrm_math(equation: str) None

Run dual waveform math

Parameters:

equation (str) – equation for the dual waveform math. e.g. ‘CH1+CH1’

Raises:

MathError – error found in the input equation

run_fft(source: str, window: int = kFFT_WINDOWS_DEF, unit: int = kFFT_UNITS_DEF)

Run FFT processing

Parameters:
  • source (str) – analog or reference soruce. e.g. ‘CH1’ or ‘REF1’

  • window (int, optional) – window function used by FFT. kRectWin for Rectangular kHammingWin for Hamming kHanningWin for Hann(default) kBlackmanWin for Blackman

  • unit (int, optional) – unit of the FFT magnitude kUnit_db for dB(default) kUnit_Lin for Linear RMS

set_advanced_math_scale_and_pos(scale: float, pos: float) None

Set advanced math scale and position ofsets

Parameters:
  • scale (float) – value per divison

  • pos (float) – value in unit of divison

set_dual_wfrm_math_scale_and_pos(scale: float, pos: float) None

Set dual waveform math scale and position ofsets

Parameters:
  • scale (float) – value per divison

  • pos (float) – value in unit of divison

set_fft_scale_and_pos(scale: float, pos: float) None

Set FFT scale and position ofsets

Parameters:
  • scale (float) – value per divison

  • pos (float) – value in unit of divison

set_math_off() None
set_math_on() None
exception dso_math.MathError

Bases: Exception

dso_math.dual_wfrm_math_parser(equation: str)

Parsing an input equation for the dual waveform math

Parameters:

equation (str) – such as ‘CH1+CH2’

Returns:

see examples below.

Return type:

match

Examples :

>>> match = dso_math.dual_wfrm_math_parser('CH1+CH2')
>>> print([ match.group(i+1) for i in range(3) ])
    ['CH1', '+', 'CH2']
dso_math.is_fft_source_valid(source: str) bool

A valid source for FFT processing is CH<x> or REF<x>

Parameters:

source (str) – input for FFT analysis

Returns:

True if the input is supported by FFT. False otherwise.

dso_math.is_source_valid(source: str, pattern: str = '(CH\\d|REF\\d)') bool

Is the input source matches a given pattern ?

Parameters:
  • source (str) – CH<x> or REF<x>, where <x> ranges from 1 to 4.

  • pattern (str, optional) – using regular expression

Returns:

True if source matches the pattern, False otherwise.

Typical usage example:

ch1_vld = is_source_valid('CH1')
ref1_vld = is_source_valid('REF1')