Skip to content

Commit 1d0b886

Browse files
committed
implemented PlottingWindow tab for saenopyOrientation
1 parent c8a7aee commit 1d0b886

File tree

10 files changed

+140
-368
lines changed

10 files changed

+140
-368
lines changed

saenopy/gui/common/PlottingWindowBase.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class PlottingWindowBase(QtWidgets.QWidget):
6060
progress_signal = QtCore.Signal(int, int, int, int)
6161
finished_signal = QtCore.Signal()
6262
thread = None
63+
time_key = "t"
6364

6465
settings_key = "Seanopy_deformation"
6566
file_extension = ".saenopy"
@@ -85,6 +86,8 @@ def clicked(*, index=index):
8586
try:
8687
self.add_files([filename])
8788
except Exception as e:
89+
import traceback
90+
traceback.print_exception(e)
8891
print(e, file=sys.stderr)
8992
QtWidgets.QMessageBox.critical(self, "Error", f"Measurement could not be added to Analysis.\n"
9093
f"Is it evaluated completely?")
@@ -301,6 +304,7 @@ def getAllCurrentPandasData(self):
301304
return res
302305

303306
def replot(self):
307+
self.check_results_with_time()
304308
if self.current_plot_func is not None:
305309
self.current_plot_func()
306310

@@ -389,15 +393,15 @@ def plot_groups(self):
389393
plt.cla()
390394
res = self.getAllCurrentPandasData()
391395

392-
code_data = [res, ["t", "group", mu_name, "filename"]]
396+
code_data = [res, [self.time_key, "group", mu_name, "filename"]]
393397

394398
# get best fitting time label
395399
factor, x_label = self.get_time_factor(np.max(res.t))
396400

397401

398402
# add a vertical line where the comparison time is
399403
if getattr(self, "input_tbar", None) and self.input_tbar.value() is not None:
400-
comp_h = self.get_comparison_index() * (res.iloc[1]["t"] - res.iloc[0]["t"])
404+
comp_h = self.get_comparison_index() * (res.iloc[1][self.time_key] - res.iloc[0][self.time_key])
401405
plt.axvline(comp_h/factor, color="k")
402406

403407
color_dict = {d[0]: d[3] for d in self.data_folders}
@@ -410,7 +414,7 @@ def plot(res, mu_name, y_label, color_dict2, x_label, factor):
410414
# iterate over the groups
411415
for group_name, data in res.groupby("group", sort=False):
412416
# get the mean and sem
413-
x = data.groupby("t")[mu_name].agg(["mean", "sem", "count"])
417+
x = data.groupby(self.time_key)[mu_name].agg(["mean", "sem", "count"])
414418
# plot the mean curve
415419
p, = plt.plot(x.index/factor, x["mean"], color=color_dict[group_name], lw=2, label=f"{group_name} (n={int(x['count'].mean())})")
416420
# add a shaded area for the standard error
@@ -457,7 +461,7 @@ def run2(self):
457461
return
458462

459463
#plt.figure(figsize=(6, 3))
460-
code_data = [res, ["t", mu_name]]
464+
code_data = [res, [self.time_key, mu_name]]
461465

462466

463467
self.canvas.setActive()
@@ -494,7 +498,11 @@ def export(self):
494498
if not dialog.exec():
495499
return
496500

497-
with open(str(dialog.inputText.value()), "wb") as fp:
501+
filename = str(dialog.inputText.value())
502+
if not filename.endswith(".py"):
503+
filename += ".py"
504+
505+
with open(filename, "wb") as fp:
498506
code = ""
499507
code += "import matplotlib.pyplot as plt\n"
500508
code += "import numpy as np\n"

saenopy/gui/example_creator.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
5+
size = [500, 300, 50]
6+
pos = [100, 30, 5]
7+
radius = 10
8+
image = np.zeros(pos)
9+
10+
for i in range(size[0]):
11+
for j in range(size[1]):
12+
for k in range(size[2]):
13+
#distance = np.linalg.
14+
pass

0 commit comments

Comments
 (0)