skrf.io.general.write

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

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

See also

read
read a skrf object
write
write skrf object[s]
read_all
read all skrf objects in a directory
write_all
write dictionary of skrf objects to a directory
skrf.network.Network.write
write method of Network
skrf.calibration.calibration.Calibration.write
write method of Calibration

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 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)
>>> n_red = rf.read('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 = rf.read('out.p')

Previous topic

skrf.io.general.read_all

Next topic

skrf.io.general.write_all

This Page