Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. how to set the weights of field combiner in python?

how to set the weights of field combiner in python?

Scheduled Pinned Locked Moved Solved Python API
4 Posts 2 Posters 496 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aiping
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    1
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      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])
      1 Reply Last reply
      0
      • A Offline
        A Offline
        Aiping
        wrote on last edited by
        #3

        Thanks, I will try that.

        1 Reply Last reply
        0
        • SylvainS Offline
          SylvainS Offline
          Sylvain
          ZMT
          wrote on last edited by
          #4

          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) ) )
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Search