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. Example of mask filter in postpro?

Example of mask filter in postpro?

Scheduled Pinned Locked Moved Python API
pythonmask filtersar
3 Posts 2 Posters 925 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.
  • pcrespoP Offline
    pcrespoP Offline
    pcrespo
    wrote on last edited by Sylvain
    #1

    I have an e-field in a simulation. I would like to mask some regions to compute statistics. Is there an example/tutorial about how to do this in python? thx

    P.

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

      The typical workflow is to first build the postprocessing pipeline in the GUI, then use the "To Python" tool (available from the right-click contextual menu) to generate the corresponding Python script.

      For the mask filter + SAR statistics, it would give something like this:

      import numpy
      import s4l_v1.analysis as analysis
      import s4l_v1.document as document
      import s4l_v1.model as model
      import s4l_v1.units as units
      from s4l_v1 import Unit
      
      # Creating the analysis pipeline
      # Adding a new SimulationExtractor
      simulation = document.AllSimulations["Dipole (Broadband) - Copy"]
      simulation_extractor = simulation.Results()
      
      # Adding a new EmSensorExtractor
      em_sensor_extractor = simulation_extractor["Overall Field"]
      em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All"
      em_sensor_extractor.Normalization.Normalize = True
      em_sensor_extractor.Normalization.AvailableReferences = u"EM Input Power(f)"
      em_sensor_extractor.SurfaceCurrent.SurfaceResolution = 0.001, units.Meters
      document.AllAlgorithms.Add(em_sensor_extractor)
      
      entity1=model.AllEntities()['Sphere 1']
      
      # Adding a new FieldMaskingFilter
      inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]]
      field_masking_filter = analysis.core.FieldMaskingFilter(inputs=inputs)
      field_masking_filter.SetAllMaterials(False)
      field_masking_filter.SetEntities([entity1])
      field_masking_filter.UpdateAttributes()
      document.AllAlgorithms.Add(field_masking_filter)
      
      # Adding a new SarStatisticsEvaluator
      inputs = [field_masking_filter.Outputs["EM E(x,y,z,f0)"]]
      sar_statistics_evaluator = analysis.em_evaluators.SarStatisticsEvaluator(inputs=inputs)
      sar_statistics_evaluator.Snapshot = u"3e+08"
      sar_statistics_evaluator.StdDev = False
      sar_statistics_evaluator.TotalLossyVolume = False
      sar_statistics_evaluator.VoxelCount = False
      sar_statistics_evaluator.LossyVoxelCount = False
      sar_statistics_evaluator.UpdateAttributes()
      document.AllAlgorithms.Add(sar_statistics_evaluator)
      
      
      1 Reply Last reply
      1
      • pcrespoP Offline
        pcrespoP Offline
        pcrespo
        wrote on last edited by
        #3

        Thanks so much!

        P.

        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