Skip to content

RF-Touchstone

A Javascript/TypeScript library for reading, manipulating, and writing Touchstone files (.snp files) used in radio frequency (RF) and microwave engineering.

TestsCoverage

Overview

RF-Touchstone provides a complete solution for working with S-parameters and other network parameters in JavaScript/TypeScript environments. This library allows you to:

  • Read and parse Touchstone files (.s1p, .s2p, .s3p, etc.)
  • Manipulate network parameter data
  • Write data back to Touchstone format
  • Convert between different parameter representations (RI, MA, DB)

What is a Touchstone File?

Touchstone files are an industry-standard ASCII text format for representing network parameters of electrical circuits. Each file contains:

  • Comments (lines starting with !)
  • Option line (starts with #) specifying frequency units, parameter type, and data format
  • Network parameter data organized by frequency points

RF-Touchstone currently supports versions 1.0 and 1.1 of the Touchstone specification.

Key Features

  • Full support for Touchstone file format (v1.0 and v1.1)
  • Parameter type support: S, Y, Z, G, H
  • Format conversions: RI (Real/Imaginary), MA (Magnitude/Angle), DB (Decibel/Angle)
  • TypeScript implementation with strong typing
  • Comprehensive test suite

Installation

bash
npm install rf-touchstone
# or
yarn add rf-touchstone

Quick Start

typescript
import { Touchstone } from 'rf-touchstone'

// Read a Touchstone file
const touchstone = new Touchstone()
touchstone.readContent(fileContent, 2) // assuming a 2-port network

// Access data
const frequencies = touchstone.frequency.f_scaled
const sParameters = touchstone.matrix

// Write back to Touchstone format
const newContent = touchstone.writeContent()

Documentation

For detailed documentation, please visit:

Development

For information on setting up a development environment and contributing to the project, see development.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.