skrf.io.general.write¶

skrf.io.general.write(file, obj, overwrite=True)[source]

Write skrf object[s] to a file

This uses the pickle module to write skrf objects to a file. Note that you can write any pickl-able python object. For example, you can write a list or dictionary of Network objects or Calibration objects. This will write out a single file. If you would like to write out a separate file for each object, use write_all().

Parameters: file (file or string) – File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string, an appropriate extension will be appended to the file name if it does not already have an extension. obj (an object, or list/dict of objects) – object or list/dict of objects to write to disk overwrite (Boolean) – if file exists, should it be overwritten?

Notes

If file is a str, but doesnt contain a suffix, one is chosen automatically. Here are the extensions

skrf object extension
Frequency ‘.freq’
Network ‘.ntwk’
NetworkSet ‘.ns’
Calibration ‘.cal’
Media ‘.med’
other ‘.p’

To make the file written by this method cross-platform, the pickling protocol 2 is used. See pickle for more info.

Examples

Convert a touchstone file to a pickled Network,

>>> n = rf.Network('my_ntwk.s2p')
>>> rf.write('my_ntwk',n)


Writing a list of different objects

>>> n = rf.Network('my_ntwk.s2p')
>>> ns = rf.NetworkSet([n,n,n])
>>> rf.write('out',[n,ns])


read()
write()
read_all()
write_all()
skrf.network.Network.write()
skrf.calibration.calibration.Calibration.write()