Reference

Touchstone.TouchstoneFileType
TouchstoneFile(f::Vector{Float64},
    N::Array{Complex{Float64}},
    frequencyunit::String,
    parameter::String,
    format::String,
    R::Float64,
    version::Float64,
    numberofports::Int,
    twoportdataorder::String,
    numberoffrequencies::Int,
    numberofnoisefrequencies::Int,
    reference::Vector{Float64},
    information::Vector{String},
    matrixformat::String,
    mixedmodeorder::Vector{Tuple{Char, Vector{Int}}},
    comments::Vector{String},
    networkdata::Vector{Float64},
    noisedata::Vector{Float64})

A structure to hold the data contained in a Touchstone file. In most cases, the user will not generate the struct directly. Instead, they will load a Touchstone file with touchstone_load, parse an IOStream or IOBuffer with touchstone_parse, or generate a TouchstoneFile struct with touchstone_file.

Touchstone.arraytonetworkdataMethod
arraytonetworkdata(frequencies,N, numberofports, numberoffrequencies,
    matrixformat, twoportdataorder, parameter, frequencyunit, format, R,
    version)

Return a vector with a frequency followed by the network data parameters for that frequency.

Examples

frequencies = 4.0e9:5.0e8:6.0e9
N = [0.9546262517670427 - 0.296397700700921im;;; 0.8915960960938982 - 0.44358732281729774im;;; 0.9857309246425359 + 0.046691189499470154im;;; 0.9759591344506418 - 0.21128542054786678im;;; 0.9604441706426364 - 0.2762239892126382im]
numberofports = 1
numberoffrequencies = 5
matrixformat = "Full"
twoportdataorder = "12_21"
parameter = "S"
frequencyunit = "GHz"
format = "MA"
R = 50.0
version = 2.0
Touchstone.arraytonetworkdata(frequencies,N, numberofports, numberoffrequencies, 
    matrixformat, twoportdataorder, parameter, frequencyunit, format, R, version)

# output
15-element Vector{Float64}:
   4.0
   0.9995813511383583
 -17.248815971093425
   4.5
   0.9958480363660398
 -26.451285931791276
   5.0
   0.9868361175866559
   2.711906450972103
   5.5
   0.9985678550072272
 -12.21545548845392
   6.0
   0.9993761539770525
 -16.045248853866596
frequencies = 4.0e9:5.0e8:6.0e9
N = [0.9546262517670427 - 0.296397700700921im;;; 0.8915960960938982 - 0.44358732281729774im;;; 0.9857309246425359 + 0.046691189499470154im;;; 0.9759591344506418 - 0.21128542054786678im;;; 0.9604441706426364 - 0.2762239892126382im]
numberofports = 1
numberoffrequencies = 5
matrixformat = "Lower"
twoportdataorder = "12_21"
parameter = "Z"
frequencyunit = "GHz"
format = "MA"
R = 50.0
version = 2.0
Touchstone.arraytonetworkdata(frequencies,N, numberofports,
    numberoffrequencies, matrixformat, twoportdataorder, parameter,
    frequencyunit, format, R, version)

# output
15-element Vector{Float64}:
   4.0
   0.9995813511383583
 -17.248815971093425
   4.5
   0.9958480363660398
 -26.451285931791276
   5.0
   0.9868361175866559
   2.711906450972103
   5.5
   0.9985678550072272
 -12.21545548845392
   6.0
   0.9993761539770525
 -16.045248853866596
frequencies = 4.0e9:5.0e8:6.0e9
N = [0.9546262517670427 - 0.296397700700921im;;; 0.8915960960938982 - 0.44358732281729774im;;; 0.9857309246425359 + 0.046691189499470154im;;; 0.9759591344506418 - 0.21128542054786678im;;; 0.9604441706426364 - 0.2762239892126382im]
numberofports = 1
numberoffrequencies = 5
matrixformat = "Lower"
twoportdataorder = "12_21"
parameter = "Z"
frequencyunit = "GHz"
format = "MA"
R = 50.0
version = 1.0
Touchstone.arraytonetworkdata(frequencies,N, numberofports,
    numberoffrequencies, matrixformat, twoportdataorder, parameter,
    frequencyunit, format, R, version)

# output
15-element Vector{Float64}:
   4.0
   0.019991627022767165
 -17.248815971093425
   4.5
   0.019916960727320795
 -26.451285931791276
   5.0
   0.01973672235173312
   2.7119064509721027
   5.5
   0.019971357100144544
 -12.215455488453918
   6.0
   0.019987523079541047
 -16.0452488538666
