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

Made tecplottools.apply_equations more robust, anticipated some different...

Made tecplottools.apply_equations more robust, anticipated some different formats in equations files
parent 05ac3452
...@@ -33,8 +33,8 @@ def apply_equations(eqn_path: str, verbose: bool = False): ...@@ -33,8 +33,8 @@ def apply_equations(eqn_path: str, verbose: bool = False):
Args: Args:
eqn_file_path (str): The path to the equation macro file (typically with eqn_file_path (str): The path to the equation macro file (typically with
extension `.eqn`). extension `.eqn`).
verbose (bool): (Optional) Whether or not to print the equations as they are verbose (bool): (Optional) Whether or not to print the equations as they
applied. Default behavior is silent. are applied. Default behavior is silent.
Examples: Examples:
```python ```python
...@@ -68,10 +68,17 @@ def apply_equations(eqn_path: str, verbose: bool = False): ...@@ -68,10 +68,17 @@ def apply_equations(eqn_path: str, verbose: bool = False):
print('Executing:') print('Executing:')
with open(eqn_path, 'r') as eqn_file: with open(eqn_path, 'r') as eqn_file:
for line in eqn_file: for line in eqn_file:
if line[0] == ' ': if '$!alterdata' in line.lower():
eqnstr = line.split("'")[1] eqn_line = eqn_file.readline()
tecplot.data.operate.execute_equation(eqnstr) try:
eqn_str = eqn_line.split("'")[1]
except IndexError:
try:
eqn_str = eqn_line.split("\"")[1]
except:
raise ValueError(f'Unable to read equation: {eqn_line}')
tecplot.data.operate.execute_equation(eqn_str)
if verbose: if verbose:
print(eqnstr) print(eqn_str)
if verbose: if verbose:
print('Successfully applied equations.') 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