MicrowaveNetworks 1.2.1

dotnet add package MicrowaveNetworks --version 1.2.1
NuGet\Install-Package MicrowaveNetworks -Version 1.2.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="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MicrowaveNetworks --version 1.2.1
#r "nuget: MicrowaveNetworks, 1.2.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.
// Install MicrowaveNetworks as a Cake Addin
#addin nuget:?package=MicrowaveNetworks&version=1.2.1

// Install MicrowaveNetworks as a Cake Tool
#tool nuget:?package=MicrowaveNetworks&version=1.2.1

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 format version 1.0
  • Cascading/embedding/de-embedding 2-port networks
  • S and T parameters

Future/In Development Features

  • Full support for Touchstone file format version 2.0
  • 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.

TouchstoneWriterSettings settings = new TouchstoneWriterSettings
{
    IncludeColumnNames = true,
    NumericFormatString = "G3"
};

using (TouchstoneWriter writer = TouchstoneWriter.Create(@"C:\example_data.s2p", settings))
{
    writer.Options.FrequencyUnit = FrequencyUnit.GHz;

    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();

    foreach (FrequencyParametersPair pair in exampleData)
        writer.WriteData(pair);
}
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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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.2.1 70 6/22/2024
1.2.0 7,686 10/4/2022
1.1.4 700 6/21/2022
1.1.3 523 6/3/2022
1.1.2 764 4/5/2022
1.1.1 1,362 12/1/2021
1.1.0 321 10/7/2021
1.0.3 311 5/28/2021
1.0.2 319 5/28/2021
1.0.1 333 5/28/2021
1.0.0 309 5/24/2021