Touchstone.frequencyscaleMethod
frequencyscale(frequencyunit::String)

Convert the SI prefix in the string frequencyunit to the corresponding numerical value.

Examples

julia> Touchstone.frequencyscale("MHz")
1.0e6
Touchstone.isbegininformationMethod
isbegininformation(line::String)

Return true if the string line is the [begin information] line of a Touchstone file.

Examples

julia> Touchstone.isbegininformation("[begin information]")
true

julia> Touchstone.isbegininformation("[version] 1.0")
false
Touchstone.isendMethod
isend(line::String)

Return true if the string line is the [end] line of a Touchstone file.

Examples

julia> Touchstone.isend("[end]")
true

julia> Touchstone.isend("[version] 1.0")
false
Touchstone.isendinformationMethod
isendinformation(line::String)

Return true if the string line is the [end information] line of a Touchstone file.

Examples

julia> Touchstone.isendinformation("[end information]")
true

julia> Touchstone.isendinformation("[version] 1.0")
false
Touchstone.ismatrixformatMethod
ismatrixformat(line::String)

Return true if the string line is the [matrix format] line of a Touchstone file.

Examples

julia> Touchstone.ismatrixformat("[matrix format] full")
true

julia> Touchstone.ismatrixformat("[version] 1.0")
false
Touchstone.ismixedmodeorderMethod
ismixedmodeorder(line::String)

Return true if the string line is the [mixed-mode order] line of a Touchstone file.

Examples

julia> Touchstone.ismixedmodeorder("[mixed-mode order] full")
true

julia> Touchstone.ismixedmodeorder("[version] 1.0")
false
Touchstone.isnetworkdataMethod
isnetworkdata(line::String)

Return true if the string line is the [network data] line of a Touchstone file.

Examples

julia> Touchstone.isnetworkdata("[network data]")
true

julia> Touchstone.isnetworkdata("[version] 1.0")
false
Touchstone.isnoisedataMethod
isnoisedata(line::String)

Return true if the string line is the [noise data] line of a Touchstone file.

Examples

julia> Touchstone.isnoisedata("[noise data]")
true

julia> Touchstone.isnoisedata("[version] 1.0")
false
Touchstone.isnumberoffrequenciesMethod
isnumberoffrequencies(line::String)

Return true if the string line is the [number of frequencies] line of a Touchstone file.

Examples

julia> Touchstone.isnumberoffrequencies("[number of frequencies]")
true

julia> Touchstone.isnumberoffrequencies("[version] 1.0")
false
Touchstone.isnumberofnoisefrequenciesMethod
isnumberofnoisefrequencies(line::String)

Return true if the string line is the [number of noise frequencies] line of a Touchstone file.

Examples

julia> Touchstone.isnumberofnoisefrequencies("[number of noise frequencies]")
true

julia> Touchstone.isnumberofnoisefrequencies("[version] 1.0")
false
Touchstone.isnumberofportsMethod
isnumberofports(line::String)

Return true if the string line is the [number of ports] line of a Touchstone file.

Examples

julia> Touchstone.isnumberofports("[number of ports] 1")
true

julia> Touchstone.isnumberofports("[version] 1.0")
false
Touchstone.isoptionlineMethod
isoptionline(line::String)

Return true if the string line is the option line of a Touchstone file.

Examples

julia> Touchstone.isoptionline("# MHz Z MA R 75")
true

julia> Touchstone.isoptionline("[number of ports] 1")
false
Touchstone.isreferenceMethod
isreference(line::String)

Return true if the string line is the [reference] line of a Touchstone file.

Examples

julia> Touchstone.isreference("[reference]")
true

julia> Touchstone.isreference("[version] 1.0")
false
Touchstone.istwoportdataorderMethod
istwoportdataorder(line::String)

Return true if the string line is the [two-port data order] line of a Touchstone file.

Examples

julia> Touchstone.istwoportdataorder("[two-port data order] 12_21")
true

julia> Touchstone.istwoportdataorder("[version] 1.0")
false
Touchstone.isversionMethod
isversion(line::String)

Return true if the string line is the [version] line of a Touchstone file.

Examples

julia> Touchstone.isversion("[version] 1.0")
true

