MicrowaveNetworks 2.0.1
dotnet add package MicrowaveNetworks --version 2.0.1
NuGet\Install-Package MicrowaveNetworks -Version 2.0.1
<PackageReference Include="MicrowaveNetworks" Version="2.0.1" />
<PackageVersion Include="MicrowaveNetworks" Version="2.0.1" />
<PackageReference Include="MicrowaveNetworks" />
paket add MicrowaveNetworks --version 2.0.1
#r "nuget: MicrowaveNetworks, 2.0.1"
#:package MicrowaveNetworks@2.0.1
#addin nuget:?package=MicrowaveNetworks&version=2.0.1
#tool nuget:?package=MicrowaveNetworks&version=2.0.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 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 | Versions 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. |
-
.NETFramework 4.7.2
- MathNet.Numerics (>= 4.15.0)
- Microsoft.Bcl.AsyncInterfaces (>= 5.0.0)
-
net5.0
- MathNet.Numerics (>= 4.15.0)
-
net8.0
- MathNet.Numerics (>= 4.15.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.