Extracting data from a surface, through time, using PyTecplot
In this example we want to extract Pressure values through time from the wall of a simulation at specific XYZ locations. After the extractions, we want to plot the results with Time on the X-Axis and Pressure on the Y-Axis for each XYZ location.
To do this we must use the PyTecplot function tecplot.data.probe_on_surface(). Another probe function, tecplot.data.probe_at_position(), is available but is likely to fail since it expects data to exist at the exact XYZ location (rather than near the location). Since a surface is infinitely thin it’s unlikely that the supplied XYZ location will be exactly on the surface, so we use the tecplot.data.probe_on_surface() function to find the surface value closest to the XYZ location.
Download the Data, layout and Scripting Files
Extract Data Instructions:
- Load data.szplt and switch to the 3D Cartesian plot type.
- Activate the ‘wall’ zone in the Zone Style dialog.
- Turn on the Contour zone layer and change the contouring variable to Pressure.
- Fit the data (Ctrl+F) and rotate the view as seen in Figure 1.
- Allow Python connections via Scripting>PyTecplot Connections…
- From a command prompt, ‘cd’ to the directory that contains ‘probe_on_surface_through_time.py’ and run the script using the command:
> python –O probe_on_surface_through_time.py
- The script extracts data from the XYZ locations specified in XYZ.txt and will create one zone for each XYZ location. These zones represent the Pressure values on the wall at each of those locations.
- To plot the new data, create a new frame and switch to XY Line plot type. Create line mappings using the Create Mappings dialog (see Figure 2 below).
- To show to timing marker in the XY plot, run the show_markergridline.mcr macro.
- In the 3D plot, activate the three new zones and use the Scatter plot layer to display the XYZ locations in the 3D plot.
- The final result is shown in Figure 4.
This Tecpot image shows the line data and the XYZ locations in context of the 3D plot.
Also see the related Tecplot 360 Video Tutorial, External Flow – Comparing a CFD Simulation with Experimental Data.