Graphics, Figures & Tables ⇒ pgfplots | Data from *. s1p Files for Smith Diagramm
pgfplots | Data from *. s1p Files for Smith Diagramm
Dear all,
I have found that pgfplots can plot Smith diagrams, but I have not yet found an option to directly import a *.s1p file which contains the data of such a Smith chart.
Does someone knows such option ?
Thanks a lot,
Best regards,
Hadrien
I have found that pgfplots can plot Smith diagrams, but I have not yet found an option to directly import a *.s1p file which contains the data of such a Smith chart.
Does someone knows such option ?
Thanks a lot,
Best regards,
Hadrien
NEW: TikZ book now 40% off at Amazon.com for a short time.
-
- Posts: 34
- Joined: Sun Oct 16, 2011 5:56 pm
pgfplots | Data from *. s1p Files for Smith Diagramm
Hi Hadrian,
An .s1p file seems to be some quite specific data format generated and/or used by 3rd party software. What is it? How is it defined?
If you have data files, pgfplots supports table format or perhaps the explicit coordinate input format. For Smith charts, it expects either untransformed complex values as input (default) or, with
Best regards
Christian
An .s1p file seems to be some quite specific data format generated and/or used by 3rd party software. What is it? How is it defined?
If you have data files, pgfplots supports table format or perhaps the explicit coordinate input format. For Smith charts, it expects either untransformed complex values as input (default) or, with
is smithchart cs=true
, cartesian coordinates inside of the unit circle.Best regards
Christian
-
- Posts: 2
- Joined: Sat May 23, 2015 4:33 pm
pgfplots | Data from *. s1p Files for Smith Diagramm
Hi!
Found this very old thread and it would have saved me hours if there would have been some examples on the usage. Here is some code with some examples on how to use this.
The following code assumes a standard s1p-File with row1 being the Frequency, row2 the real part and row3 the imaginary part:
The output can be seen in the attachment.
Found this very old thread and it would have saved me hours if there would have been some examples on the usage. Here is some code with some examples on how to use this.
The following code assumes a standard s1p-File with row1 being the Frequency, row2 the real part and row3 the imaginary part:
! ListType=Lin
! Comment=PCB-Spule_N10
# MHz S RI R 50
0.1000000 -0.9712057 0.0205816
0.2333556 -0.9715719 0.0436983
0.3667111 -0.9699207 0.0673892
0.5000667 -0.9677658 0.0899401
0.6334223 -0.9641644 0.1142959
0.7667779 -0.9615511 0.1367883
0.9001334 -0.9574007 0.1607424
1.0334890 -0.9530981 0.1832266
(...)
Code: Select all
% !TeX encoding = UTF-8
% !TeX spellcheck = de_DE
\documentclass[11pt,border=0mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{smithchart}
%Command to create a vertical, gray, dashed line in plots
\newcommand{\vasymptote}[2][]{
\draw [color=gray,densely dashed,#1] ({rel axis cs:0,0} -| {axis cs:#2,0}) -- ({rel axis cs:0,1} -| {axis cs:#2,0});
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=0.95\textwidth,
height=7.5cm, %xmin=0,xmax=75,ymin=-80,
xlabel={frequency [GHz]},ylabel={},legend pos=south west
]
\vasymptote {76.88} %First item-be in the bg.
\addplot[color=red] table[skip first n=2, %Ignore the first two lines (comment and ListType)
x index=0, %in which column to find the x-values
y expr={\thisrowno{1}} %in which column to find the y-values
] {data/test.s1p};
\addlegendentry{$Re(\Gamma=s_{11})$}
\addplot[color=blue] table[skip first n=2, x index=0, y expr={\thisrowno{2}}] {data/test.s1p};
\addlegendentry{$Im(\Gamma=s_{11})$}
\addplot[color=black] table[skip first n=2, x index=0, y expr={(((\thisrowno{1})^2+(\thisrowno{2})^2))}] {data/test.s1p};
\addlegendentry{$|\Gamma=s_{11}|^2$}
\addplot[color=green] table[skip first n=2, x index=0, y expr={20*log10(sqrt((\thisrowno{1})^2+(\thisrowno{2})^2))}] {data/test.s1p};
\addlegendentry{$ |\Gamma=s_{11}|\text{ in dB}$}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{smithchart}[
width=7.5cm,
height=7.5cm
]
\addplot[color=red,is smithchart cs] table[skip first n=2, meta index=0, x expr={\thisrowno{1}}, y expr={\thisrowno{2}}] {data/test.s1p};
\addplot+[color=blue,is smithchart cs,
mark phase=20, %line offset for the first mark
mark repeat=150, %lines after which to make the next mark
mark=o,
nodes near coords, % Place nodes near each coordinate
point meta=explicit,
every node near coord/.append style={
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1
}, % Display numbers with precision 1, e.g. 10.0, 91.2, etc
] table[skip first n=2, meta index=0, x expr={-\thisrowno{1}}, y expr={-\thisrowno{2}} % Minus just to receive antoher graph!
] {data/test.s1p};
\end{smithchart}
\end{tikzpicture}
\end{document}
- Attachments
-
- test.pdf
- Code: See post.
- (63.69 KiB) Downloaded 258 times
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
pgfplots | Data from *. s1p Files for Smith Diagramm
Hi and welcome, thanks for sharing you solution.
One minor thing. The real and imaginary parts are either typeset in Fraktur, or in the upright form. In the latter, it could be confused with the Reynolds number, depending on your readership. Please consider the following:
One minor thing. The real and imaginary parts are either typeset in Fraktur, or in the upright form. In the latter, it could be confused with the Reynolds number, depending on your readership. Please consider the following:
Code: Select all
\documentclass{article}
\usepackage{mathtools}
\begin{document}
$a = \Re{(a + b\mathrm i)} $ und $b = \Im{(a + b\mathrm i)}$\par
\renewcommand{\Re}{\mathrm{Re}} \renewcommand{\Im}{\mathrm{Im}}
$a = \Re{(a + b\mathrm i)} $ und $b = \Im{(a + b\mathrm i)}$
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
-
- Posts: 2
- Joined: Sat May 23, 2015 4:33 pm
pgfplots | Data from *. s1p Files for Smith Diagramm
Hi again.
@Johannes: Oh, thanks I've been looking for something like this. Wouldn't a renewcomand usually belong in front of begin[document]?
I also wanted to share my code for .s2p-Files and some more tricks for nice results:
Results in:
And
Results in:
I know this code is not that well documented, but I hope it helps anyway.
Now I come to another thing: Admittance Smith Charts. Though they seem a little buggy, I got this working:
Results in:
Please note that, as far as I know, the plus/minus sign of the admittance chart is wrong.
If you have any questions about this code (please only about the code, since my knowledge of LaTex is very limited), you can contact me via master (youknowwhat) aypac.de
@Johannes: Oh, thanks I've been looking for something like this. Wouldn't a renewcomand usually belong in front of begin[document]?
I also wanted to share my code for .s2p-Files and some more tricks for nice results:
Code: Select all
% !TeX encoding = UTF-8
% !TeX spellcheck = de_DE
\documentclass[11pt,border=0mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[]{units}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
%Command to create a vertical dashed line in Plots
\newcommand{\vasymptote}[2][]{
\draw [color=gray,densely dashed,#1] ({rel axis cs:0,0} -| {axis cs:#2,0}) -- ({rel axis cs:0,1} -| {axis cs:#2,0});
}
\usepgfplotslibrary{smithchart}
%\usepgfplotslibrary[smithchart]
%\usetikzlibrary{pgfplots.smithchart}
%\usetikzlibrary[pgfplots.smithchart]
\pgfplotsset{compat=1.12}
%a4: width=21.00cm, height=29.70cm
%borders 2.5cm each side => width=16.00cm*0.95=15.2cm
%\usepackage[left=2cm, right=1cm, top=1cm, bottom=1cm]{geometry}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title=\text{$N=10$ PCB-Spule mit Anpassungsnetzwerk},
width=15.2cm, height=8cm,
ymin=-18, xmin=0,xmax=200,ymax=0,
xlabel={$f$ [MHz]},ylabel={Amplitude [dB]},legend pos=south west]
\vasymptote {84.1} %Als erstes, damit im Hintergrund!
\addplot[color=blue] table[skip first n=2, x index=0, y expr={20*log10(sqrt((\thisrowno{1})^2+(\thisrowno{2})^2)}] {../data/VNAS/PCB/Neu/PCB-Spule-N10-2015-05-22.s1p};
\addlegendentry{$s_{11}$, Ohne Anpassung}
\addplot[color=red] table[skip first n=2, x index=0, y expr={20*log10(sqrt((\thisrowno{1})^2+(\thisrowno{2})^2))}] {../data/VNAS/PCB/Neu/N10/2/n10-anp4.1.2015-05-28.s1p};
\addlegendentry{$s_{11}$, impedanzangepasst}
\addplot[color=green] table[skip first n=2, x index=0, y expr={20*log10(sqrt((\thisrowno{3})^2+(\thisrowno{4})^2))}] {../data/VNAS/PCB/Neu/N10/2/n10-anp4.1.2015-06-02.s2p};
\addlegendentry{$s_{21}$, impedanzangepasst}
\end{axis}
\end{tikzpicture}
\end{document}
And
Code: Select all
% !TeX encoding = UTF-8
% !TeX spellcheck = de_DE
\documentclass[11pt,border=0mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[]{units}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
%Command to create a vertical dashed line in Plots
\newcommand{\vasymptote}[2][]{
\draw [color=gray,densely dashed,#1] ({rel axis cs:0,0} -| {axis cs:#2,0}) -- ({rel axis cs:0,1} -| {axis cs:#2,0});
}
\usepgfplotslibrary{smithchart}
\pgfplotsset{compat=1.12}
%a4: width=21.00cm, height=29.70cm
%borders 2.5cm each side => width=16.00cm*0.95=15.2cm
%\usepackage[left=2cm, right=1cm, top=1cm, bottom=1cm]{geometry}
\begin{document}
\begin{tikzpicture}
\begin{smithchart}[
title=Imdepedanz Smith-Diagramm zweier PCB-Spulen,
width=15.2cm,
% smithchart mirrored=false, %admittance vs impedance smith graph
% yticklabel around circle*, %around vs in
show origin=true,
]
\addplot+[color=blue, line width=0.4mm, is smithchart cs,
mark phase=12, %line offset for the first mark
mark repeat=100, %lines after which to make the next mark
mark=x,
% nodes near coords, % Place nodes near each coordinate
% point meta=explicit,
% every node near coord/.append style={
% anchor=-90, % angle for the label
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=1
% }, % Display numbers with precision 1, e.g. 10.0, 91.2, etc
] table[skip first n=2, select coords between index={619}{643}, meta index=0, x expr={\thisrowno{1}}, y expr={\thisrowno{2}} % Minus just to receive antoher graph!
] {../data/VNAS/PCB/Neu/PCB-Spule-N10-2015-05-22.s1p};
\addlegendentry{Ohne Anpassung}
\addplot+[color=red, line width=0.4mm, is smithchart cs,
mark phase=12, %line offset for the first mark
mark repeat=100, %lines after which to make the next mark
mark=o,
% nodes near coords, % Place nodes near each coordinate
% point meta=explicit,
% every node near coord/.append style={
% anchor=-90, % angle for the label
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=1
% }, % Display numbers with precision 1, e.g. 10.0, 91.2, etc
] table[skip first n=2, select coords between index={619}{643}, meta index=0, x expr={\thisrowno{1}}, y expr={\thisrowno{2}} % Minus just to receive antoher graph!
] {../data/VNAS/PCB/Neu/N10/2/n10-anp4.1.2015-05-28.s1p};
\addlegendentry{Mit Impedanzanpassung}
%The rest of the graph in lighter colors
\addplot[color=red!40!white,is smithchart cs] table[skip first n=2, select coords between index={0}{619},x expr={\thisrowno{1}}, y expr={\thisrowno{2}}] {../data/VNAS/PCB/Neu/N10/2/n10-anp4.1.2015-05-28.s1p};
\addplot[color=red!40!white,is smithchart cs] table[skip first n=2, select coords between index={643}{2000},x expr={\thisrowno{1}}, y expr={\thisrowno{2}}] {../data/VNAS/PCB/Neu/N10/2/n10-anp4.1.2015-05-28.s1p};
\addplot[color=blue!40!white,is smithchart cs] table[skip first n=2, select coords between index={0}{619},x expr={\thisrowno{1}}, y expr={\thisrowno{2}}] {../data/VNAS/PCB/Neu/PCB-Spule-N10-2015-05-22.s1p};
\addplot[color=blue!40!white,is smithchart cs] table[skip first n=2, select coords between index={643}{2000},x expr={\thisrowno{1}}, y expr={\thisrowno{2}}] {../data/VNAS/PCB/Neu/PCB-Spule-N10-2015-05-22.s1p};
\end{smithchart}
\end{tikzpicture}
\end{document}
Now I come to another thing: Admittance Smith Charts. Though they seem a little buggy, I got this working:
Code: Select all
% !TeX encoding = UTF-8
% !TeX spellcheck = de_DE
\documentclass[11pt,border=0mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[]{units}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
%Command to create a vertical dashed line in Plots
\newcommand{\vasymptote}[2][]{
\draw [color=gray,densely dashed,#1] ({rel axis cs:0,0} -| {axis cs:#2,0}) -- ({rel axis cs:0,1} -| {axis cs:#2,0});
}
\usepgfplotslibrary{smithchart}
%a4: width=21.00cm, height=29.70cm
%borders 2.5cm each side => width=16.00cm*0.95=15.2cm
%\usepackage[left=2cm, right=1cm, top=1cm, bottom=1cm]{geometry}
\begin{document}
\begin{tikzpicture}[]
% First, the Admittance chart:
\begin{smithchart}[
title=\text{Imdepedanz und Admittanz Smith-Diagramm zweier PCB-Spulen},
smithchart mirrored=true,
xticklabel shift=-19pt,
grid style={blue},
ticklabel style={blue},
width=15.2cm,
xtick={0.2,0.5,1,2,5},
ytick={0,0.2,0.5,1,2,5,-0.2,-0.5,-1,-2,-5},
xgrid each nth passes y={2},
ygrid each nth passes x={2},%ytick align=center,
ytick align=center,
yticklabel style={
rotate=180,
},
]
\end{smithchart}
% Second, overlay the impedance chart:
\begin{smithchart}[
show origin,
grid style={red},
ticklabel style={red},
width=15.2cm,
xtick={0.2,0.5,1,2,5}, %,0.1,0.3
ytick={0,0.2,0.5,1,2,5,-0.2,-0.5,-1,-2,-5},
xgrid each nth passes y={2},
ygrid each nth passes x={2},
]
\addplot+[color=green, line width=0.4mm, is smithchart cs,
mark phase=12, %line offset for the first mark
mark repeat=100, %lines after which to make the next mark
mark=o,
% nodes near coords, % Place nodes near each coordinate
% point meta=explicit,
% every node near coord/.append style={
% anchor=-90, % angle for the label
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=1
% }, % Display numbers with precision 1, e.g. 10.0, 91.2, etc
] table[skip first n=2, select coords between index={619}{643}, meta index=0, x expr={\thisrowno{1}}, y expr={\thisrowno{2}} % Minus just to receive antoher graph!
] {../data/VNAS/PCB/Neu/PCB-Spule-N20-2015-05-22.s1p};
\addlegendentry{$N=20$}
\addplot+[color=orange, line width=0.4mm, is smithchart cs,
mark phase=12, %line offset for the first mark
mark repeat=100, %lines after which to make the next mark
mark=x,
% nodes near coords, % Place nodes near each coordinate
% point meta=explicit,
% every node near coord/.append style={
% anchor=-90, % angle for the label
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=1
% }, % Display numbers with precision 1, e.g. 10.0, 91.2, etc
] table[skip first n=2, select coords between index={619}{643}, meta index=0, x expr={\thisrowno{1}}, y expr={\thisrowno{2}} % Minus just to receive antoher graph!
] {../data/VNAS/PCB/Neu/PCB-Spule-N10-2015-05-22.s1p};
\addlegendentry{$N=10$}
\end{smithchart}
\end{tikzpicture}
\end{document}
If you have any questions about this code (please only about the code, since my knowledge of LaTex is very limited), you can contact me via master (youknowwhat) aypac.de
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: pgfplots | Data from *. s1p Files for Smith Diagramm
There are certain places where it completely fine to redefine a command within documents. Here i had to do, or nobody would have seen any changes 

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.