Commit f420b06b authored by Camilla Dodge Koslowsky Harris's avatar Camilla Dodge Koslowsky Harris
Browse files

Initial commit of tecplottools module for working with Tecplot and pytecplot.

parent 4b4cfb52
......@@ -13,6 +13,8 @@ These are automatically imported.
- `` Tools used in swmfpy. You might find these useful but it is
- `swmfpy.tecplottools` Tools for working with the Tecplot visualization
software. Requires a Tecplot license and the pytecplot python package.
__author__ = 'Qusai Al Shidi'
__license__ = 'MIT'
#!/usr/bin/env python
"""Tools for working with the Tecplot visualization software. Requires an
active Tecplot license and the pytecplot python package. pytecplot ships with
Tecplot 360 2017 R1 and later versions but it is recommended that you install
the latest version with `pip install pytecplot`. See the pytecplot
documentation for more details about installation
( See also
TECPLOT.markdown for tips targeted to SWMF users.
Some useful references:
- Tecplot User's Manual
- Tecplot Scripting Guide
- Pytecplot documentation
__all__ = [
__author__ = 'Camilla D. K. Harris'
__email__ = ''
import tecplot
def apply_equations(eqn_path: str, verbose: bool = False):
Apply an equations file in the Tecplot macro format to the active Tecplot
dataset. Please reference the Tecplot User's Manual for more details on
equation files and syntax. It is recommended to use this function with eqn
files generated with the Tecplot GUI. See TECPLOT.markdown for tips on using
eqn_file_path: The path to the equation macro file (typically with
extension `.eqn`).
verbose: (Optional) Whether or not to print the equations as they are
applied. Default behavior is silent.
import tecplot
import swmfpy.tecplottools as tpt
## Uncomment this line if you are connecting to a running tecplot
## session. Be sure that the port number matches the port the GUI is
## listening to. See TECPLOT.markdown for tips on connecting to a
## running session or running your script seperately.
## load a dataset
dataset ='./z=0_mhd_1_n00000000.plt')
## apply an equations file
tpt.apply_equations('./gse_to_ephio.eqn', verbose= True)
## apply a frame style
frame = tecplot.active_frame()
## annotate with the zone name
frame.add_text('&(ZONENAME[ACTIVEOFFSET=1])', position= (5, 95))
## save the image
tecplot.export.save_png('./density.png', width= 1200, supersample= 8)
if verbose:
with open(eqn_path, 'r') as eqn_file:
for line in eqn_file:
if line[0] == ' ':
eqnstr = line.split("'")[1]
if verbose:
if verbose:
print('Successfully applied equations.')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment