skrf.network.Network.write_touchstone

Network.write_touchstone(filename=None, dir=None, write_z0=False, skrf_comment=True, return_string=False, to_archive=None, form='ri', format_spec_A='{}', format_spec_B='{}', format_spec_freq='{}', r_ref=None)[source]

Write a contents of the Network to a touchstone file.

Parameters:
  • filename (a string, optional) – touchstone filename, without extension. if ‘None’, then will use the network’s name.

  • dir (string, optional) – the directory to save the file in.

  • write_z0 (boolean) – write impedance information into touchstone as comments, like Ansoft HFSS does

  • skrf_comment (bool, optional) – write created by skrf comment

  • return_string (bool, optional) – return the file_string rather than write to a file

  • to_archive (zipfile.Zipfile) – opened ZipFile object to place touchstone file in

  • form (string) – format to write data: ‘db’: db, deg. ‘ma’: mag, deg. ‘ri’: real, imag.

  • format_spec_A (string, optional) – Any valid format specifying string as given by https://docs.python.org/3/library/string.html#format-string-syntax This specifies the formatting in the resulting touchstone file for the A part of the S parameter, (e.g. the dB magnitude for ‘db’ format, the linear magnitude for ‘ma’ format, or the real part for ‘ri’ format)

  • format_spec_B (string, optional) – Any valid format specifying string as given by https://docs.python.org/3/library/string.html#format-string-syntax This specifies the formatting in the resulting touchstone file for the B part of the S parameter, (e.g. the angle in degrees for ‘db’ format, the angle in degrees for ‘ma’ format, or the imaginary part for ‘ri’ format)

  • format_spec_freq (string, optional) – Any valid format specifying string as given by https://docs.python.org/3/library/string.html#format-string-syntax This specifies the formatting in the resulting touchstone file for the frequency.

  • r_ref (float) – Reference impedance to renormalize the network. If None network port impedance is used if possible. If None and network port impedance is complex and not equal at all ports and frequency points raises ValueError.

Return type:

str | None

Note

Format supported at the moment are [Hz/kHz/MHz/GHz] S [DB/MA/RI] Frequency unit can be changed by setting Network.frequency.unit property

Note

The functionality of this function should take place in the Touchstone class.