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: complex = 0j, e11: complex = 0j, delta_e: complex = 0j, e10e01: complex = 0j, e30: complex = 0j, e22: complex = 0j, e10e32: complex = 0j)[source]

Bases: object

delta_e: complex = 0j
e00: complex = 0j
e10e01: complex = 0j
e10e32: complex = 0j
e11: complex = 0j
e22: complex = 0j
e30: complex = 0j
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]
freq_max() int[source]
freq_min() int[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 = <factory>, 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 = <factory>, 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 = <factory>, 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
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
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
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.AppConfig(gui: NanoVNASaver.Defaults.GuiConfig = <factory>, charts_selected: NanoVNASaver.Defaults.ChartsSelectedConfig = <factory>, chart: NanoVNASaver.Defaults.ChartConfig = <factory>, chart_colors: NanoVNASaver.Defaults.ChartColorsConfig = <factory>, markers: NanoVNASaver.Defaults.MarkersConfig = <factory>, sweep_settings: NanoVNASaver.Defaults.SweepConfig = <factory>)[source]

Bases: object

chart: ChartConfig
chart_colors: ChartColorsConfig
charts_selected: ChartsSelectedConfig
gui: GuiConfig
markers: MarkersConfig
sweep_settings: SweepConfig
class NanoVNASaver.Defaults.AppSettings(organization: str = 'NanoVNASaver', application: str = 'NanoVNASaver')[source]

Bases: QSettings

get_app_config() AppConfig[source]
restore_config() AppConfig[source]
staticMetaObject = PySide6.QtCore.QMetaObject("AppSettings" inherits "QSettings": )
store_config() None[source]
class NanoVNASaver.Defaults.ChartColorsConfig(background: PySide6.QtGui.QColor = <factory>, foreground: PySide6.QtGui.QColor = <factory>, reference: PySide6.QtGui.QColor = <factory>, reference_secondary: PySide6.QtGui.QColor = <factory>, sweep: PySide6.QtGui.QColor = <factory>, sweep_secondary: PySide6.QtGui.QColor = <factory>, swr: PySide6.QtGui.QColor = <factory>, text: PySide6.QtGui.QColor = <factory>, bands: PySide6.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.ChartConfig(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.ChartsSelectedConfig(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.GuiConfig(window_height: int = 950, window_width: int = 1433, font_size: int = 8, custom_colors: bool = False, dark_mode: bool = False, splitter_sizes: PySide6.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.MarkersConfig(active_labels: list = <factory>, colored_names: bool = True, color_0: PySide6.QtGui.QColor = <factory>, color_1: PySide6.QtGui.QColor = <factory>, color_2: PySide6.QtGui.QColor = <factory>, color_3: PySide6.QtGui.QColor = <factory>, color_4: PySide6.QtGui.QColor = <factory>, color_5: PySide6.QtGui.QColor = <factory>, color_6: PySide6.QtGui.QColor = <factory>, color_7: PySide6.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
class NanoVNASaver.Defaults.SweepConfig(start: str = '', end: str = '', center: str = '', span: str = '', segments: str = '1')[source]

Bases: object

center: str = ''
end: str = ''
segments: str = '1'
span: str = ''
start: str = ''
NanoVNASaver.Defaults.get_app_config() AppConfig[source]

NanoVNASaver.Formatting module

NanoVNASaver.Formatting.format_capacitance(val: Decimal | float | str | tuple[int, Sequence[int], int], 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: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_frequency_chart(freq: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_frequency_chart_2(freq: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_frequency_inputs(freq: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_frequency_short(freq: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_frequency_space(freq: Decimal | float | str | tuple[int, Sequence[int], int], fmt=(6, False, ' ', True, -10, 10, False, False, -inf, inf, '', '', False, False, -inf, inf)) str[source]
NanoVNASaver.Formatting.format_frequency_sweep(freq: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_gain(val: Decimal | float | str | tuple[int, Sequence[int], int], invert: bool = False) str[source]
NanoVNASaver.Formatting.format_group_delay(val: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_inductance(val: Decimal | float | str | tuple[int, Sequence[int], int], allow_negative: bool = True) str[source]
NanoVNASaver.Formatting.format_magnitude(val: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_phase(val: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_q_factor(val: Decimal | float | str | tuple[int, Sequence[int], int], allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_resistance(val: Decimal | float | str | tuple[int, Sequence[int], int], allow_negative: bool = False) str[source]
NanoVNASaver.Formatting.format_vswr(val: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_wavelength(length: Decimal | float | str | tuple[int, Sequence[int], int]) str[source]
NanoVNASaver.Formatting.format_y_axis(val: Decimal | float | str | tuple[int, Sequence[int], int], 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.NanoVNASaver module

class NanoVNASaver.NanoVNASaver.Communicate[source]

Bases: QObject

data_available
staticMetaObject = PySide6.QtCore.QMetaObject("Communicate" inherits "QObject": Methods:   #4 type=Signal, signature=data_available() )
class NanoVNASaver.NanoVNASaver.NanoVNASaver[source]

Bases: QWidget

auto_connect()[source]
changeFont(font: QFont) None[source]
closeEvent(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() QSize[source]
staticMetaObject = PySide6.QtCore.QMetaObject("NanoVNASaver" inherits "QWidget": )
sweepFinished()[source]
sweep_start()[source]
updateTitle()[source]
update_sweep_title()[source]
version = '0.7.2'

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: Decimal | float | str | tuple[int, Sequence[int], int] = 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: V, rmin: V, rmax: V) V[source]
NanoVNASaver.SITools.log_floor_125(x: SupportsFloat) float[source]
NanoVNASaver.SITools.round_ceil(value: SupportsFloat, digits: int = 0) float[source]
NanoVNASaver.SITools.round_floor(value: SupportsFloat, digits: int = 0) float[source]

NanoVNASaver.SweepWorker module

class NanoVNASaver.SweepWorker.SweepWorker(app: vna_app)[source]

Bases: QThread

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]
quit() 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() None[source]
staticMetaObject = PySide6.QtCore.QMetaObject("SweepWorker" inherits "QThread": Methods:   #12 type=Slot, signature=run() )
update_data(frequencies: list[int], values11: list[complex], values21: list[complex], index: int) None[source]
class NanoVNASaver.SweepWorker.WorkerSignals[source]

Bases: QObject

finished
staticMetaObject = PySide6.QtCore.QMetaObject("WorkerSignals" inherits "QObject": Methods:   #4 type=Signal, signature=updated()   #5 type=Signal, signature=finished()   #6 type=Signal, signature=sweep_error() )
sweep_error
updated
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: ClassVar[dict[str, int]] = {'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]

Module contents

class NanoVNASaver.NanoVNASaver[source]

Bases: QWidget

auto_connect()[source]
bands: BandsModel
calibration: Calibration
changeFont(font: QFont) None[source]
closeEvent(a0: QCloseEvent) None[source]
copyChart(chart: Chart)[source]
data: Touchstone
dataUpdated()[source]
display_window(name)[source]
markerUpdated(marker: Marker)[source]
markers: list[Marker]
popoutChart(chart: Chart)[source]
ref_data: Touchstone
resetReference()[source]
saveData(data, data21, source=None)[source]
scale_factor = 1.0
setReference(s11=None, s21=None, source=None)[source]
settings: AppSettings
showError(text)[source]
showSweepError()[source]
sizeHint() QSize[source]
staticMetaObject = PySide6.QtCore.QMetaObject("NanoVNASaver" inherits "QWidget": )
sweepFinished()[source]
sweep_start()[source]
tdr_chart: TDRChart
updateTitle()[source]
update_sweep_title()[source]
version = '0.7.2'
vna: VNA
windows: dict[str, QDialog]