Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Save S21 data in CSV format
I have some S21 data (see attachment) that I want import into Excel as either tab or comma delimited frequency data pair. Neither nanovna-saver or nanoVNASharp support exporting to a CSV file. Has anyone written a python script that will get the NanoVNA S21 data and save it in CSV format? I suppose I could use nanovna-saver or nanoVNASharp to save to a s2p file and then parse that file to CSV, but I don't have the programming skills or understanding of the s2p format to do so. Any help would be appreciated.
Regards, -Herb |
QRP,
I had looked at the S2P file using a text editor and could see the values were space delimited but the none of the columns were identifiable to me as the S21 log magnitude values displayed by the nanoVNA. For example at 50 kHz the insertion loss value was -34.013 dB but none of the values at 50000 in the S2P file below are that value. # Hz S RI R 50 50000 -0.009529378 0.000616876 0.019876752 0.001359617 0 0 0 0 - Herb |
On Sun, Oct 13, 2019 at 08:58 PM, hwalker wrote:
Herb, As you know S-Parameter files are actually text files. The line with the "#" character is the format string for the file. This may or may not be the first line in a file. In the case above, the frequency is in Hz, this is an S-parameter file, the data values are Real and Imaginary because the header has "RI" and the impedance system is Resistive and 50 Ohms. 1st column is frequency in Hz, indicated by Hz in the first line, 2nd column is S11 real part (-0.009529378 above) 3rd column is S11 imaginary part (0.000616876 above) 4th column is S21 real part (0.019876752 above) 5th column is S21 imaginary part (0.001359617 above) 6th column is S12 real part (0 above) 7th column is S12 imaginary part (0 above) 8th column is S22 real part (0 above) 9th column is S22 imaginary part (0 above) nanoVNA-Saver does not save the data in dB format. I hope this helps. -- Bryan, WA5VAH |
Herb,
toggle quoted message
Show quoted text
The S2P file can be in decibels and phase angle, or in real and imaginary part for each component. In this case, I think "RI" indicates real and imaginary for each of the four S parameters (S11, S21, S22, S12) of a two port network. The data is for only S11 and S21 here, so the last 4 entries in each line are zero. To get dB, you compute 20*log(sqrt( real^2 + im^2)), or equivalently 10*log(real^2 + im^2). 10 * log (0.019876752^2 + 0.001359617^2) = -34.013, the insertion loss in dB. You can also get the phase by taking the arctan (im/re). --John Gord On Sun, Oct 13, 2019 at 07:58 PM, hwalker wrote:
|
Hi
Here is how to split "any somewhat formatted" text file using Excel 2003*. The procedure has been the same since the early 1990'ies: - Open the file in Excel - When the "Text Import Wizard" shows (Step 1 of 3) - select fixed width, in the case of a S2P file otherwise it could be delimited with e.g. "space", ";", ",", "tab" ... - select the row to start the import - select the file origin. Sometimes this may require some experimentation to match the OS locale - click the Next button (Step 2 of 3) - click the Next button (Step 3 of 3) - click the Advanced button - select the decimal separator (S2P file = .) - select the thousands separator (S2P file = ,) - click the OK button - Click the Next button *: I don't know how it is done in later versions or other spreadsheet programs. Another way to convert the decimal separator is to open the file in a text editor and replace the decimal separator. Bo |
On Sun, Oct 13, 2019 at 10:12 PM, John Gord wrote:
¡.. "To get dB, you compute 20*log(sqrt( real^2 + im^2)), or equivalently 10*log(real^2 + im^2).------------------------------------------------------------ John, That's the key piece of info I needed. None of my web searches returned that conversion formula. I can now use Excel to convert the data to dB and then apply some additional correction factors. I would eventually like to use Python to read the data directly from the NanoVNA and post process, plot and save it to a factor file. That's something I never would have even considered before purchasing the NanoVNA. The device has expanded my learning horizon. Thanks to everyone who responded. - Herb |
Hi Herb
The s1p and s2p files are plain txt files so you can open then directly from Excel, choosing a separator then you can save tocsv. However the first 4 lines are text telling what type of data are in the columns which you may removed. I use also a plane txt editor like notepad+ to remove sections of the frequency range e.g. from 500MHz upwards and the like Kind regards Kurt -----Oprindelig meddelelse----- Fra: [email protected] <[email protected]> P? vegne af hwalker Sendt: 14. oktober 2019 04:06 Til: [email protected] Emne: [nanovna-users] Save S21 data in CSV format I have some S21 data (see attachment) that I want import into Excel as either tab or comma delimited frequency data pair. Neither nanovna-saver or nanoVNASharp support exporting to a CSV file. Has anyone written a python script that will get the NanoVNA S21 data and save it in CSV format? I suppose I could use nanovna-saver or nanoVNASharp to save to a s2p file and then parse that file to CSV, but I don't have the programming skills or understanding of the s2p format to do so. Any help would be appreciated. Regards, -Herb |
On Mon, Oct 14, 2019 at 03:14 AM, hwalker wrote:
Herb, John Gord is on the right track about the phase. To be a bit more specific, the phase angle from -180 to 180 degrees in Excel is converted using atan2(im,re) which is the four quadrant arc tangent. The result from atan2() in Excel is in radians and you must convert to degrees if that is what you want. For example, to get the phase angle in degrees from S11 in row 5 once you load the S2p file into Excel you will need to put the equation "=atan2(c5,b5)*180/pi()" in a cell, say column 11 or something like that. Have fun. -- Bryan, WA5VAH |
to navigate to use esc to dismiss