NanoVNASaver package

Subpackages

Submodules

NanoVNASaver.About module

NanoVNASaver.AnalyticTools module

NanoVNASaver.AnalyticTools.calculate_rolloff(s21: list[Datapoint], idx_1: int, idx_2: int) tuple[float, float][source]
NanoVNASaver.AnalyticTools.center_from_idx(gains: list[float], idx: int, delta: float = 3.0) int[source]

find maximum from index postion of gains in a attn dB gain span

Parameters:
  • gains (list[float]) – gain values

  • idx (int) – start position to search from

  • delta (float, optional) – max gain delta from start. Defaults to 3.0.

Returns:

position of highest gain from start in range (-1 if no data)

Return type:

int

NanoVNASaver.AnalyticTools.cut_off_left(gains: list[float], idx: int, peak_gain: float, attn: float = 3.0) int[source]

find first position in list where gain in attn lower then peak left from index

Parameters:
  • gains (list[float]) – gain values

  • idx (int) – start position to search from

  • peak_gain (float) – reference gain value

  • attn (float, optional) – attenuation to search position for. Defaults to 3.0.

Returns:

position of attenuation point. (-1 if no data)

Return type:

int

NanoVNASaver.AnalyticTools.cut_off_right(gains: list[float], idx: int, peak_gain: float, attn: float = 3.0) int[source]

find first position in list where gain in attn lower then peak right from index

Parameters:
  • gains (list[float]) – gain values

  • idx (int) – start position to search from

  • peak_gain (float) – reference gain value

  • attn (float, optional) – attenuation to search position for. Defaults to 3.0.

Returns:

position of attenuation point. (-1 if no data)

Return type:

int

NanoVNASaver.AnalyticTools.dip_cut_offs(gains: list[float], peak_gain: float, attn: float = 3.0) tuple[int, int][source]
NanoVNASaver.AnalyticTools.maxima(data: list[float], threshold: float = 0.0) list[int][source]
Parameters:

data (list[float]) – data list to execute

Returns:

indices of maxima

Return type:

list[int]

NanoVNASaver.AnalyticTools.minima(data: list[float], threshold: float = 0.0) list[int][source]
Parameters:

data (list[float]) – data list to execute

Returns:

indices of minima

Return type:

list[int]

NanoVNASaver.AnalyticTools.take_from_idx(data: list[float], idx: int, predicate: Callable) list[int][source]

take_from_center

Parameters:
  • data (list[float]) – data list to execute

  • idx (int) – index of a start position

  • predicate (Callable) – predicate on which elements to take from center. (e.g. lambda i: i[1] < threshold)

Returns:

indices of element matching predicate left

and right from index

Return type:

list[int]

NanoVNASaver.AnalyticTools.zero_crossings(data: list[float]) list[int][source]

find zero crossings

Parameters:

data (list[float]) – data list execute

Returns:

sorted indices of zero crossing points

Return type:

list[int]

NanoVNASaver.Calibration module

class NanoVNASaver.Calibration.CalData(short: complex = 0j, open: complex = 0j, load: complex = 0j, through: complex = 0j, thrurefl: complex = 0j, isolation: complex = 0j, freq: int = 0, e00: float = 0.0, e11: float = 0.0, delta_e: float = 0.0, e10e01: float = 0.0, e30: float = 0.0, e22: float = 0.0, e10e32: float = 0.0)[source]

Bases: object

delta_e: float = 0.0
e00: float = 0.0
e10e01: float = 0.0
e10e32: float = 0.0
e11: float = 0.0
e22: float = 0.0
e30: float = 0.0
freq: int = 0
isolation: complex = 0j
load: complex = 0j
open: complex = 0j
short: complex = 0j
through: complex = 0j
thrurefl: complex = 0j
class NanoVNASaver.Calibration.CalDataSet[source]

Bases: UserDict

