Hello all,

I'm trying to read RF touchstone (.s2p) files that are in a format like so:

Freq(MHz)  MagS11  AngS11  MagS21  AngS21   MagS12  AngS12   MagS22  AngS22
100         0.588   50.208  0.770   -35.964  0.770   -35.964  0.588   50.208
...
200         0.589   51.209  1.771   -34.965  1.771   -34.965  1.589   51.209

There are thousands of these lines in a file, one line for each measured 
frequency.  Each line represents a complex scattering (S-parameter) matrix 
and the mag/angle format needs to be converted to a `cdouble` to work on 
the matrix mathematically.

A single-line 2x2 complex matrix might look as follows, where S_ji is a 
complex value:

 [ S11  S12 ]
 [ S21  S22 ]

Since we are provided values in magnitude-angle format (in this example) 
they must be converted to cdoubles so we can work on them.  There are 
several formats: RI, DB, and MA.  For the MA (mag-angle) format this is 
the transform where $a is mag and $b is angle:

        $complex = cos($b*pi()/180) + $a*sin($b*pi()/180) * i

I can generate a vector of 2x4 matrices holding mag-angle pairs by reading 
the file line by line like this:

[
  [
   [ S11mag S11ang S12mag S12ang ]
   [ S21mag S21ang S22mag S22ang ]
  ]
  ... for each line
]

I'm new to using PDL and at this point I'm not sure how to convert them to 
a computable form. Since the mag/angle values need to be manipulated in 
parallel before creating a cdouble out of them I'm not sure how to go 
about this.

Here are my questions:

1. How can I efficiently apply the 
     real = cos($b*pi()/180)
     imag = $a*sin($b*pi()/180)
   transform to each mag/angle pair where $a is mag and $b is angle?

2. How can I then (or simultaneously) convert the 2x4 real-imag matrix 
   from #1 into a 2x2 cdouble matrix to look something like this?

        [
          [
           [ S11  S12 ]
           [ S21  S22 ]
          ]
          ... for each line where Sji are cdoubles
        ]

3. Now that I've described the issue, is there a better way to do this?


Once they are in a matrix format then PDL can convert them efficiently to 
other matrix types (T, A, Z, Y) to create parallel or series circuits with 
matrix arithmetic at each frequency.  We can then optimize the RF filter 
circuits using component models published by manufacturers from actual 
measurements.

The resulting open-source tool will be comprised of Perl modules from this 
work and published on CPAN.

Thanks for your help!

--
Eric Wheeler
KJ7LNW


_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to