skrf.io.touchstone.Touchstone.__init__

Touchstone.__init__(file, encoding=None)[source]

constructor

Parameters:
  • file (str or file-object) – touchstone file to load

  • encoding (str, optional) – define the file encoding to use. Default value is None, meaning the encoding is guessed (ANSI, UTF-8 or Latin-1).

Examples

From filename

>>> t = rf.Touchstone('network.s2p')

File encoding can be specified to help parsing the special characters:

>>> t = rf.Touchstone('network.s2p', encoding='ISO-8859-1')

From file-object

>>> file = open('network.s2p')
>>> t = rf.Touchstone(file)

From a io.StringIO object

>>> link = 'https://raw.githubusercontent.com/scikit-rf/scikit-rf/master/examples/
    basic_touchstone_plotting/horn antenna.s1p'
>>> r = requests.get(link)
>>> stringio = io.StringIO(r.text)
>>> stringio.name = 'horn.s1p'  # must be provided for the Touchstone parser
>>> horn = rf.Touchstone(stringio)