Hello Sim4Life community,
I have problems changing the mask setting using the python API. I want to export data where the background is masked away. If I do it interactively in Sim4Life and choose 'to Python' the masking part of the code (setting entities to True/False) seems to be missing. I think I have to use the 'SetMaterial' function in the Analysis.Core.FieldMaskingFilter. I just can't figure out what input type it wants for the materials.
Any help would be wonderful. This is my code:
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 ReleaseVersion
from s4l_v1 import Unit
try:
# Define the version to use for default values
ReleaseVersion.set_active(ReleaseVersion.version6_2)
size = numpy.linspace(1,34,34)
for k in size:
# Creating the analysis pipeline
# Adding a new SimulationExtractor
simulation = document.AllSimulations["Simulation " + str(k)]
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.SurfaceCurrent.SurfaceResolution = 0.001, units.Meters
document.AllAlgorithms.Add(em_sensor_extractor)
# 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.UpdateAttributes()
document.AllAlgorithms.Add(field_masking_filter)
# Adding a new MatlabExporter
inputs = [field_masking_filter.Outputs["EM E(x,y,z,f0)"]]
matlab_exporter = analysis.exporters.MatlabExporter(inputs=inputs)
matlab_exporter.FileName = u"[some path]"+str(k)+".mat"
matlab_exporter.UpdateAttributes()
matlab_exporter.Update()
document.AllAlgorithms.Add(matlab_exporter)
except Exception as exc:
import traceback
traceback.print_exc(exc)
# Reset active version to default
ReleaseVersion.reset()
raise(exc)
Best,
Frodi