Loading touchstone (.snp) files

At the moment, what is the most convenient way to load touchstone (.snp) files in Julia ?

I typically want to load scattering parameter of a multi-channel array extracted from software like Advanced Software Design (ADS).

A google search finds a (deleted) project (EDAData.jl) by @MA_Laforge
Let’s see if s/he is still around.

There is also Touchstone.jl. Also the archived package Marconi provides functions to read and write Touchstone files.

2 Likes

I saw this one, but I could not find documentation on how to use it.

Not sure which one you’re referring to, but Touchstone.jl provides what looks like a comprehensive Readme.md with a section on Usage. For Marconi, there is substantial documentation, in particular for FileIO.

2 Likes

Sorry. I was actually referring to this one (for which I could not find any documentation): GitHub - mpichl87/Touchstone.jl: Julia module for parsing Touchstone files.

I will try the one from Marconi as soon as I have time.

From your comments it appears that you’re not familiar with the “badges” that are displayed on many Github pages. On the Touchstone.jl repo you referenced, there is a badge that looks like this:
image
This badge is a link to the “stable” version of the documentation (i.e. the version associated with the latest tagged release of the package). In that link there is documentation for the “Public Interface” (i.e. the exported names from the package) which includes parse_touchstone_file which I think is what you want. An example of its use can be found in the unit tests starting here.

1 Like

Oh, wow: I believe that package was deleted about a year ago.

In case you are still curious @Valery: the new home of my touchstone reader is now the EDAData module (namespace) of the CMDimCircuits.jl package:
CMDimCircuits.jl/EDAData.md at master · ma-laforge/CMDimCircuits.jl · GitHub

Background on deprecating EDAData.jl

In the days of EDAData.jl, I had trouble maintaining/synchronizing my heavily fragmented solution of circuit-related packages. Since each package had to be in its own .git repository, I had to tag & release multiple julia packages simultaneously, and it was very labour intensive/error prone.

Although this one-to-one relationship is no longer strictly necessary, I haven’t personally figured out a good way to get things to work smoothly.

An example of reading touchstone

import CMDimCircuits
import CMDimCircuits.EDAData
using CMDimCircuits.NetwAnalysis #for mx2elem

#Read in S-parameter matrix:
S = EDAData.read_snp("lineS_5.0m.s2p", numports=2)

#Obtain data as DataF1 object (keeps frequency & SP data together for easier math)
s21 = S[2,1]

#Unpack all DataF1 objects simultaneously instead:
(s11, s12, s21, s22) = mx2elem(S)

#NOTE:
#   DataF1 objects keep frequency & "y-values" together when applying math:
Δ = s11*s22 - s12*s21
K = ( 1 - abs(s11)^2 - abs(s22)^2 + abs(Δ)^2 ) / ( abs(s12)*abs(s21) )
#(Would also work with parametric sweeps of S-parameter data!)


#But you can also get (frequency/"y-value") data
#as simple vectors, if preferred:
f = S[2,1].x
s21 = S[2,1].y
2 Likes

A word of caution

Please note that my implementation is not super robust at the moment. It likely is not fully compliant with the standard.

InspectDR

Since you are likely are in need of generating Smith plots, InspectDR can do that:
GitHub - ma-laforge/InspectDR.jl: Fast, interactive Julia/GTK+ plots (+Smith charts +Gtk widget +Cairo-onl

2 Likes