Read s2p Z parameter files in Python

294 views
Skip to first unread message

Puneet Jain

unread,
Jun 23, 2022, 2:18:45 PM6/23/22
to scikit-rf
I am trying to read s2p files in using Python scikit-rf library. The s2p file in not in S parameter. I converted it to Z parameter. Looks like scikit-rf can read only S parameter file. Is there any other library or way to read s2p files with Z parameter. Below is how I am reading the file:


import skrf as rf 
ntwk = rf.Network('ZTEST5_SHORTED.s10p') 
s = ntwk.s print(s)

Below is the error:

Traceback (most recent call last): File "C:\Users\pujai\PycharmProjects\SIIntegration\practice.py", line 26, in <module> ntwk = rf.Network('ZTEST5_SHORTED_DCfitted.s10p') File "C:\Users\pujai\PycharmProjects\SIIntegration\venv\lib\site-packages\skrf\network.py", line 457, in __init__ self.read_touchstone(filename, self.encoding) File "C:\Users\pujai\PycharmProjects\SIIntegration\venv\lib\site-packages\skrf\network.py", line 2050, in read_touchstone raise NotImplementedError('only s-parameters supported for now.') NotImplementedError: only s-parameters supported for now.


If I try to read an S parameter file, it works fine. Any help?

Puneet Jain

unread,
Jun 23, 2022, 3:46:32 PM6/23/22
to scikit-rf
Here is a snippet from the file:

#    MHz    Z    MA    R    1
0    10676.9217266929    -89.9996922763017    21.8057273267468    -90.0020463959989    51.2822443115442    -90.0001796805383    51.2822443139193    -90.0001913484415
                51.2822443092998    -90.000353348531    51.2822443194682    -90.0004686439498    51.2822443930106    -90.000550007965    51.2822442696319    -90.0000948159687
                6.97916690350401    89.9998344901134    6.97916691190284    89.9986375129139
            21.8057273104465    -90.0020464107003    63754.6007953583    89.9981705059089    20.6101518076135    90.0041095770662    20.6101517339149    89.999990857772
                20.6101516951136    89.9980338593023    20.6101516965512    89.9982869729047    20.6101517268438    89.9991377329278    20.6101517071014    89.998753887922
                0.621172783655873    -89.9822306398258    0.621172812583443    -89.976139722965
            51.2822443061024    -90.0001797181979    20.610151252399    90.004109014424    1889.84663829441    -89.9991386658517    1889.84663831083    -89.9991524638532
                1889.84663835269    -89.9992005745209    1889.84663833721    -89.9991774317595    1889.84663785683    -89.9992933431628    1889.84663795451    -89.9992697366806
                42.3883012605096    90.0056833234696    42.3883011851481    90.0055121758161
            51.2822443084774    -90.000191386101    20.6101511787261    89.9999902950379    1889.84663831083    -89.9991524638532    1889.84663832319    -89.9991346737575
                1889.84663836817    -89.9991979388386    1889.84663835328    -89.9991743791286    1889.84663786705    -89.9992894882182    1889.84663797014    -89.9992663366631
                42.3883012618417    90.0056460941817    42.3883011863982    90.0054749465282
            51.2822443038578    -90.0003533861906    20.6101511399333    89.9980332965163    1889.84663835267    -89.9992005745209    1889.84663836816    -89.9991979388386
                1889.84663844745    -89.9992060956688    1889.84663842919    -89.9991944418949    1889.84663792613    -89.9993174098777    1889.84663803201    -89.9992900406004
                42.3883012345506    90.0050947810637    42.3883011616751    90.0049600976616
            51.2822443140278    -90.0004686816089    20.6101511413649    89.9982864101169    1889.84663833725    -89.9991774317595    1889.84663835331    -89.9991743791287
                1889.84663842924    -89.9991944418949    1889.84663840981    -89.999156770148    1889.84663790361    -89.9992904883582    1889.84663801847    -89.9992585876496
                42.3883012986792    90.0061517302031    42.3883012189043    90.0060170468036
            51.2822443875694    -90.0005500456245    20.6101511716603    89.9991371701763    1889.84663785686    -89.9992933431628    1889.84663786708    -89.9992894882182
                1889.84663792616    -89.9993174098777    1889.8466379036    -89.9992904883582    1889.84663743521    -89.9993913543685    1889.84663762473    -89.9993796397999
                42.3883011783852    90.0049118622332    42.3883011060572    90.0047036801252
            51.2822442641889    -90.0000948536285    20.6101511519151    89.9987533251306    1889.84663795446    -89.9992697366806    1889.8466379701    -89.9992663366632
                1889.84663803198    -89.9992900406004    1889.84663801839    -89.9992585876496    1889.84663762466    -89.9993796397999    1889.8466376412    -89.9993421525407
                42.3883011908417    90.0054688790319    42.3883011186086    90.0052606969267
            6.97916690335969    89.9998343192217    0.621171596913012    -89.982270102364    42.3883012987864    90.0056831034319    42.3883013001192    90.0056458741442
                42.3883012728306    90.0050945610262    42.3883013369573    90.0061515101649    42.3883012166644    90.0049116421959    42.3883012291213    90.0054686589943
                5281.89056273623    -89.9999867646875    5281.89056272443    -89.9999841097774
            6.97916691175836    89.9986373420223    0.621171625788863    -89.9761791738575    42.3883012234252    90.0055119557792    42.388301224676    90.0054747264914
                42.3883011999552    90.0049598776248    42.3883012571825    90.006016826766    42.3883011443368    90.0047034600886    42.3883011568886    90.0052604768899
                5281.89056272444    -89.9999841097774    5281.89056270833    -89.9999287234814
