Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

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. ...@@ -13,6 +13,8 @@ These are automatically imported.
- `swmfpy.tools` Tools used in swmfpy. You might find these useful but it is - `swmfpy.tools` Tools used in swmfpy. You might find these useful but it is
unecessary. unecessary.
- `swmfpy.tecplottools` Tools for working with the Tecplot visualization
software. Requires a Tecplot license and the pytecplot python package.
""" """
__author__ = 'Qusai Al Shidi' __author__ = 'Qusai Al Shidi'
__license__ = 'MIT' __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
(https://www.tecplot.com/docs/pytecplot/install.html). See also
TECPLOT.markdown for tips targeted to SWMF users.
Some useful references:
- Tecplot User's Manual
http://download.tecplot.com/360/current/360_users_manual.pdf
- Tecplot Scripting Guide
http://download.tecplot.com/360/current/360_scripting_guide.pdf
- Pytecplot documentation
https://www.tecplot.com/docs/pytecplot/index.html
"""
__all__ = [
'apply_equations'
]
__author__ = 'Camilla D. K. Harris'
__email__ = 'cdha@@umich.edu'
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
pytecplot.
Arguments:
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.
Example:
```python
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.
#tecplot.session.connect(port=7600)
## load a dataset
dataset = tecplot.data.load_tecplot('./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()
frame.load_stylesheet('./density.sty')
## 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:
print('Executing:')
with open(eqn_path, 'r') as eqn_file:
for line in eqn_file:
if line[0] == ' ':
eqnstr = line.split("'")[1]
tecplot.data.operate.execute_equation(eqnstr)
if verbose:
print(eqnstr)
if verbose:
print('Successfully applied equations.')
Markdown is supported
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