touchstone: For Touchstone VNA files

An extractors for data in Touchstone formats.

yadg.extractors.touchstone.snp module

This module parses Touchstone files conforming to the Touchstone File Specification, revision 1.1.

Note

Currently only 1- and 2-port (i.e. .s1p and .s2p) files are supported.

Usage

Available since yadg-5.1.

pydantic model dgbowl_schemas.yadg.dataschema_6_0.filetype.Touchstone_snp
Config:
  • extra: str = forbid

Validators:

field filetype: Literal['touchstone.snp'] [Required]

Schema

xarray.DataTree:
  {{ parameter_name }}                  # S11, S21, etc. for scattering parameters
    coords:
      uts:            !!float           # Unix timestamp, optional
      frequency:      !!float           #
    data_vars:
      real:           (uts, frequency)  # Real part of the response
      imag:           (uts, frequency)  # Imagunary part of the response
      magnitude:      (uts, frequency)  # Magnitude of the response
      phase_angle:    (uts, frequency)  # Phase angle of the response

Metadata

Metadata about the device are inferred from the structure of the comments lines, see below. In most circumstances, the following information can be provided:

  • Ref R: the reference resistance (in Ohms)

  • Model: model number of the network analyseer

  • Serial: serial number of the device

  • Software Version: software version with which the file was created

Note

The timestamp (uts) is also parsed from the comments in the file. In case you have Touchstone files with a well-defined header that is not supported by yadg, please open an issue.

Uncertainties

Uncertainties in all variables are determined from the precision of the string-to-float conversion.

Notes on file structure

The Touchstone .sNp files are composed of four sections:

  • options line, denoted by #

  • any number of comments lines, denoted by !

  • data lines

  • a noise parameters section, delimited by ! NOISE PARAMETERS

Currently, only the first three sections are parsed.

Code author: Peter Kraus

yadg.extractors.touchstone.snp.process_filename(filename: str) dict
yadg.extractors.touchstone.snp.process_options(line: str) dict
yadg.extractors.touchstone.snp.attr_in_lines(attr: str, lines: list[str], sep: str = ':') dict
yadg.extractors.touchstone.snp.process_comments(lines: list[str], tz: str) dict
yadg.extractors.touchstone.snp.data_to_dataset(key: str, data: dict) Dataset
yadg.extractors.touchstone.snp.extract(*, fn: str, encoding: str, timezone: str, locale: str, **kwargs: dict) DataTree