- You need teh function
FindCell
(see example below)
- You also need
FindCell
, together with raw access to the underlying numpy data array and a way to "reshape" it properly (see same example below)
# Creating the analysis pipeline
# Adding a new SimulationExtractor
simulation = document.AllSimulations["SCC34 Benchmark Simulation"]
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)
# Get data object
em_sensor_extractor.Outputs["SAR(x,y,z,f0)"].Update() # output needs to be updated before extracting data
sar = em_sensor_extractor.Outputs["SAR(x,y,z,f0)"].Data
# a location in space:
x = 0
y = -0.00910
z = -0.00025
# get grid cell indices closest to that location:
id_x, id_y, id_z = sar.Grid.FindCell(x,y,z)
# Create Slice Viewer at that location
inputs = [em_sensor_extractor.Outputs["SAR(x,y,z,f0)"]]
slice_field_viewer = analysis.viewers.SliceFieldViewer(inputs=inputs)
slice_field_viewer.Data.Mode = slice_field_viewer.Data.Mode.enum.QuantityRealModulus
slice_field_viewer.Slice.Index = id_z
slice_field_viewer.UpdateAttributes()
document.AllAlgorithms.Add(slice_field_viewer)
# Get raw data array (in the form of a numpy array)
sar_array = em_sensor_extractor.Outputs["SAR(x,y,z,f0)"].Data.Field(snapshot_index=0)
nx, ny, nz = numpy.array(sar.Grid.Dimensions) - numpy.array((1,1,1)) # grid is defined on nodes, SAR data is in cell centers
sar_array = numpy.reshape(sar_array, (nx, ny, nz), order='F')
# now data can be accessed easily:
print sar_array[:, id_y, id_z]