How can I view uncertainty values in magnitude using Python

120 views
Skip to first unread message

Rob Feldman

unread,
Nov 11, 2020, 6:21:20 PM11/11/20
to VNA Tools
I am trying to create a calibration certificate from the data collected from VNA Tools II.  I have CITI files but the uncertainty is represented as Real and Imaginary.  I would like to convert them to Magnitude (dB) and Phase (degrees) using python.

Thanks in advance for the assistance.

Michael Wollensack METAS

unread,
Nov 16, 2020, 2:52:38 AM11/16/20
to VNA Tools
Hi,

I've you have only CITI files with real and imaginary uncertainties the conversion to mag and phase uncertainties is not ambiguous, because you don't know the correlation between real and imaginary parts.

What is your source file?

If it would be sdatb then you can load it from VNA Tools, MATLAB or Python and you can compute the magnitude and phase uncertainties.

Regards
Michael

Rob Feldman

unread,
Nov 19, 2020, 5:13:14 PM11/19/20
to VNA Tools
I do have a sdatb file as my source.  My main goal is take the sdatb file and display the data (magnitude and phase) so that I can export to a word template. I would prefer to do that in Python if possible.  

Michael Wollensack METAS

unread,
Nov 20, 2020, 9:59:12 AM11/20/20
to VNA Tools
Hi,

do you want to use the VNA Tools built-in IronPython script engine or do you want to use CPython?

Regards
Michael

Michael Wollensack METAS

unread,
Nov 20, 2020, 10:40:38 AM11/20/20
to VNA Tools
Ok, the following script will help you:

import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('Metas.Vna.Tools')
from System import Math
from System.Threading import Thread
from System.Windows.Forms import MessageBox
from Metas.Vna.Tools import Script

s = Script(RootPath)

d = s.LoadSParamData(r'01_Basic_Example_N(f-m)\SOLT_01_out\DUTs\01419_Att20dB(f-m)_52371_01\01419_Att20dB(f-m)_52371_01_01.sdatb')

print(d.NFreq)
print(d.NPorts)

print(d[d.NFreq-1,1,0].Abs().Value) # |s21| of last frequency point
print(d[d.NFreq-1,1,0].Abs().StdUnc * 2) # U(|s21|) of last frequency point

print(d[d.NFreq-1,1,0].Abs().Log10().Value * 20) # |s21| of last frequency point
print(d[d.NFreq-1,1,0].Abs().Log10().StdUnc * 2 * 20) # U(|s21|) of last frequency point


print(d[d.NFreq-1,1,0].Angle().Value * 180 / Math.PI ) # angle(s21) of last frequency point
print(d[d.NFreq-1,1,0].Angle().StdUnc * 2* 180 / Math.PI) # U(angle(s21)) of last frequency point


Rob Feldman

unread,
Nov 20, 2020, 1:40:55 PM11/20/20
to VNA Tools
Thanks, that is exactly what I needed!
Reply all
Reply to author
Forward
0 new messages