1e-07    10676.9217266929    -89.9996922763017    21.8057273267468    -90.0020463959989    51.2822443115442    -90.0001796805383    51.2822443139193    -90.0001913484415
                51.2822443092998    -90.000353348531    51.2822443194682    -90.0004686439498    51.2822443930106    -90.000550007965    51.2822442696319    -90.0000948159687
                6.97916690350401    89.9998344901134    6.97916691190284    89.9986375129139
            21.8057273104465    -90.0020464107003    63754.6007953583    89.9981705059089    20.6101518076135    90.0041095770662    20.6101517339149    89.999990857772
                20.6101516951136    89.9980338593023    20.6101516965512    89.9982869729047    20.6101517268438    89.9991377329278    20.6101517071014    89.998753887922
                0.621172783655873    -89.9822306398258    0.621172812583443    -89.976139722965
            51.2822443061024    -90.0001797181979    20.610151252399    90.004109014424    1889.84663829441    -89.9991386658517    1889.84663831083    -89.9991524638532
                1889.84663835269    -89.9992005745209    1889.84663833721    -89.9991774317595    1889.84663785683    -89.9992933431628    1889.84663795451    -89.9992697366806
                42.3883012605096    90.0056833234696    42.3883011851481    90.0055121758161
            51.2822443084774    -90.000191386101    20.6101511787261    89.9999902950379    1889.84663831083    -89.9991524638532    1889.84663832319    -89.9991346737575
                1889.84663836817    -89.9991979388386    1889.84663835328    -89.9991743791286    1889.84663786705    -89.9992894882182    1889.84663797014    -89.9992663366631
                42.3883012618417    90.0056460941817    42.3883011863982    90.0054749465282
            51.2822443038578    -90.0003533861906    20.6101511399333    89.9980332965163    1889.84663835267    -89.9992005745209    1889.84663836816    -89.9991979388386
                1889.84663844745    -89.9992060956688    1889.84663842919    -89.9991944418949    1889.84663792613    -89.9993174098777    1889.84663803201    -89.9992900406004
                42.3883012345506    90.0050947810637    42.3883011616751    90.0049600976616
            51.2822443140278    -90.0004686816089    20.6101511413649    89.9982864101169    1889.84663833725    -89.9991774317595    1889.84663835331    -89.9991743791287
                1889.84663842924    -89.9991944418949    1889.84663840981    -89.999156770148    1889.84663790361    -89.9992904883582    1889.84663801847    -89.9992585876496
                42.3883012986792    90.0061517302031    42.3883012189043    90.0060170468036
            51.2822443875694    -90.0005500456245    20.6101511716603    89.9991371701763    1889.84663785686    -89.9992933431628    1889.84663786708    -89.9992894882182
                1889.84663792616    -89.9993174098777    1889.8466379036    -89.9992904883582    1889.84663743521    -89.9993913543685    1889.84663762473    -89.9993796397999
                42.3883011783852    90.0049118622332    42.3883011060572    90.0047036801252
            51.2822442641889    -90.0000948536285    20.6101511519151    89.9987533251306    1889.84663795446    -89.9992697366806    1889.8466379701    -89.9992663366632
                1889.84663803198    -89.9992900406004    1889.84663801839    -89.9992585876496    1889.84663762466    -89.9993796397999    1889.8466376412    -89.9993421525407
                42.3883011908417    90.0054688790319    42.3883011186086    90.0052606969267
            6.97916690335969    89.9998343192217    0.621171596913012    -89.982270102364    42.3883012987864    90.0056831034319    42.3883013001192    90.0056458741442
                42.3883012728306    90.0050945610262    42.3883013369573    90.0061515101649    42.3883012166644    90.0049116421959    42.3883012291213    90.0054686589943
                5281.89056273623    -89.9999867646875    5281.89056272443    -89.9999841097774
            6.97916691175836    89.9986373420223    0.621171625788863    -89.9761791738575    42.3883012234252    90.0055119557792    42.388301224676    90.0054747264914
                42.3883011999552    90.0049598776248    42.3883012571825    90.006016826766    42.3883011443368    90.0047034600886    42.3883011568886    90.0052604768899
                5281.89056272444    -89.9999841097774    5281.89056270833    -89.9999287234814


