Terrabits / rohdeschwarz

Rohde & Schwarz python instrument control toolbox
https://vna.rs-us.net/python/
Other
37 stars 18 forks source link

Channel.read_s_parameter_group returns mixed-up data #10

Open Terrabits opened 3 years ago

Terrabits commented 3 years ago

The VNA returns S-Parameter data in this order:

S11(f1), S11(f2), S11(f3)... S12(f1), S12(f2), ...

In the Channel.read_s_parameter_group method, this data is reshaped into shape=(points, ports, ports), which mixes up everything.

See https://github.com/Terrabits/save_all_s4p/blob/main/save_all_s4p/vna_monkeypatch/read_s_parameter_group.py for a potential solution.

Here is an excerpt of the relevant array manipulations:

# reshape data according to VNA
    ports          = len(self.s_parameter_group)
    points         = self.points
    original_shape = (ports, ports, points)
    original_array =  numpy.reshape(result, original_shape)

    # switch axes to match scikit-rf [s] syntax
    desired_array = numpy.swapaxes(original_array, 1, 2)
    desired_array = numpy.swapaxes(desired_array,  0, 1)