When looking at geographical or ocean datasets, it is often desirable to analyze a non-linear path through the dataset and view a vertical cross-section created by the path. For example, above is the Boston Bay ocean dataset in the Getting Started Guide. This article describes how to get a vertical cross-section or ‘transect’ using a PyTecplot script we developed.
While Tecplot 360 has a built-in tool for creating slices, a more flexible tool is needed to trace a complex path, such as the red polyline in the picture above, and analyze the result.
For this tutorial, we are using the Ocean dataset from our Getting Started bundle (zip), and the Extract2DCrossSection.py script. You will also need to install our PyTecplot package if you have not already.
The script creates a set of vertical slices using coordinates from line segments in a polyline zone. It then uses those slices to stitch together a continuous “transect” and calculates distance across them. Finally, the script will change the plot style to show us a view of our transect.
First, open “Ocean2.lay” in the “finallayouts” folder of Ocean dataset of the 360 getting started guide:
When the layout opens in 360, we should be looking down on the bay.
With this particular layout, the variables for longitude and latitude are being used for the x and y axes. While this makes sense in the context of the data, we should change this to the variables X and Y to get accurate reading of distance. To do this, go to Plot > Assign XYZ > X Y Z. Tecplot 360 may give warnings that the frame aspect ratio has been adjusted, these can be ignored. Next, snap to the XY orientation on the plot sidebar to get a proper birds-eye view of the data, as shown in the picture below.
Next, select the polyline tool from the top row of tools. Left-click to start a line segment of the polyline, click again to add a new line segment. Create a path through the dataset, with whatever orientation you like. When finished, right-click to stop using the polyline tool.
To extract this polyline, right-click on it and choose Extract points. This will bring up an extraction dialog with multiple options. Choose Extract only points that define geometry, as this leads to far less computation and will give the same result with less data.
Check that a new zone was created by going to Data > Data Set Info. There should be a new zone, titled, “Extracted Points”.
It is important to note that extracting a new polyline, will create yet another zone with the same title. You can double-click any zone in this dialog to rename it as needed. By default, the script will search for the first zone with the title “Extracted Points” and use it to create the transect.
Next, go to Scripting > PyTecplot Connections… and toggle on Accept connections. This will allow the PyTecplot script to connect to the open instance of Tecplot 360.
Finally, open the “Extract2DCrossSection.py” script and in an IDE or the command line. There is only one option we need to consider, that’s the variable “polyline_zone_name”.
By default, it should be set to “Extracted Points”. If you changed the name of the zone in Tecplot 360, you must also change it here.
Verifying that this value is correct, we can now run the script from the command line or the IDE. There are a few updates the script will give us while it runs. They should appear in the order below:
Keep in mind that the time needed for the script to run is dependent on how many line segments are in your polyline and how many timesteps your data has.
Now that the script has run, you should see a vertical transect in Tecplot 360. You can change the contour variable and colormap as needed. Below is a visualization of the variable salinity with the colormap cmocean – haline.
Because the data in this case is transient, it is possible to analyze the transect over time, such as in the exported animation below.