skrf.network.Network.renumber
- Network.renumber(from_ports, to_ports, only_z0=False)[source]
Renumber ports of a Network (inplace).
- Parameters:
from_ports (list-like) – List of port indices to change. Size between 1 and N_ports.
to_ports (list-like) – List of desired port indices. Size between 1 and N_ports.
only_z0 (bool) – If true only z0 is renumbered, s-parameters are not affected. This should only be used after executing the “connect_s” method which keeps the port index where you expect it to be.
NB (from_ports and to_ports must have same size.)
- Returns:
None
The reorganization of the Network’s port is performed inplace.
- Return type:
None
Examples
In the following example, the ports of a 3-ports Network are reorganized. Dummy reference impedances are set only to follow more easily the renumbering.
>>> f = rf.Frequency(1, 1, 1, 'hz') >>> s = np.arange(9).reshape(1, 3, 3) >>> z0 = [10, 20, 30] >>> ntw = rf.Network(frequency=f, s=s, z0=z0) # our OEM Network
In picture, we have:
Order in Original Order Scatter Parameters skrf.Network 0 1 2 ┌───────────────────┐ ┌──────────────────────┐ │ OEM │ │ │ │ │ │ │ 0 ────────┤ A (10 Ω) │ ┤ 0.+0.j 1.+0.j 2.+0.j │ │ │ │ │ │ │ │ │ 1 ────────┤ B (20 Ω) │ ┤ 3.+0.j 4.+0.j 5.+0.j │ │ │ │ │ │ │ │ │ 2 ────────┤ C (30 Ω) │ ┤ 6.+0.j 7.+0.j 8.+0.j │ │ │ │ │ └───────────────────┘ └──────────────────────┘While after renumbering
>>> ntw.renumber([0, 1, 2], [1, 2, 0])
we now have:
Order in Scatter Parameters skrf.Network 0 1 2 ┌───────────────────┐ ┌──────────────────────┐ │ OEM │ │ │ │ │ │ │ 0 ────────┤ C (30 Ω) │ ┤ 8.+0.j 6.+0.j 7.+0.j │ │ │ │ │ │ │ │ │ 1 ────────┤ A (10 Ω) │ ┤ 2.+0.j 0.+0.j 1.+0.j │ │ │ │ │ │ │ │ │ 2 ────────┤ B (20 Ω) │ ┤ 5.+0.j 3.+0.j 4.+0.j │ │ │ │ │ └───────────────────┘ └──────────────────────┘Other examples:
Reorganized only the reference impedance of the ports, while keeping the order of the scattering parameters is also supported. This is beneficial in some special cases.
>>> ntw.renumber([1, 2, 0], [0, 1, 2], only_z0=True)
we now have:
Order in Scatter Parameters skrf.Network 0 1 2 ┌───────────────────┐ ┌──────────────────────┐ │ OEM │ │ │ │ │ │ │ 0 ────────┤ A (10 Ω) │ ┤ 8.+0.j 6.+0.j 7.+0.j │ │ │ │ │ │ │ │ │ 1 ────────┤ B (20 Ω) │ ┤ 2.+0.j 0.+0.j 1.+0.j │ │ │ │ │ │ │ │ │ 2 ────────┤ C (30 Ω) │ ┤ 5.+0.j 3.+0.j 4.+0.j │ │ │ │ │ └───────────────────┘ └──────────────────────┘To flip the ports of a 2-port network ‘foo’:
>>> foo.renumber( [0,1], [1,0] )
To rotate the ports of a 3-port network ‘bar’ so that port 0 becomes port 1:
>>> bar.renumber( [0,1,2], [1,2,0] )
To swap the first and last ports of an N-port (N>=2) Network ‘duck’:
>>> duck.renumber( [0,-1], [-1,0] )
See also