Cpython metas_unclib import problem

88 views
Skip to first unread message

sle...@gmail.com

unread,
Jan 17, 2025, 3:38:22 AMJan 17
to VNA Tools
Hi,

I would like to load sdatb file in the normal cpython, first I tried this example from the python console:
https://groups.google.com/g/vnatools/c/vekhXXA1ksQ/m/Xeuo24nXCgAJ
I got the error message at the metas_unclib import.

VNA Tools version: 2.8.3
metas-unclib version: 2.8.3

Thank you.

Best Regards,
Laszló


Microsoft Windows [Version 10.0.19045.5131]
(c) Microsoft Corporation. Minden jog fenntartva.

C:\Users\sleiszl>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> vnatools_path = r'C:\Program Files (x86)\METAS\Metas.Vna.Tools'
>>> data_path = r'C:\Users\Public\Documents\Metas.Vna.Tools\Matlab\Example_01.sdatb'
>>> import os as _os
>>> import clr as _clr
>>> _clr.AddReference(_os.path.join(vnatools_path, "Metas.Vna.Data"))
<System.Reflection.RuntimeAssembly object at 0x00000274F512BA00>
>>> from metas_unclib import *

Nem kezelt kivétel: System.ArgumentException: GenericArguments[0], "Metas.UncLib.LinProp.UncList" (helye: "Metas.UncLib.Core.Unc.GenericUnc`2[T1,T2]") - megsérti a(z) "T1" típusú korlátozást. ---> System.TypeLoadException: GenericArguments[0], "Metas.UncLib.LinProp.UncList" (hely: "Metas.UncLib.Core.Unc.GenericUnc`2[T1,T2]") - megsérti a(z) "T1" típusparaméter korlátozását.
   a következő helyen: System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
   a következő helyen: System.RuntimeTypeHandle.Instantiate(Type[] inst)
   a következő helyen: System.RuntimeType.MakeGenericType(Type[] instantiation)
   --- Vége a belső kivételek veremkivonatának ---
   a következő helyen: System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
   a következő helyen: System.RuntimeType.MakeGenericType(Type[] instantiation)
   a következő helyen: Python.Runtime.ClassBase.type_subscript(IntPtr idx)
   a következő helyen: Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw)
   a következő helyen: Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw)

Michael Wollensack METAS

unread,
Jan 17, 2025, 3:43:40 AMJan 17
to VNA Tools
Hi,

what happens if you just start python and then `from metas_unclib import *`?

Regards
Michael

sle...@gmail.com

unread,
Jan 17, 2025, 3:51:48 AMJan 17
to VNA Tools
Hi,
 
In this case, this command is works fine.

Regards,
László

C:\Users\sleiszl>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from metas_unclib import *

Michael Wollensack METAS

unread,
Jan 17, 2025, 4:52:12 AMJan 17
to VNA Tools
Hi, 

I cannot reproduce the error on my side.

I've performed the following steps:

  1. Start Windows Sandbox
  2. Install Python 3.13.1
  3. Install metas_unclib 2.8.3 from https://pypi.org/project/metas-unclib/
  4. Install METAS VNA Tools V2.8.3
  5. Runt the following code lines

  1. vnatools_path = r'C:\Program Files (x86)\METAS\Metas.Vna.Tools'
    data_path = r'C:\Users\Public\Documents\Metas.Vna.Tools\Matlab\Example_01.sdatb'
    import os as _os
    import clr as _clr
    _clr.AddReference(_os.path.join(vnatools_path, "Metas.Vna.Data"))
  1. from metas_unclib import *
Can you check on your side what is the output of
_clr.AddReference(_os.path.join(vnatools_path, "Metas.Vna.Data")).FullName

Should be
'Metas.Vna.Data, Version=2.8.9053.20259, Culture=neutral, PublicKeyToken=3694dea3dd97db1a'

Regards
Michael

sle...@gmail.com

unread,
Jan 17, 2025, 5:00:32 AMJan 17
to VNA Tools
Hi,

The output:
C:\Users\sleiszl>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> vnatools_path = r'C:\Program Files (x86)\METAS\Metas.Vna.Tools'
>>> data_path = r'C:\Users\Public\Documents\Metas.Vna.Tools\Matlab\Example_01.sdatb'
>>> import os as _os
>>> import clr as _clr
>>> _clr.AddReference(_os.path.join(vnatools_path, "Metas.Vna.Data")).FullName
'Metas.Vna.Data, Version=2.8.9053.20259, Culture=neutral, PublicKeyToken=3694dea3dd97db1a'
>>>

I have python version 3.810, not 3.13.1.
Could this be a problem?

Regards
László

Michael Wollensack METAS

unread,
Jan 17, 2025, 5:03:57 AMJan 17
to VNA Tools
Hi,

Ok in that case try to update Python to V3.13.1.

Regards
Michael

Michael Wollensack METAS

unread,
Jan 17, 2025, 5:43:56 AMJan 17
to VNA Tools
Another reason could be that you have installed as well METAS UncLib from the msi installer (but not V2.8.3).

sle...@gmail.com

unread,
Jan 20, 2025, 5:17:05 AMJan 20
to VNA Tools
Hi,

I updated the Python to V3.13.1, now everything works fine.

Other question:
Is it possible to select S parameter only one frequency or I have to write a cycle to search it?

Regards
László

Michael Wollensack METAS

unread,
Jan 20, 2025, 8:21:09 AMJan 20
to VNA Tools
Hi,

> Is it possible to select S parameter only one frequency or I have to write a cycle to search it?


Regards
Michael

sle...@gmail.com

unread,
Jan 21, 2025, 5:15:31 AMJan 21
to VNA Tools
Hi,

I get error message for this code:

sdata.Item(0)

AttributeError: 'SParamData[UncNumber]' object has no attribute 'Item'



I found this solution, if I want to get back for S parameter of 1e9 Hz.

print(sdata[np.where(frequency == 1e9)[0][0].item(),0,0].Abs().Value)

Is there a simpler solution?

Regards
László

Michael Wollensack METAS

unread,
Jan 21, 2025, 6:39:36 AMJan 21
to VNA Tools
Hi,

to find the frequency index for given frequency I would use

i = np.where(np.isclose(frequency, 1e9, atol=1e-3))[0]


be aware that you're dealing with floats.

Regards
Michael

sle...@gmail.com

unread,
Jan 21, 2025, 7:59:32 AMJan 21
to VNA Tools
Hi,

Thank you Michael.
You helped me a lot.

Regards
László
Reply all
Reply to author
Forward
0 new messages