@@ -60,6 +60,7 @@ class PlottingWindowBase(QtWidgets.QWidget):
60
60
progress_signal = QtCore .Signal (int , int , int , int )
61
61
finished_signal = QtCore .Signal ()
62
62
thread = None
63
+ time_key = "t"
63
64
64
65
settings_key = "Seanopy_deformation"
65
66
file_extension = ".saenopy"
@@ -85,6 +86,8 @@ def clicked(*, index=index):
85
86
try :
86
87
self .add_files ([filename ])
87
88
except Exception as e :
89
+ import traceback
90
+ traceback .print_exception (e )
88
91
print (e , file = sys .stderr )
89
92
QtWidgets .QMessageBox .critical (self , "Error" , f"Measurement could not be added to Analysis.\n "
90
93
f"Is it evaluated completely?" )
@@ -301,6 +304,7 @@ def getAllCurrentPandasData(self):
301
304
return res
302
305
303
306
def replot (self ):
307
+ self .check_results_with_time ()
304
308
if self .current_plot_func is not None :
305
309
self .current_plot_func ()
306
310
@@ -389,15 +393,15 @@ def plot_groups(self):
389
393
plt .cla ()
390
394
res = self .getAllCurrentPandasData ()
391
395
392
- code_data = [res , ["t" , "group" , mu_name , "filename" ]]
396
+ code_data = [res , [self . time_key , "group" , mu_name , "filename" ]]
393
397
394
398
# get best fitting time label
395
399
factor , x_label = self .get_time_factor (np .max (res .t ))
396
400
397
401
398
402
# add a vertical line where the comparison time is
399
403
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 ])
401
405
plt .axvline (comp_h / factor , color = "k" )
402
406
403
407
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):
410
414
# iterate over the groups
411
415
for group_name , data in res .groupby ("group" , sort = False ):
412
416
# 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" ])
414
418
# plot the mean curve
415
419
p , = plt .plot (x .index / factor , x ["mean" ], color = color_dict [group_name ], lw = 2 , label = f"{ group_name } (n={ int (x ['count' ].mean ())} )" )
416
420
# add a shaded area for the standard error
@@ -457,7 +461,7 @@ def run2(self):
457
461
return
458
462
459
463
#plt.figure(figsize=(6, 3))
460
- code_data = [res , ["t" , mu_name ]]
464
+ code_data = [res , [self . time_key , mu_name ]]
461
465
462
466
463
467
self .canvas .setActive ()
@@ -494,7 +498,11 @@ def export(self):
494
498
if not dialog .exec ():
495
499
return
496
500
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 :
498
506
code = ""
499
507
code += "import matplotlib.pyplot as plt\n "
500
508
code += "import numpy as np\n "
0 commit comments