ansys/pyaedt

Add get_touchstone_data_formatted()

Closed this issue · 2 comments

Description of the feature

It would be great to have a feature (if there isn't already one) where you can get just the touchstone data that you would see when exporting to a touchstone file.

Currently, Circuit.get_touchstone_data() gives data that is nested fairly deeply inside an object. If I have some circuit, I can grab the first dataset like so:

with Circuit(...) as cir:
    touchstone_data = cir.get_touchstone_data()[0]

In order to assemble the same data that would be written to file (for just a 1-port network), I need to do this to get the S parameters:

s_data = [touchstone_datum.s11.s_mag[0][0][0] for touchstone_datum in touchstone_data]

Then after that, I would need to format it like the touchstone file to make the data consumable by existing codes. Is there a better way of doing this, or should I just deal with it and either write my own parser/formatter or just output to file?

Steps for implementing the feature

I am not quite sure, because I don't know how your export touchstone works on the backend. If there is an easy way to hold in memory the data you output to file when exporting the touchstone, it would be great to expose that to the user.

Useful links and references

No response

Example touchstone file:
! Touchstone file exported from Circuit Design 2023.2.0
! File: some_file.aedt
! Generated: 9:07:05 PM Oct 06, 2022
! Design: fancy_design
! Project: circuit
! Setup: MySetupAuto
! Solution: MySetupAuto
!
# GHz S MA R 50.000000
! Terminal data exported
! Port[1] = Port1
7.003 0.96153 -111.353490917705
! Gamma 0 0
! Port Impedance 50 0
7.0030001 0.90703 -111.384298782215
! Gamma 0 0
! Port Impedance 50 0
7.0030002 0.917335 -111.415123658908
! Gamma 0 0
! Port Impedance 50 0
7.0030003 0.9875 -111.445965557382
! Gamma 0 0
! Port Impedance 50 0
7.0030004 0.945311 -115.476824487238
! Gamma 0 0
! Port Impedance 50 0
7.0030005 0.995 -111.507700458137
! Gamma 0 0
! Port Impedance 50 0
7.0030006 0.9776224 -111.53859347968

Nevermind, I see the data in touchstone_data.s_mag. Thanks and sorry for the noise!