How to extract point data?
-
Hi,
I would need to know if it is possible to automatically (or via Python) extract point data, giving the point coordinates, once the acoustic simulation has run.
Or I have to set a point sensor in each point of interest before running the simulation?
Specially, I would need to extract the acoustic intensity value in specific points.
So far I extracted the profile along an axis and then I manually took the value using the cursor, a very awkward way !!! -
Dear Annalisa,
- If you want the time domain data then you will need the point sensors which need to be set ahead of time.
- If you just want the Intensity values (steady state) and the coordinates then you can use python for that
- out is 3D numpy array of intensity values
- xaxis is coordinates is the coordinates of each x point in the out array
-- Note that Values are stored at cell centers and the xaxis_nodes gives the coordinates for the cell nodes (not cell centers), xaxis is the just the midpoint
-- Careful with axis units, they're probably in meters by default but not sure (maybe depends on s4l settings)
import numpy as np 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 simulation = document.AllSimulations["Ac"] simulation_extractor = simulation.Results() simulation_extractor.Update() acoustic_sensor_extractor = simulation_extractor["Overall Field"] field = acoustic_sensor_extractor.Outputs["Intensity"] field.Update() # Get Field - 1D flat array out = field.Data.Field(0) # Get Axis dims = np.array(field.Data.Grid.Dimensions) if np.prod(dims) != len(out): dims = dims-1 # Reshape Field - 3D [x,y,z] array out = out.reshape(dims, order='F') # Coordinates of nodes xaxis_nodes = field.Data.Grid.XAxis yaxis_nodes = field.Data.Grid.YAxis zaxis_nodes = field.Data.Grid.ZAxis # Coordinates of cell values xaxis = (xaxis_nodes[:-1] + xaxis_nodes[1:]) / 2 yaxis = (yaxis_nodes[:-1] + yaxis_nodes[1:]) / 2 zaxis = (zaxis_nodes[:-1] + zaxis_nodes[1:]) / 2