Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you may not be able to execute some actions.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi Guys,
I am currently adapting a code I've written in Sim4Life 2.3 some years ago to Sim4Life 6.0 and found out that a lot has changed in the meantime.
How do I properly set up a Field Crop Filter (for the EMLF-Solver)? This is what my original code looks like and the SetInputConnection and Value commands seem to be deprecated.
import sys, os import s4l_v1.analysis as analysis import s4l_v1.analysis.core as core # Create extractor for a given simulation output file results = sim.Results() overall_field_sensor = results[ 'Overall Field' ] e_field = overall_field_sensor['EM E(x,y,z,f0)'] # pipe the E_field through a crop filter crop_filter = core.FieldCropFilter() crop_filter.SetInputConnection(0, e_field) crop_filter.Update(0) crop_filter[0].SetValue = (63, 123, 513) # set lower extent of crop region (in grid indexes) crop_filter[1].SetValue = (198, 271, 662) # set upper extent of crop region (in grid indexes) analysis.RegisterAlgorithm(crop_filter)
Thanks for your help!
In general, an easy way to create a postprocessing script is to first do it in the GUI and then use the "To-Python" function (available via right-click on the algorithm in the Explorer window).
Here is what the auto-generated script looks like for a simple pipeline with a Crop Filter:
# Creating the analysis pipeline # Adding a new SimulationExtractor simulation = document.AllSimulations["EM"] 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.SurfaceCurrent.SurfaceResolution = 0.001, units.Meters document.AllAlgorithms.Add(em_sensor_extractor) # Adding a new FieldCropFilter inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]] field_crop_filter = analysis.core.FieldCropFilter(inputs=inputs) field_crop_filter.LowerExtent = numpy.array([1, 3, 2]) field_crop_filter.UpperExtent = numpy.array([21, 21, 21]) field_crop_filter.UpdateAttributes() document.AllAlgorithms.Add(field_crop_filter)
Note fyi that you don't actually need to pass a Numpy array to UpperExtent or LowerExtent, it also works if you pass any iterable, like a list or a tuple.
UpperExtent
LowerExtent