julia> Touchstone.isversion("[number of ports] 1")
false
Touchstone.matrixindicesMethod
matrixindices(nports, format, twoportdataorder)

Return the cartesian indices of the elements of a scattering matrix given the number of ports nports and the format format which can be "Full", "Upper", or "Lower". The two port data order twoportdataorder can be "12_21" or "21_12" for 2 ports but must be "12_21" for other numbers of ports.

Examples

julia> Touchstone.matrixindices(2,"Full","12_21")
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(1, 2)
 CartesianIndex(2, 1)
 CartesianIndex(2, 2)

julia> Touchstone.matrixindices(2,"Full","21_12")
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)
 CartesianIndex(1, 2)
 CartesianIndex(2, 2)
Touchstone.matrixindicesMethod
matrixindices(nports, format)

Return the cartesian indices of the elements of a scattering matrix given the number of ports nports and the format format which can be "Full", "Upper", or "Lower".

Examples

julia> Touchstone.matrixindices(2,"Full",printflag=true)
11 12 
21 22 
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(1, 2)
 CartesianIndex(2, 1)
 CartesianIndex(2, 2)

julia> Touchstone.matrixindices(2,"Upper",printflag=true)
11 12 
   22 
      3-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(1, 2)
 CartesianIndex(2, 2)

julia> Touchstone.matrixindices(2,"Lower",printflag=true)
11 
21 22 
3-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)
 CartesianIndex(2, 2)
Touchstone.networkdatatoarrayMethod
networkdatatoarray(networkdata, numberofports, numberoffrequencies,
    matrixformat, twoportdataorder, parameter, frequencyunit, format, R,
    version)

Examples

networkdata = [4.0, 0.9995813511383583, -17.248815971093425, 4.5, 0.9958480363660398, -26.451285931791276, 5.0, 0.9868361175866559, 2.711906450972103, 5.5, 0.9985678550072272, -12.21545548845392, 6.0, 0.9993761539770525, -16.045248853866596]
numberofports = 1
numberoffrequencies = 5
matrixformat = "Full"
twoportdataorder = "12_21"
parameter = "s"
frequencyunit = "ghz"
format = "ma"
R = 50.0
version = 2.0
frequencies, N = Touchstone.networkdatatoarray(networkdata,
    numberofports, numberoffrequencies, matrixformat, twoportdataorder,
    parameter, frequencyunit, format, R, version)
println(frequencies)
println(N[1,1,:])

# output
[4.0e9, 4.5e9, 5.0e9, 5.5e9, 6.0e9]
ComplexF64[0.9546262517670427 - 0.296397700700921im, 0.8915960960938982 - 0.44358732281729774im, 0.9857309246425359 + 0.04669118949947016im, 0.9759591344506418 - 0.21128542054786678im, 0.9604441706426364 - 0.2762239892126382im]
Touchstone.parseinformation!Method
parseinformation!(information::Vector{String},io::IO)

Append the contents of the information section of a Touchstone file from the IOBuffer or IOStream io to the vector information.

Examples

