# S parameters calculation from VNA file

I am trying to validate that our broadband LNA(Low noise amplifier) is working correctly. I wanted to measure the S21 of the LNA, I calibrated the VNA for the specified frequency range and measured performed a measurement. The file that I extracted from the VNA is a .s2p file.

It roughly looks like this. I can imagine that S is the real part of the signal and RI is the imaginary part of the signal. From there, how can I calculate the S21?

Thank you,

• Worth noting that although HZ S RI R 50 look like column headers when you import to Excel, they're not. They're flags. The first column does happen to be the frequency in Hz, but S means "this file has S-parameters", RI means "the values are real/imag pairs" (rather than magnitude/angle or dB/angle), and R 50 means that Z0 is 50 ohm. Commented Aug 16, 2023 at 15:42
• (in other words, the second column isn't "S", the third column isn't "RI", etc.) Commented Aug 16, 2023 at 16:28

### Updated answer: Calculate dB(|S21|) from .s2p.

First, instead of Excel, I strongly recommend a purpose-built RF data analysis tool, as it's much more efficient than manually handling them in Excel. They can automatically show S-parameters in other formats, such as magnitude-and-phase, real-and-imaginary, scalar decibel, VSWR, or plotting them as Smith chart, or even perform simulations with them.

Or at least, use an S-parameter file viewer.

Here, I show three different ways, in GUI using Qucs, in Python programming language using scikit-rf, or in a spreadsheet.

If you must do it in a spreadsheet, here is how.

First, make sure the format of the s2p file is what is being described in this answer. Touchstone files can include data in different formats, either in magnitude/phase, or in real/imaginary. Touchstone also uses different data order between 1/2-port test data and multi-port test data.

Take a look at the first line:

HZ S RI R 50

RI means the data is presented in the real-imaginary format, and R 50 means the system impedance is 50 Ω. This is what we want. If the headers are different, this answer does not apply.

Once we know the file format is what we expect, in this case, the order of the data is (beware that for 3-port, 4-port, or more ports, the order is different, and this answer does not apply):

freq ReS11 ImS11 ReS21 ImS21 ReS12 ImS12 ReS22 ImS22

Column 1 is frequency in Hertz, Column 2 is the real part of S11, Column 3 is the imaginary parts of S11, Column 4 is the real part of S21, Column 5 is the imaginary part of S21, etc. For low-cost VNAs that cannot measure in both directions, S12 and S22 are usually filled with placeholder 0.0, 0.0, 0.0, 0.0.

Next, we calculate the absolute value (modulus) of a complex number. For example, in the first line, your ReS21 and ImS21 values are:

3.42665, -2.97679

Thus,

\begin{align} \| S21 \| &= \|(3.42665 + (-2.97679j))\|\\ &= \sqrt{3.42665^2 + (-2.97679)^2}\\ &= 4.54 \end{align}

This is the scalar S21.

Next, express the scalar S21 in decibels. S21 is the ratio between input voltage wave and output voltage wave. If S21 is 1.0, it means the gain is 0 dB. Thus, using the formula of voltage ratio to decibel, we have:

\begin{align} \| \text{S21} \| _{dB} &= 20 \cdot \log_{10}{(\|\text{S21}\|)}\\ &= 20 \cdot \log_{10}{(4.54)}\\ &= 13.14 \text{ dB} \end{align}

This is the gain of the amplifier at 300 MHz.

#### Using Python and scikit-rf

I don't recommend the use of a spreadsheet to convert data manually problem when it's easily solved programmatically.

Using scikit-rf, a Python software library for RF/microwave data analysis, you just need to write 4 lines of code:

import sys
import skrf

network = skrf.Network(sys.argv[1])


Run it with

python3 touchstone-csv.py data.s2p


Now you have a data.s2p.csv file immediately, with the following content:

Freq(Hz),S11 Log Mag(dB),S11 Phase(deg),S21 Log Mag(dB),S21 Phase(deg),S12 Log Mag(dB),S12 Phase(deg),S22 Log Mag(dB),S22 Phase(deg)
300000000.0,-31.340189470952012,179.43340338132262,13.139348665139238,-40.98140991390657,-inf,0.0,-inf,0.0


This can be opened directly as a spreadsheet:

Plotting is easy too, for example:

network.plot_s_smith()


immediately gives you a Smith chart.

#### Using Qucs or another RF design tool

Qucs is a great tool but with a steep learning curve, but powerful once mastered. It can use external S-parameters files to perform RF simulation and show the results as Smith chart, as tables, as VSWR (with a suitable formula), etc. I have an example here.

There are also quite a few "S-parameter viewers" tools on the Web. They're less powerful than a full RF design software, but useful to give a quick look at the data. For example, I just did a quick search and found this tool from Teledyne LeCroy (I've never used it, but perhaps you can give it a try):

SParamViewer Version 2.0 SParamViewer is a free tool for plotting S-Parameters Features

• Reads standard Touchstone format S-Parameter files
• Zoom in for more detail
• Copy and Paste S-Parameter data as images, text, or Microsoft Excel® format

### Original Answer: Impossibility To Calculate S21 from S11

In general, calculating S21 from S11 is impossible - unless the device is reciprocal, such as most passive circuits that contain resistors, capacitors and inductors, in which case the S21 can be deduced using conservation of energy, as outlined here.

S11 measures the reflected signal at the input, S21 measures the transmitted signal at the output, they're completely different things. In an active device like a two-port amplifier, energy is not conserved, and it's not possible to calculate S21 from S11. Imagine a variable gain amplifier, when you change its gain, its S21 changes, but its S11 usually only has a slight change (if there's any change at all).

If your VNA supports 2-port measurement, you need to do a 2-port measurement and export the data as an .s2p file. A few additional things that deserve attention:

1. Beware of the maximum power limit of the VNA port. If your VNA is not designed to measure active circuits directly, make sure to use an coaxial RF attenuator as large as the gain of the LNA at the VNA's Port 2, otherwise the VNA can be damaged! Check the user manuals. With the attenuator installed, perform SOLT calibration as usual, after that, the effect of the attenuator is automatically removed.

2. Instead of using Excel, purpose-built RF data analysis tools are strongly recommended, they can automatically convert S-parameters to other formats, such as magnitude-and-phase, real-and-imaginary, scalar decibel, or VSWR formats. Qucs is a great tool but with a steep learning curve, I have an example here. Search the keyword "S-parameter viewers" on the Web for other options.

If you only have a 1-port VNA, beware that it only has limited use for designing active devices like amplifiers. You can check how well the input (and sometimes the output) is matched, but that's all.

If you don't have a 2-port VNA, you may want to use the old scalar method of a tracking generator and a spectrum analyzer, which is less powerful but cheaper than a VNA.

Note: Perhaps in some particular measurements, a clever arrangement of external RF couplers can turn a 2-port problem into a 1-port problem - but it's a brain-teaser rather than a practical solution of S21 measurements...

• hey sorry, thank you for your comment this is actually the .s2p file
– DRF
Commented Aug 16, 2023 at 17:47
• @DimitarZhekov Thanks for the update. I'll write another answer. Commented Aug 16, 2023 at 17:51