diff --git a/src/SimNDT/run_setup/snapshots.py b/src/SimNDT/run_setup/snapshots.py index 9537d26..d0811d8 100644 --- a/src/SimNDT/run_setup/snapshots.py +++ b/src/SimNDT/run_setup/snapshots.py @@ -10,6 +10,17 @@ from scipy.io import savemat import math import yaml +import re + +def strip_python_tags(s): + result = [] + + for line in s.splitlines(): + line = re.sub("!!python/[^ ]+","",line) + line = re.sub("!![^ ]","",line) + result.append(line) + return '\n'.join(result) + class SnapShots: def __init__(self, Enable=False, Extension='.png', Step=200, Filename=None, File_path = None, dB=60, Color=0, Field = 0, @@ -183,19 +194,17 @@ class SnapShots: savemat(FILE, S) - def save_summary (self,dt,dx): + def save_summary (self,data): if self.enableSummary == True: FILE = self.Filename + ("-simulation.yml") FILE_PATH = os.path.join(self.File_path, FILE) # save in yaml format - data = dict ( - dt=dt, - dx=dx - ) print("Saving simulation summary in "+FILE_PATH) + yaml.encoding = None + text = strip_python_tags(yaml.dump(data,default_flow_style=False)) with open(FILE_PATH, 'w') as outfile: - yaml.dump(data, outfile, default_flow_style=False) - + outfile.write(text) + def save_power(self, Vx, Vy, n): S = np.sqrt(Vx ** 2 + Vy ** 2)