complete1port() bool[source]
complete2port() bool[source]
frequencies() list[int][source]
from_str(text: str) CalDataSet[source]
get(k[, d]) D[k] if k in D, else d.  d defaults to None.[source]
insert(name: str, dp: Datapoint)[source]
items() a set-like object providing a view on D's items[source]
size_of(name: str) int[source]
values() an object providing a view on D's values[source]
class NanoVNASaver.Calibration.CalElement(short_state: str = '', short_touchstone: NanoVNASaver.Touchstone.Touchstone = None, short_is_ideal: bool = True, short_l0: float = 5.7e-12, short_l1: float = -8.96e-20, short_l2: float = -1.1e-29, short_l3: float = -4.12e-37, short_length: float = -34.2, open_state: str = '', open_touchstone: NanoVNASaver.Touchstone.Touchstone = None, open_is_ideal: bool = True, open_c0: float = 2.1e-14, open_c1: float = 5.67e-23, open_c2: float = -2.39e-31, open_c3: float = 2e-40, open_length: float = 0.0, load_state: str = '', load_touchstone: NanoVNASaver.Touchstone.Touchstone = None, load_is_ideal: bool = True, load_r: float = 50.0, load_l: float = 0.0, load_c: float = 0.0, load_length: float = 0.0, through_is_ideal: bool = True, through_length: float = 0.0)[source]

Bases: object

load_c: float = 0.0
load_is_ideal: bool = True
load_l: float = 0.0
load_length: float = 0.0
load_r: float = 50.0
load_state: str = ''
load_touchstone: Touchstone = None
open_c0: float = 2.1e-14
open_c1: float = 5.67e-23
open_c2: float = -2.39e-31
open_c3: float = 2e-40
open_is_ideal: bool = True
open_length: float = 0.0
open_state: str = ''
open_touchstone: Touchstone = None
short_is_ideal: bool = True
short_l0: float = 5.7e-12
short_l1: float = -8.96e-20
short_l2: float = -1.1e-29
short_l3: float = -4.12e-37
short_length: float = -34.2
short_state: str = ''
short_touchstone: Touchstone = None
through_is_ideal: bool = True
through_length: float = 0.0
class NanoVNASaver.Calibration.Calibration[source]

Bases: object

calc_corrections()[source]
correct11(dp: Datapoint)[source]
correct21(dp: Datapoint, dp11: Datapoint)[source]
data_size(name) int[source]
gamma_load(freq: int) complex[source]
gamma_open(freq: int) complex[source]
gamma_short(freq: int) complex[source]
gamma_through(freq: int) complex[source]
gen_interpolation()[source]
insert(name: str, data: list[Datapoint])[source]
isValid1Port() bool[source]
isValid2Port() bool[source]
load(filename)[source]
save(filename: str)[source]
size() int[source]
NanoVNASaver.Calibration.correct_delay(d: Datapoint, delay: float, reflect: bool = False)[source]

NanoVNASaver.Defaults module

class NanoVNASaver.Defaults.AppSettings[source]

Bases: QSettings

restore_dataclass(name: str, data: object) object[source]
store_dataclass(name: str, data: object) None[source]
class NanoVNASaver.Defaults.CFG(gui: object = <factory>, charts_selected: object = <factory>, chart: object = <factory>, chart_colors: object = <factory>, markers: object = <factory>)[source]

Bases: object

chart: object
chart_colors: object
charts_selected: object
gui: object
markers: object
class NanoVNASaver.Defaults.Chart(point_size: int = 2, show_lines: bool = False, line_thickness: int = 1, marker_count: int = 3, marker_label: bool = False, marker_filled: bool = False, marker_at_tip: bool = False, marker_size: int = 8, returnloss_is_positive: bool = False, show_bands: bool = False, vswr_lines: list = <factory>)[source]

Bases: object

line_thickness: int = 1
marker_at_tip: bool = False
marker_count: int = 3
marker_filled: bool = False
marker_label: bool = False
marker_size: int = 8
point_size: int = 2
returnloss_is_positive: bool = False
show_bands: bool = False
show_lines: bool = False
vswr_lines: list
class NanoVNASaver.Defaults.ChartColors(background: PyQt6.QtGui.QColor = <factory>, foreground: PyQt6.QtGui.QColor = <factory>, reference: PyQt6.QtGui.QColor = <factory>, reference_secondary: PyQt6.QtGui.QColor = <factory>, sweep: PyQt6.QtGui.QColor = <factory>, sweep_secondary: PyQt6.QtGui.QColor = <factory>, swr: PyQt6.QtGui.QColor = <factory>, text: PyQt6.QtGui.QColor = <factory>, bands: PyQt6.QtGui.QColor = <factory>)[source]

