MicrowaveNetworks 2.0.1

dotnet add package MicrowaveNetworks --version 2.0.1
                    
NuGet\Install-Package MicrowaveNetworks -Version 2.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="MicrowaveNetworks" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MicrowaveNetworks" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MicrowaveNetworks" />
                    
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 MicrowaveNetworks --version 2.0.1
                    
#r "nuget: MicrowaveNetworks, 2.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 MicrowaveNetworks@2.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=MicrowaveNetworks&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MicrowaveNetworks&version=2.0.1
                    
Install as a Cake Tool

Microwave Networks

A C# library implementing common tools for working with microwave networks including reading/writing to Touchstone (.snp) files, de/embedding network parameters, etc. Download:

Currently Supported Features

  • Full support for Touchstone file formats version 1.0 and 2.0
  • Cascading/embedding/de-embedding 2-port networks
  • S and T parameters

Future/In Development Features

  • Cascading n-port networks using the symmetry extension method
  • Other parameter types (admittance, impedance, etc.)
  • Interpolation

Examples

Network Data

Create a Two-Port S-Parameters Matrix
// Simple "ideal" 3 dB attenuator at some frequency with an excellent match
ScatteringParametersMatrix atten = new ScatteringParametersMatrix(numPorts: 2)
{
    [1, 1] = NetworkParameter.FromPolarDecibelDegree(-50, 0),
    [1, 2] = NetworkParameter.FromPolarDecibelDegree(-3, 0),
    [2, 1] = NetworkParameter.FromPolarDecibelDegree(-3, 0),
    [2, 2] = NetworkParameter.FromPolarDecibelDegree(-50, 0)
};
Create Frequency-Dependent Network Data
NetworkParameter ten_dBLoss = NetworkParameter.FromPolarDecibelDegree(-10, 0);
var exampleData = new NetworkParametersCollection<ScatteringParametersMatrix>(2)
{
    // Create a new 2-port S-parameter matrix, and set S21 to a scalard 10 dB loss.
    [1.0e9] = new ScatteringParametersMatrix(2) { [2, 1] = ten_dBLoss },
    // Alternatively, can index the frequency and specific matrix index all at once
    // i.e. at 2 GHz, set S21 to -10 dB
    [2.0e9, 2, 1] = ten_dBLoss,
    // etc.
    [5.0e9, 2, 1] = ten_dBLoss
};

Touchstone Files

Simple File IO

Reading All Touchstone Data From a File
INetworkParametersCollection coll = Touchstone.ReadAllData(@"C:\example.s2p");
foreach (FrequencyParametersPair pair in coll)
{
    (double frequency, NetworkParametersMatrix matrix) = pair;
    double insertionLoss = matrix[2, 1].Magnitude_dB;
    Console.WriteLine($"Insertion loss at {frequency} is {insertionLoss} dB");
}
Writing All Touchstone Data to a File

This example uses the exampleData collection shown in Create Frequency-Dependent Network Data.

// Create a new Touchstone file with all default settings
Touchstone tsFile = new Touchstone(exampleData);
tsFile.Write(@"C:\example_data.s2p");

Advanced File IO

Enumerating/Filtering Touchstone Data with LINQ

Rather than loading all of the data into memory, the following example enumerates each matrix one at a time from a file to allow for runtime manipulation without allocating unnecessary memory.

string path = @"C:\example.s2p";
var filteredInsertionLoss = from FrequencyParametersPair pair in Touchstone.ReadData(path)
                            where pair.Frequency_Hz > 2.0e9 && pair.Frequency_Hz < 5.0e9
                            let InsertionLoss_dB = pair.Parameters[2, 1].Magnitude_dB
                            select new { pair.Frequency_Hz, InsertionLoss_dB };
Streaming Touchstone Data to a File

The TouchstoneWriter and TouchstoneReader classes allow for precise control over Touchstone File IO, including full support for asynchronous file operations. This example uses the exampleData collection shown in Create Frequency-Dependent Network Data.

Touchstone sample = Touchstone.Create<ScatteringParametersMatrix>(4, 50);
			
// Fill file with data

TouchstoneWriterSettings settings = new TouchstoneWriterSettings
{
	IncludeColumnNames = true,
	NumericFormatString = "G3",
	FileVersion = TouchstoneFileVersion.Two,
	FrequencyUnit = TouchstoneFrequencyUnit.GHz
};

using (TouchstoneWriter writer = TouchstoneWriter.Create(@"C:\example_data.s2p", sample, settings))
{
	writer.WriteCommentLine("This is an example comment at the top of the file.");
	// The header will be written automatically if not called manually as soon as the first call is made to WriteData(). 
	// However, you can manually invoke this if you would like to control where it is placed in relation to other comments.
	writer.WriteHeader();

	writer.WriteCommentLine("Now the network data begins");

	writer.WriteNetworkData();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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 Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.1 123 1/12/2026
2.0.0 241 6/20/2025
1.2.1 532 6/22/2024
1.2.0 11,287 10/4/2022
1.1.4 932 6/21/2022
1.1.3 698 6/3/2022
1.1.2 956 4/5/2022
1.1.1 1,584 12/1/2021
1.1.0 538 10/7/2021
1.0.3 524 5/28/2021
1.0.2 505 5/28/2021
1.0.1 548 5/28/2021
1.0.0 496 5/24/2021