Touchstone.Parser 1.0.1

dotnet add package Touchstone.Parser --version 1.0.1
                    
NuGet\Install-Package Touchstone.Parser -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Touchstone.Parser" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Touchstone.Parser" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Touchstone.Parser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Touchstone.Parser --version 1.0.1
                    
#r "nuget: Touchstone.Parser, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Touchstone.Parser@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Touchstone.Parser&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Touchstone.Parser&version=1.0.1
                    
Install as a Cake Tool

Touchstone.Parser

A .NET library for Touchstone .sNp parsing and S‑parameter analysis in RF/microwave engineering.

NuGet NuGet Downloads Build Coverage Docs License .NET

Touchstone.Parser is a clean, modular, enterprise-ready .NET library for parsing Touchstone (.sNp) files — the industry-standard format for RF and microwave S‑parameter data. It provides strongly typed classes, LINQ-friendly APIs, and seamless integration into simulation and analysis workflows.


✨ Features

  • Parse .sNp files into strongly typed C# classes (TouchstoneData, FrequencyPoint, NetworkParameter)
  • Multi-port support — 1‑port through N‑port networks
  • All data formats — Real/Imaginary (RI), Magnitude/Angle (MA), Decibel/Angle (DB)
  • All frequency units — Hz, kHz, MHz, GHz with automatic normalization
  • All parameter types — S, Y, Z, H, G
  • LINQ-friendly APIs — query S‑parameters with GetS11(), GetS21(), GetParameter(i, j)
  • RF calculations — insertion loss, return loss, VSWR out of the box
  • Export utilities — CSV export and Touchstone writer for round-trip fidelity
  • Async supportParseAsync() with cancellation token
  • Cross-platform — targets net6.0 and netstandard2.1
  • Zero dependencies — pure .NET, no external packages

📦 Installation

dotnet add package Touchstone.Parser

Or via the NuGet Package Manager:

Install-Package Touchstone.Parser

🚀 Quick Start

using Touchstone.Parser.Parsing;
using Touchstone.Parser.Utilities;
using Touchstone.Parser.Models;

// Parse a Touchstone file
var data = TouchstoneParser.Parse("filter.s2p");

Console.WriteLine($"Ports: {data.NumberOfPorts}");
Console.WriteLine($"Frequency points: {data.Count}");

// Query S21 insertion loss with LINQ
foreach (var (freqHz, param) in data.GetS21())
{
    double freqGhz = FrequencyConverter.FromHz(freqHz, FrequencyUnit.GHz);
    Console.WriteLine($"{freqGhz:F3} GHz → S21 = {param.MagnitudeDb:F2} dB");
}

// Filter to a frequency range
var passband = data.InFrequencyRange(2.0e9, 3.0e9);

// Compute VSWR
foreach (var (freqHz, vswr) in data.ToVswr())
{
    Console.WriteLine($"VSWR = {vswr:F3}");
}

// Export to CSV
using var writer = new StreamWriter("output.csv");
data.ToCsv(writer, FrequencyUnit.GHz, DataFormat.DecibelAngle);

📖 API Overview

Parsing

Method Description
TouchstoneParser.Parse(filePath) Parse from a file path
TouchstoneParser.Parse(stream, fileName?) Parse from a stream
TouchstoneParser.Parse(textReader, fileName?) Parse from a TextReader
TouchstoneParser.ParseString(content, fileName?) Parse from a raw string
TouchstoneParser.ParseAsync(filePath, ct) Async file parsing

Data Access (LINQ-friendly)

Method Description
data.GetParameter(row, col) Get any S‑parameter across all frequencies
data.GetS11() / GetS21() / GetS12() / GetS22() Common 2‑port shortcuts
data.Frequencies All frequency values in Hz
data.GetFrequenciesIn(FrequencyUnit.GHz) Frequencies in any unit
data[index] Access a specific frequency point

RF Calculations

Method Description
data.ToInsertionLoss() |S21| insertion loss in dB
data.ToReturnLoss() |S11| return loss in dB
data.ToVswr() VSWR from S11

Filtering & Export

Method Description
data.InFrequencyRange(minHz, maxHz) Filter to frequency range
data.Where(predicate) Custom filtering
data.ToCsv(writer, unit, format) Export to CSV
data.ToCsvString(unit, format) Export to CSV string
TouchstoneWriter.Write(data, filePath) Write back to Touchstone format

Utilities

Method Description
FrequencyConverter.Convert(val, from, to) Convert between frequency units
NetworkParameter.FromRealImaginary(re, im) Create from RI
NetworkParameter.FromMagnitudeAngle(mag, deg) Create from MA
NetworkParameter.FromDecibelAngle(dB, deg) Create from DB

🏗️ Project Structure

touchstone-dotnet/
├── src/
│   └── Touchstone.Parser/          # Core library
│       ├── Models/                  # Domain models (enums, data classes)
│       ├── Parsing/                 # Parser engine
│       └── Utilities/               # Converters, extensions, writer
├── tests/
│   └── Touchstone.Parser.Tests/    # xUnit test suite
├── examples/
│   └── Touchstone.Parser.Examples/ # Demo console app
├── Directory.Build.props            # Centralized build settings
├── Touchstone.Parser.sln            # Solution file
└── global.json                      # .NET SDK version

🔧 Supported Formats

Feature Supported
Touchstone v1.0 / v1.1
1‑port (.s1p)
2‑port (.s2p)
3+ port (.s3p, .s4p, ...)
Real-Imaginary (RI)
Magnitude-Angle (MA)
Decibel-Angle (DB)
Hz / kHz / MHz / GHz
S / Y / Z / H / G parameters
Comments and metadata
Touchstone v2.0 keywords 🔜 Planned

🧪 Running Tests

dotnet test --verbosity normal

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.


📄 License

This project is licensed under the MIT License.


📚 Resources


<p align="center"> <em>Built for the RF/microwave engineering community</em> 📡 </p>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 103 4/22/2026
0.1.0 100 4/20/2026
0.0.0-main.3b27d58 52 4/20/2026