IO

This Package provides functions and objects for input/output.

Reading and writing touchstone files is supported through the Touchstone class, which can be more easily used through the Network constructor, __init__()

The general functions read() and write() can be used to read and write [almost] any skrf object to disk, using the pickle module. This should only be used for temporary storage, because pickling is not stable over time, as skrf evolves.

touchstone (skrf.io.touchstone)

Touchstone class and utilities

Touchstone(file[, encoding])

Class to read touchstone s-parameter files.

general (skrf.io.general)

General input/output functions for reading and writing skrf objects

Pickle functions

The read/write methods use the pickle module. These should only be used for temporary storage.

read(file, *args, **kwargs)

Read skrf object[s] from a pickle file.

read_all([dir, sort, contains, f_unit, ...])

Read all skrf objects in a directory.

read_all_networks(*args, **kwargs)

Read all networks in a directory.

write(file, obj[, overwrite])

Write skrf object[s] to a file.

write_all(dict_objs[, dir])

Write a dictionary of skrf objects individual files in dir.

save_sesh(dict_objs[, file, module, ...])

Save all skrf objects in the local namespace.

Spreadsheets

network_2_spreadsheet(ntwk[, file_name, ...])

Write a Network object to a spreadsheet, for your boss.

networkset_2_spreadsheet(ntwkset[, ...])

Write a NetworkSet object to a spreadsheet, for your boss.

Pandas dataframe

network_2_dataframe(ntwk[, attrs, ports, ...])

Convert one or more attributes of a network to a pandas DataFrame.

Statistics

statistical_2_touchstone(file_name[, ...])

Converts Statistical file to a touchstone file.

JSON

TouchstoneEncoder(*[, skipkeys, ...])

Serializes Network object by converting arrays to lists, splitting complex numbers into real and imaginary, and breaking down frequency objects into dicts.

to_json_string(network)

Dumps Network to JSON string. Faster than converting and saving as touchstone. Safer than pickling (no arbitrary code execution on load). :param network: Network object A Network object to be serialized and returned as a JSON string. :return: str JSON string representation of a network object.

from_json_string(obj_string)

Loads network object from JSON string representation. :param obj_string: str JSON string representation of a network object. :return: Network object A Network object, rebuilt from JSON.

csv (skrf.io.csv)

Functions for reading and writing standard csv files

read_all_csv([dir, contains])

Read all CSV files in a directory.

AgilentCSV(filename, *args, **kwargs)

Agilent-style csv file representing either scalar traces vs frequency or complex data vs.

Reading/Writing Agilent

read_pna_csv(filename, *args, **kwargs)

Reads data from a csv file written by an Agilient PNA.

pna_csv_2_ntwks(filename)

Reads a PNAX csv file, and returns a list of one-port Networks.

pna_csv_2_ntwks3(filename)

Read a CSV file exported from an Agilent PNA in dB/deg format.

pna_csv_2_df(filename)

Reads data from a csv file written by an Agilient PNA as a pandas DataFrame.

Reading/Writing R&S

read_zva_dat(filename, *args, **kwargs)

Reads data from a dat file written by a R&S ZVA in dB/deg or re/im format.

read_all_zva_dat([dir, contains])

Read all DAT files in a directory (from R&S ZVA).

zva_dat_2_ntwks(filename)

Read a dat file exported from a R&S ZVA in dB/deg or re/im format.

Reading/Writing Anritsu VectorStar

vectorstar_csv_2_ntwks(filename)

Reads a vectorstar csv file, and returns a list of one-port Networks.

read_vectorstar_csv(filename, *args, **kwargs)

Reads data from a csv file written by an Anritsu VectorStar.