information = String[]
comments = String[]
io = IOBuffer("This is an information section.
[End Information]")
Touchstone.parseinformation!(information,comments,io)
println(information)

# output
["this is an information section."]
Touchstone.parsematrixformatMethod
parsematrixformat(line::String)

Return the two-port data order string parsed from the [two-port data order] line of a Touchstone file.

Examples

julia> Touchstone.parsematrixformat("[matrix format] lower")
"Lower"

julia> Touchstone.parsematrixformat("[matrix format] upper")
"Upper"
Touchstone.parsemixedmodeorder!Method
parsemixedmodeorder!(mixedmodeorder::Vector{Tuple{Char, Vector{Int}}},
    line::String)

Append the contents of the [mixed-mode order] line of a Touchstone file from the to the vector mixedmodeorder.

Examples

julia> mixedmodeorder = Tuple{Char, Vector{Int}}[];Touchstone.parsemixedmodeorder!(mixedmodeorder,"[Mixed-Mode Order] D2,3 D6,5 C2,3 C6,5 S4 S1");mixedmodeorder
6-element Vector{Tuple{Char, Vector{Int64}}}:
 ('D', [2, 3])
 ('D', [6, 5])
 ('C', [2, 3])
 ('C', [6, 5])
 ('S', [4])
 ('S', [1])
Touchstone.parsenetworkdata!Method
parsenetworkdata!(networkdata::Vector{Float64}, comments::Vector{String}, io::IO)

Append the contents of the networkdata section of a Touchstone file from the IOBuffer or IOStream io to the vector networkdata.

Examples

networkdata = Float64[]
comments = String[]
io = IOBuffer("1.0000 0.3926 -0.1211 -0.0003 -0.0021 -0.0003 -0.0021 0.3926 -0.1211
2.0000 0.3517 -0.3054 -0.0096 -0.0298 -0.0096 -0.0298 0.3517 -0.3054
10.000 0.3419 0.3336 -0.0134 0.0379 -0.0134 0.0379 0.3419 0.3336")
Touchstone.parsenetworkdata!(networkdata,comments,io)
println(networkdata)

# output
[1.0, 0.3926, -0.1211, -0.0003, -0.0021, -0.0003, -0.0021, 0.3926, -0.1211, 2.0, 0.3517, -0.3054, -0.0096, -0.0298, -0.0096, -0.0298, 0.3517, -0.3054, 10.0, 0.3419, 0.3336, -0.0134, 0.0379, -0.0134, 0.0379, 0.3419, 0.3336]
networkdata = Float64[]
comments = String[]
io = IOBuffer("2 .95 -26 3.57 157 .04 76 .66 -14
22 .60 -144 1.30 40 .14 40 .56 -85
! NOISE PARAMETERS
4 .7 .64 69 .38
18 2.7 .46 -33 .40")
Touchstone.parsenetworkdata!(networkdata,comments,io)
println(networkdata)

# output
[2.0, 0.95, -26.0, 3.57, 157.0, 0.04, 76.0, 0.66, -14.0, 22.0, 0.6, -144.0, 1.3, 40.0, 0.14, 40.0, 0.56, -85.0]
networkdata = Float64[]
comments = String[]
io = IOBuffer("2 .95 -26 3.57 157 .04 76 .66 -14
22 .60 -144 1.30 40 .14 40 .56 -85
[Noise Data]
4 .7 .64 69 19
18 2.7 .46 -33 20
[End]")
Touchstone.parsenetworkdata!(networkdata,comments,io)
println(networkdata)

# output
[2.0, 0.95, -26.0, 3.57, 157.0, 0.04, 76.0, 0.66, -14.0, 22.0, 0.6, -144.0, 1.3, 40.0, 0.14, 40.0, 0.56, -85.0]
Touchstone.parsenoisedata!Method
parsenoisedata!(noisedata::Vector{Float64}, comments::Vector{String},
    io::IO)

Append the contents of the networkdata section of a Touchstone file from the IOBuffer or IOStream io to the vector networkdata.

Examples

networkdata = Float64[]
noisedata = Float64[]
comments = String[]
io = IOBuffer("1.0000 0.3926 -0.1211 -0.0003 -0.0021 -0.0003 -0.0021 0.3926 -0.1211
2.0000 0.3517 -0.3054 -0.0096 -0.0298 -0.0096 -0.0298 0.3517 -0.3054
10.000 0.3419 0.3336 -0.0134 0.0379 -0.0134 0.0379 0.3419 0.3336")
Touchstone.parsenetworkdata!(networkdata,comments,io)
Touchstone.parsenoisedata!(noisedata,comments,io)
println(noisedata)

# output
Float64[]
networkdata = Float64[]
noisedata = Float64[]
comments = String[]
io = IOBuffer("2 .95 -26 3.57 157 .04 76 .66 -14
22 .60 -144 1.30 40 .14 40 .56 -85
! NOISE PARAMETERS
4 .7 .64 69 .38
18 2.7 .46 -33 .40")
Touchstone.parsenetworkdata!(networkdata,comments,io)
Touchstone.parsenoisedata!(noisedata,comments,io)
println(noisedata)

# output
[4.0, 0.7, 0.64, 69.0, 0.38, 18.0, 2.7, 0.46, -33.0, 0.4]
networkdata = Float64[]
noisedata = Float64[]
comments = String[]
io = IOBuffer("2 .95 -26 3.57 157 .04 76 .66 -14
22 .60 -144 1.30 40 .14 40 .56 -85
[Noise Data]
4 .7 .64 69 19
18 2.7 .46 -33 20
[End]")
Touchstone.parsenetworkdata!(networkdata,comments,io)
Touchstone.parsenoisedata!(noisedata,comments,io)
println(noisedata)

# output
[4.0, 0.7, 0.64, 69.0, 19.0, 18.0, 2.7, 0.46, -33.0, 20.0]
Touchstone.parsenumberoffrequenciesMethod
parsenumberoffrequencies(line::String)

Return the number of frequencies parsed from the [number of frequencies] line of a Touchstone file.

Examples

julia> Touchstone.parsenumberoffrequencies("[number of frequencies] 10")
10
Touchstone.parsenumberofnoisefrequenciesMethod
parsenumberofnoisefrequencies(line::String)

Return the number of noise frequencies parsed from the [number of noise frequencies] line of a Touchstone file.

Examples

julia> Touchstone.parsenumberofnoisefrequencies("[number of noise frequencies] 10")
10
Touchstone.parsenumberofportsMethod
parsenumberofports(line::String)

Return the number of ports parsed from the [number of ports] line of a Touchstone file.

Examples

julia> Touchstone.parsenumberofports("[number of ports] 1")
1
Touchstone.parseoptionlineMethod
parseoptionline(line::String)

Return a struct TouchstoneOptionLine which contains the option line of a Touchstone file.

Examples

julia> Touchstone.parseoptionline("# MHz Z MA R 75")
Touchstone.TouchstoneOptionLine("MHz", "Z", "MA", 75.0)

julia> Touchstone.parseoptionline("# MHz H RI R 75")
Touchstone.TouchstoneOptionLine("MHz", "H", "RI", 75.0)
Touchstone.parsereference!Method
parsereference!(reference::Vector{Float64}, comments::Vector{String},
    line::String, numberofports::Int, io::IO)

Append the contents of the [reference] section of a Touchstone file from the IOBuffer or IOStream io to the vector reference. The reference impedance values can be spread across multiple lines.

Examples

io = IOBuffer("[Reference] 50.0 60.0 75.0")
numberofports = 3
comments = String[]
reference = Float64[]
line = Touchstone.stripcommentslowercase!(comments,readline(io))
Touchstone.parsereference!(reference, comments, line, numberofports, io)
println(reference)

# output
[50.0, 60.0, 75.0]
io = IOBuffer("[Reference] 50.0 
60.0 75.0")
numberofports = 3
comments = String[]
reference = Float64[]
line = Touchstone.stripcommentslowercase!(comments,readline(io))
Touchstone.parsereference!(reference, comments, line, numberofports, io)
println(reference)

# output
[50.0, 60.0, 75.0]
io = IOBuffer("[Reference] 50.0 
60.0 75.0
[Number of Frequencies] 1")
numberofports = 3
comments = String[]
reference = Float64[]
line = Touchstone.stripcommentslowercase!(comments,readline(io))
Touchstone.parsereference!(reference, comments, line, numberofports, io)
println(reference)

# output
[50.0, 60.0, 75.0]
Touchstone.parsetwoportdataorderMethod
parsetwoportdataorder(line::String)

Return the two-port data order string parsed from the [two-port data order] line of a Touchstone file.

Examples

julia> Touchstone.parsetwoportdataorder("[two-port data order] 12_21")
"12_21"

julia> Touchstone.parsetwoportdataorder("[two-port data order] 21_12")
"21_12"
Touchstone.parseversionMethod
parseversion(line::String)

Return the version parsed from the [version] line of a Touchstone file.

Examples

julia> Touchstone.parseversion("[version] 1.0")
1.0
Touchstone.stripcommentslowercase!Method
stripcommentslowercase!(comments::Vector{String},line::String)

Append the comment portion of a line line of a Touchstone file to the vector comments. Return the line with the comments removed and made lowercase.

Examples

julia> comments=String[];println(Touchstone.stripcommentslowercase!(comments,"! This is a comment"));println(comments)

[" This is a comment"]

julia> comments=String[];println(Touchstone.stripcommentslowercase!(comments,"This is a !comment"));println(comments)
this is a 
["comment"]
Touchstone.touchstone_fileMethod
touchstone_file(f::Vector{Float64}, N::Array{Complex{Float64}};
    frequencyunit::String = "GHz",
    parameter::String = "S",
    format::String = "MA",
    R::Float64 = 50.0,
    version::Float64 = 2.0,
    twoportdataorder::String = "",
    numberofnoisefrequencies::Int = 0,
    reference::Vector{Float64} = Float64[],
    information::Vector{String} = String[],
    matrixformat::String = "Full",
    mixedmodeorder::Vector{Tuple{Char, Vector{Int}}} = Tuple{Char, Vector{Int}}[],
    comments::Vector{String} = String[],
    noisedata::Vector{Float64} = Float64[])

Generate a TouchstoneFile struct from the frequency vector f in units of Hz and the complex network data array N where the frequency axis is the last dimension. All other arguments are optional.

Touchstone.touchstone_loadMethod
touchstone_load(filename)

Read a file in the Touchstone format. Standard compliant.

References to the 1.1 spec and the 2.0 spec.

Outputs un-normalized network parameters with frequency units of Hz. Don't enforce any particular file extension or try to infer the number of ports from the extension.

Touchstone.touchstone_parseMethod
touchstone_parse(io::IO)

Parse the Touchstone file described by the IOBuffer or IOStream io.

References to the 1.1 spec and the 2.0 spec.

Examples

str="!Example 1:
!1-port S-parameter file, single frequency point
# MHz S MA R 50
!freq magS11 angS11
2.000 0.894 -12.136";
println(str);
Touchstone.touchstone_parse(IOBuffer(str))

# output
!Example 1:
!1-port S-parameter file, single frequency point
# MHz S MA R 50
!freq magS11 angS11
2.000 0.894 -12.136
Touchstone.TouchstoneFile([2.0e6], ComplexF64[0.874020294860635 - 0.18794819544685323im;;;], "mhz", "s", "ma", 50.0, 1.0, 1, "12_21", 1, 0, [50.0], String[], "Full", Tuple{Char, Vector{Int64}}[], ["Example 1:", "1-port S-parameter file, single frequency point", "freq magS11 angS11"], [2.0, 0.894, -12.136], Float64[])
str="!Example 4 (Version 2.0):
! 4-port S-parameter data
! Default impedance is overridden by [Reference]
! Data cannot be represented using 1.0 syntax
! Note that the [Reference] keyword arguments appear on a separate line
[Version] 2.0
# GHz S MA R 50
[Number of Ports] 4
[Reference]
50 75 0.01 0.01
[Number of Frequencies] 1
[Network Data]
5.00000 0.60 161.24 0.40 -42.20 0.42 -66.58 0.53 -79.34 !row 1
0.40 -42.20 0.60 161.20 0.53 -79.34 0.42 -66.58 !row 2
0.42 -66.58 0.53 -79.34 0.60 161.24 0.40 -42.20 !row 3
0.53 -79.34 0.42 -66.58 0.40 -42.20 0.60 161.24 !row 4";
println(str);
Touchstone.touchstone_parse(IOBuffer(str))

# output
!Example 4 (Version 2.0):
! 4-port S-parameter data
! Default impedance is overridden by [Reference]
! Data cannot be represented using 1.0 syntax
! Note that the [Reference] keyword arguments appear on a separate line
[Version] 2.0
# GHz S MA R 50
[Number of Ports] 4
[Reference]
50 75 0.01 0.01
[Number of Frequencies] 1
[Network Data]
5.00000 0.60 161.24 0.40 -42.20 0.42 -66.58 0.53 -79.34 !row 1
0.40 -42.20 0.60 161.20 0.53 -79.34 0.42 -66.58 !row 2
0.42 -66.58 0.53 -79.34 0.60 161.24 0.40 -42.20 !row 3
0.53 -79.34 0.42 -66.58 0.40 -42.20 0.60 161.24 !row 4
Touchstone.TouchstoneFile([5.0e9], ComplexF64[-0.5681244079815996 + 0.1929628385351877im 0.29632183851470006 - 0.2686882357291961im 0.16693665375723588 - 0.38539869438327984im 0.09803970583787712 - 0.5208533537179372im; 0.29632183851470006 - 0.2686882357291961im -0.5679895560694177 + 0.1933594171383067im 0.09803970583787712 - 0.5208533537179372im 0.16693665375723588 - 0.38539869438327984im; 0.16693665375723588 - 0.38539869438327984im 0.09803970583787712 - 0.5208533537179372im -0.5681244079815996 + 0.1929628385351877im 0.29632183851470006 - 0.2686882357291961im; 0.09803970583787712 - 0.5208533537179372im 0.16693665375723588 - 0.38539869438327984im 0.29632183851470006 - 0.2686882357291961im -0.5681244079815996 + 0.1929628385351877im;;;], "ghz", "s", "ma", 50.0, 2.0, 4, "12_21", 1, 0, [50.0, 75.0, 0.01, 0.01], String[], "Full", Tuple{Char, Vector{Int64}}[], ["Example 4 (Version 2.0):", " 4-port S-parameter data", " Default impedance is overridden by [Reference]", " Data cannot be represented using 1.0 syntax", " Note that the [Reference] keyword arguments appear on a separate line", "row 1", "row 2", "row 3", "row 4"], [5.0, 0.6, 161.24, 0.4, -42.2, 0.42, -66.58, 0.53, -79.34, 0.4  …  0.4, -42.2, 0.53, -79.34, 0.42, -66.58, 0.4, -42.2, 0.6, 161.24], Float64[])
Touchstone.touchstone_saveMethod
touchstone_save(filename::String,frequencies::AbstractArray,
    N::AbstractArray;version=1.0,reference=[50.0,50.0],R = 50.0,format="RI",
    comments=[""],twoportdataorder="12_21",matrixformat="Full",frequencyunit="Hz")

Write a file in the Touchstone format. Standards compliant except does not support writing noise data.

References to the 1.1 spec and the 2.0 spec.

Touchstone.touchstone_writeMethod
touchstone_write(io::IO, frequencies::AbstractVector, N::AbstractArray;
    version=1.0, reference=[50.0,50.0], R = 50.0, format="RI",
    parameter = "S", comments=[""], twoportdataorder="12_21",
    matrixformat="Full", frequencyunit="Hz")

Write a Touchstone file to the IOStream or IOBuffer io.

Examples

julia> io = IOBuffer();Touchstone.touchstone_write(io, [1.0e9, 2.0e9, 10.0e9], [0.3926 - 0.1211im -0.0003 - 0.0021im; -0.0003 - 0.0021im 0.3926 - 0.1211im;;; 0.3517 - 0.3054im -0.0096 - 0.0298im; -0.0096 - 0.0298im 0.3517 - 0.3054im;;; 0.3419 + 0.3336im -0.0134 + 0.0379im; -0.0134 + 0.0379im 0.3419 + 0.3336im];version=1.0,R=50.0,format="RI",frequencyunit="Hz",comments=["Example 4:","2-port S-parameter file, three frequency points"]);println(String(take!(io)))
!Example 4:
!2-port S-parameter file, three frequency points
# Hz S RI R 50.0
! freq ReS11 ImS11 ReS21 ImS21 ReS12 ImS12 ReS22 ImS22 
1.0e9 0.3926 -0.1211 -0.0003 -0.0021 -0.0003 -0.0021 0.3926 -0.1211
2.0e9 0.3517 -0.3054 -0.0096 -0.0298 -0.0096 -0.0298 0.3517 -0.3054
1.0e10 0.3419 0.3336 -0.0134 0.0379 -0.0134 0.0379 0.3419 0.3336

julia> io = IOBuffer();Touchstone.touchstone_write(io, [1.0e9, 2.0e9, 10.0e9], [0.3926 - 0.1211im -0.0003 - 0.0021im; -0.0003 - 0.0021im 0.3926 - 0.1211im;;; 0.3517 - 0.3054im -0.0096 - 0.0298im; -0.0096 - 0.0298im 0.3517 - 0.3054im;;; 0.3419 + 0.3336im -0.0134 + 0.0379im; -0.0134 + 0.0379im 0.3419 + 0.3336im];version=2.0,R=50.0,format="RI",frequencyunit="Hz",comments=["Example 4:","2-port S-parameter file, three frequency points"]);println(String(take!(io)))
!Example 4:
!2-port S-parameter file, three frequency points
[Version] 2.0
# Hz S RI R 50.0
[Number of Ports] 2
[Two-Port Data Order] 12_21
[Number of Frequencies] 3
[Reference] 50.0 50.0
[Network Data]
! freq ReS11 ImS11 ReS12 ImS12 ReS21 ImS21 ReS22 ImS22 
1.0e9 0.3926 -0.1211 -0.0003 -0.0021 -0.0003 -0.0021 0.3926 -0.1211
2.0e9 0.3517 -0.3054 -0.0096 -0.0298 -0.0096 -0.0298 0.3517 -0.3054
1.0e10 0.3419 0.3336 -0.0134 0.0379 -0.0134 0.0379 0.3419 0.3336
[End]
Touchstone.touchstone_writeMethod
touchstone_write(io::IO, ts::TouchstoneFile)

Write a Touchstone file specified by the TouchstoneFile object ts to the IOStream or IOBuffer io.