Its a 10*10 matrix. I am posting only two frequencies here to make it short.

Puneet Jain

unread,
Jun 23, 2022, 6:44:44 PM6/23/22
to scikit-rf
Can someone please tell me if its possible or not? All I am looking for is a way to parse this data and have it in an array. I don't need to perform any other operations on it. I

jeanbiego

unread,
Jun 23, 2022, 9:22:24 PM6/23/22
to scikit-rf
Hi,

I have not tried converting the pasted text to a numpy array because of the difficulty, but if you can do that, the following could be used.
2022年6月24日金曜日 7:44:44 UTC+9 punit.ja...@gmail.com:

vinc0110

unread,
Jun 24, 2022, 12:56:52 AM6/24/22
to scikit-rf
As you already mentioned, scikit-rf can currently only read S parameters from a Touchstone file, see source code here: https://github.com/scikit-rf/scikit-rf/blob/ba3b0a7f391838dabaa6c122db1a8e28067e9494/skrf/network.py#L2049-L2050
I don't know the reason, because the file format obviously supports other parameters as well. It looks like you have to parse the file yourself or find another library that can do it. The Touchstone format is pretty simple though: http://www.ibis.org/touchstone_ver2.0/touchstone_ver2_0.pdf

Julien Hillairet

unread,
Jun 24, 2022, 1:43:23 AM6/24/22
to scik...@googlegroups.com
Indeed scikit-rf does not support Touchstone files with other data than S yet. (and to be honest this is the first time I see such file. Where does it come from?)

If you want to contribute to the project, you can start by submitting an issue on github.

Otherwise, there is eventually a possible hack to test:

# replace 'Z' with 'S' in your s10p file
dummy = rf.Network('test.s10p')
ntwk = rf.Network(z=dummy.s, frequency=dummy.frequency)

Julien

--
You received this message because you are subscribed to the Google Groups "scikit-rf" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-rf+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scikit-rf/02248ce0-eb44-4d1b-a78b-d55248d00cdbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages