, 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().

  • 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?


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.


Convert a touchstone file to a pickled Network,

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

Writing a list of different objects

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

See also

read a skrf object
write skrf object[s]
read all skrf objects in a directory
write dictionary of skrf objects to a directory
write method of Network
write method of Calibration