Touchstone.Parser
1.0.1
dotnet add package Touchstone.Parser --version 1.0.1
NuGet\Install-Package Touchstone.Parser -Version 1.0.1
<PackageReference Include="Touchstone.Parser" Version="1.0.1" />
<PackageVersion Include="Touchstone.Parser" Version="1.0.1" />
<PackageReference Include="Touchstone.Parser" />
paket add Touchstone.Parser --version 1.0.1
#r "nuget: Touchstone.Parser, 1.0.1"
#:package Touchstone.Parser@1.0.1
#addin nuget:?package=Touchstone.Parser&version=1.0.1
#tool nuget:?package=Touchstone.Parser&version=1.0.1
Touchstone.Parser
A .NET library for Touchstone
.sNpparsing and S‑parameter analysis in RF/microwave engineering.
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
.sNpfiles 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 support —
ParseAsync()with cancellation token - Cross-platform — targets
net6.0andnetstandard2.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 | Versions 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. |
-
.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 |
See https://github.com/suryakantamangaraj/touchstone-dotnet/blob/main/CHANGELOG.md for release notes.