Bases: object

background: QColor
bands: QColor
foreground: QColor
reference: QColor
reference_secondary: QColor
sweep: QColor
sweep_secondary: QColor
swr: QColor
text: QColor
class NanoVNASaver.Defaults.ChartsSelected(chart_00: str = 'S11 Smith Chart', chart_01: str = 'S11 Return Loss', chart_02: str = 'None', chart_10: str = 'S21 Polar Plot', chart_11: str = 'S21 Gain', chart_12: str = 'None')[source]

Bases: object

chart_00: str = 'S11 Smith Chart'
chart_01: str = 'S11 Return Loss'
chart_02: str = 'None'
chart_10: str = 'S21 Polar Plot'
chart_11: str = 'S21 Gain'
chart_12: str = 'None'
class NanoVNASaver.Defaults.GUI(window_height: int = 950, window_width: int = 1433, font_size: int = 8, custom_colors: bool = False, dark_mode: bool = False, splitter_sizes: PyQt6.QtCore.QByteArray = <factory>, markers_hidden: bool = False)[source]

Bases: object

custom_colors: bool = False
dark_mode: bool = False
font_size: int = 8
markers_hidden: bool = False
splitter_sizes: QByteArray
window_height: int = 950
window_width: int = 1433
class NanoVNASaver.Defaults.Markers(active_labels: list = <factory>, colored_names: bool = True, color_0: PyQt6.QtGui.QColor = <factory>, color_1: PyQt6.QtGui.QColor = <factory>, color_2: PyQt6.QtGui.QColor = <factory>, color_3: PyQt6.QtGui.QColor = <factory>, color_4: PyQt6.QtGui.QColor = <factory>, color_5: PyQt6.QtGui.QColor = <factory>, color_6: PyQt6.QtGui.QColor = <factory>, color_7: PyQt6.QtGui.QColor = <factory>)[source]

Bases: object

active_labels: list
color_0: QColor
color_1: QColor
color_2: QColor
color_3: QColor
color_4: QColor
color_5: QColor
color_6: QColor
color_7: QColor
colored_names: bool = True
NanoVNASaver.Defaults.from_type(data) str[source]
NanoVNASaver.Defaults.restore(settings: AppSettings) CFG[source]
NanoVNASaver.Defaults.store(settings: AppSettings, data: CFG = None) None[source]
NanoVNASaver.Defaults.to_type(data: object, data_type: type) object[source]

NanoVNASaver.Formatting module

