how to set the weights of field combiner in python?

I found the function, myfieldcombiner.SetWeights(). But I don't know how to specify the weights of the two inputs. for example: 1+0j and -1+0j.

Here is an example I used in the past (with Sim4Life v3.0), maybe it works for you?

sim = document.AllSimulations[0]
results = sim.Results()

sim_combiner = results.GetSimulationCombiner()

sim_combiner.UpdateAttributes()

weights = sim_combiner.GetChannelWeights()


for n, channel in enumerate(weights):
	power, phase = weights[channel]
	weights[channel] = power, 45*n

for channel in weights:
	print channel, weights[channel]
	sim_combiner.SetChannelWeight(channel, *weights[channel])

Thanks, I will try that.

sorry, I gave you some code for the Simulation Combiner, not the Field Combiner...
This is how you can use the GetWeights and SetWeights functions for the field combiner:

>>> field_combiner.GetWeights()
((1+0j), (1+0j))

>>> field_combiner.SetWeights( ( (2+0j), (-3+0j) ) )
Log in to reply