NanoVNASaver.Formatting.format_capacitance(val: float, allow_negative: bool = True) str[source]
NanoVNASaver.Formatting.format_complex_adm(z: complex, allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_complex_imp(z: complex, allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_frequency(freq: Number) str[source]
NanoVNASaver.Formatting.format_frequency_chart(freq: Number) str[source]
NanoVNASaver.Formatting.format_frequency_chart_2(freq: Number) str[source]
NanoVNASaver.Formatting.format_frequency_inputs(freq: Number | str) str[source]
NanoVNASaver.Formatting.format_frequency_short(freq: Number) str[source]
NanoVNASaver.Formatting.format_frequency_space(freq: float, fmt=(6, False, ' ', True, -10, 10, False, False, -inf, inf, '', '', False, False, -inf, inf)) str[source]
NanoVNASaver.Formatting.format_frequency_sweep(freq: Number) str[source]
NanoVNASaver.Formatting.format_gain(val: float, invert: bool = False) str[source]
NanoVNASaver.Formatting.format_group_delay(val: float) str[source]
NanoVNASaver.Formatting.format_inductance(val: float, allow_negative: bool = True) str[source]
NanoVNASaver.Formatting.format_magnitude(val: float) str[source]
NanoVNASaver.Formatting.format_phase(val: float) str[source]
NanoVNASaver.Formatting.format_q_factor(val: float, allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_resistance(val: float, allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_vswr(val: float) str[source]
NanoVNASaver.Formatting.format_wavelength(length: Number) str[source]
NanoVNASaver.Formatting.format_y_axis(val: float, unit: str = '') str[source]
NanoVNASaver.Formatting.parse_frequency(freq: str) int[source]
NanoVNASaver.Formatting.parse_value(val: str, unit: str = '', fmt: Format = (6, False, '', True, -10, 10, False, False, -inf, inf, '', '', True, True, -inf, inf)) float[source]

NanoVNASaver.Inputs module

class NanoVNASaver.Inputs.FrequencyInputWidget(text='')[source]

Bases: QLineEdit

setText(self, a0: str | None)[source]
class NanoVNASaver.Inputs.MarkerFrequencyInputWidget(text='')[source]

Bases: FrequencyInputWidget

keyPressEvent(self, a0: QKeyEvent | None)[source]

NanoVNASaver.NanoVNASaver module

class NanoVNASaver.NanoVNASaver.Communicate[source]

Bases: QObject

data_available

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

class NanoVNASaver.NanoVNASaver.NanoVNASaver[source]

Bases: QWidget

auto_connect()[source]
changeFont(font: QFont) None[source]
closeEvent(self, a0: QCloseEvent | None)[source]
copyChart(chart: Chart)[source]
dataUpdated()[source]
display_window(name)[source]
markerUpdated(marker: Marker)[source]
popoutChart(chart: Chart)[source]
resetReference()[source]
saveData(data, data21, source=None)[source]
scale_factor = 1.0
setReference(s11=None, s21=None, source=None)[source]
showError(text)[source]
showSweepError()[source]
sizeHint(self) QSize[source]
sweepFinished()[source]
sweep_start()[source]
sweep_stop()[source]
updateTitle()[source]
update_sweep_title()[source]
version = '0.6.8'

NanoVNASaver.RFTools module

class NanoVNASaver.RFTools.Datapoint(freq, re, im)[source]

Bases: NamedTuple

capacitiveEquivalent(ref_impedance: float = 50) float[source]
freq: int

Alias for field number 0

property gain: float
im: float

Alias for field number 2

impedance(ref_impedance: float = 50) complex[source]
inductiveEquivalent(ref_impedance: float = 50) float[source]
property phase: float

return the datapoint’s phase value

qFactor(ref_impedance: float = 50) float[source]
re: float

Alias for field number 1

seriesImpedance(ref_impedance: float = 50) complex[source]
shuntImpedance(ref_impedance: float = 50) complex[source]
property vswr: float
property wavelength: float
property z: complex

return the s value complex number

NanoVNASaver.RFTools.corr_att_data(data: list[Datapoint], att: float) list[Datapoint][source]

Correct the ratio for a given attenuation on s21 input

NanoVNASaver.RFTools.gamma_to_impedance(gamma: complex, ref_impedance: float = 50) complex[source]

Calculate impedance from gamma

NanoVNASaver.RFTools.groupDelay(data: list[Datapoint], index: int) float[source]
NanoVNASaver.RFTools.impedance_to_capacitance(z: complex, freq: float) float[source]

Calculate capacitive equivalent for reactance

NanoVNASaver.RFTools.impedance_to_inductance(z: complex, freq: float) float[source]

Calculate inductive equivalent for reactance

NanoVNASaver.RFTools.impedance_to_norm(z: complex, ref_impedance: float = 50) complex[source]

Calculate normalized z from impedance

NanoVNASaver.RFTools.norm_to_impedance(z: complex, ref_impedance: float = 50) complex[source]

Calculate impedance from normalized z

NanoVNASaver.RFTools.parallel_to_serial(z: complex) complex[source]

Convert parallel impedance to serial impedance equivalent

NanoVNASaver.RFTools.reflection_coefficient(z: complex, ref_impedance: float = 50) complex[source]

Calculate reflection coefficient for z

NanoVNASaver.RFTools.serial_to_parallel(z: complex) complex[source]

Convert serial impedance to parallel impedance equivalent

NanoVNASaver.SITools module

class NanoVNASaver.SITools.Format(max_nr_digits, fix_decimals, space_str, assume_infinity, min_offset, max_offset, allow_strip, allways_signed, printable_min, printable_max, unprintable_under, unprintable_over, parse_sloppy_unit, parse_sloppy_kilo, parse_clamp_min, parse_clamp_max)[source]

Bases: NamedTuple

allow_strip: bool

Alias for field number 6

allways_signed: bool

Alias for field number 7

assume_infinity: bool

Alias for field number 3

fix_decimals: bool

Alias for field number 1

max_nr_digits: int

Alias for field number 0

max_offset: int

Alias for field number 5

min_offset: int

Alias for field number 4

parse_clamp_max: float

Alias for field number 15

parse_clamp_min: float

Alias for field number 14

parse_sloppy_kilo: bool

Alias for field number 13

parse_sloppy_unit: bool

Alias for field number 12

printable_max: float

Alias for field number 9

printable_min: float

Alias for field number 8

space_str: str

Alias for field number 2

unprintable_over: str

Alias for field number 11

unprintable_under: str

Alias for field number 10

class NanoVNASaver.SITools.Value(value: Real = Decimal('0'), unit: str = '', fmt=(6, False, '', True, -10, 10, False, False, -inf, inf, '', '', False, False, -inf, inf))[source]

Bases: object

CTX = Context(prec=60, rounding=ROUND_HALF_EVEN, Emin=-33, Emax=33, capitals=1, clamp=0, flags=[], traps=[InvalidOperation, DivisionByZero, Overflow])
parse(value: str) Value[source]
property unit: str
property value
NanoVNASaver.SITools.clamp_value(value: Real, rmin: Real, rmax: Real) Real[source]
NanoVNASaver.SITools.log_floor_125(x: float) float[source]
NanoVNASaver.SITools.round_ceil(value: Real, digits: int = 0) Real[source]
NanoVNASaver.SITools.round_floor(value: Real, digits: int = 0) Real[source]

NanoVNASaver.SweepWorker module

class NanoVNASaver.SweepWorker.SweepState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

RUNNING = 1
STOPPED = 0
class NanoVNASaver.SweepWorker.SweepWorker(app: NanoVNA)[source]

Bases: QRunnable

applyCalibration(raw_data11: list[Datapoint], raw_data21: list[Datapoint]) tuple[list[Datapoint], list[Datapoint]][source]
gui_error(message: str) None[source]
init_data() None[source]
read_averaged_segment(start: int, stop: int, averages: int = 1) tuple[list[int], list[complex], list[complex]][source]
read_data(data) list[complex][source]
read_segment(start: int, stop: int) tuple[list[int], list[complex], list[complex]][source]
run(self)[source]
update_data(frequencies: list[int], values11: list[complex], values21: list[complex], index: int) None[source]
class NanoVNASaver.SweepWorker.WorkerSignals[source]

Bases: QObject

finished

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

sweep_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

updated

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

NanoVNASaver.SweepWorker.truncate(values: list[list[complex]], count: int) list[list[complex]][source]

truncate drops extrema from data list if averaging is active

NanoVNASaver.Touchstone module

class NanoVNASaver.Touchstone.Options(unit: str = 'GHZ', parameter: str = 'S', t_format: str = 'ma', resistance: int = 50)[source]

Bases: object

UNIT_TO_FACTOR = {'ghz': 1000000000, 'hz': 1, 'khz': 1000, 'mhz': 1000000}
VALID_FORMATS = ('ma', 'db', 'ri')
VALID_PARAMETERS = 'syzgh'
VALID_UNITS = dict_keys(['ghz', 'mhz', 'khz', 'hz'])
property factor: int
parse(line: str)[source]
class NanoVNASaver.Touchstone.Touchstone(filename: str = '')[source]

Bases: object

FIELD_ORDER = ('11', '21', '12', '22')
gen_interpolation()[source]
gen_interpolation_s11()[source]
load()[source]
loads(s: str)[source]

Parse touchstone 1.1 string input appends to existing sdata if Touchstone object exists

max_freq() int[source]
min_freq() int[source]
property r: int
s(name: str) list[Datapoint][source]
property s11: list[Datapoint]
property s12: list[Datapoint]
property s21: list[Datapoint]
property s22: list[Datapoint]
s_freq(name: str, freq: int) Datapoint[source]
save(nr_params: int = 1)[source]

Save touchstone data to file.

Parameters:

nr_params – Number of s-parameters. 2 for s1p, 4 for s2p

saves(nr_params: int = 1) str[source]

Returns touchstone data as string.

Parameters:

nr_params – Number of s-parameters. 1 for s1p, 4 for s2p

swap()[source]

NanoVNASaver.Version module

NanoVNASaver.Version.Version(vstring: str = '0.0.0') _Version[source]

Module contents