3333
3434pg .mkQApp ()
3535pg .setConfigOption ('background' , 'w' )
36+ #pg.setConfigOption('crashWarning', True)
3637
3738base_path = Path (__file__ ).parent
3839file_path = (base_path / "Lifetime_analysis_gui_layout.ui" ).resolve ()
@@ -69,14 +70,14 @@ def __init__(self):
6970 self .show ()
7071
7172 def open_file (self ):
73+ # try:
74+ filename = QtWidgets .QFileDialog .getOpenFileName (self )
7275 try :
73- filename = QtWidgets .QFileDialog .getOpenFileName (self )
74- try :
75- self .file = np .loadtxt (filename [0 ], skiprows = 0 )
76- except ValueError :
77- self .file = np .loadtxt (filename [0 ], skiprows = 10 )
78- except :
79- self .file = read_picoharp_phd (filename [0 ])
76+ self .file = np .loadtxt (filename [0 ], skiprows = 10 )
77+ # except ValueError:
78+ # self.file = np.loadtxt(filename[0], skiprows=10)
79+ except UnicodeDecodeError :
80+ self .file = read_picoharp_phd (filename [0 ])
8081 except :
8182 pass
8283
@@ -91,27 +92,35 @@ def acquire_settings(self):
9192 resolution = float (self .ui .Res_comboBox .currentText ())
9293 channel = int (self .ui .Channel_comboBox .currentText ())
9394 try :
94- y = self .file [:,channel ]
95- except :
96- res , y = self .file .get_curve (channel )
97- # TO DO - check if res read in is the same as selected
98- time_window = int (np .floor (self .file .get_time_window_in_ns (channel )))
99- y = y [0 :time_window ]
100-
101- length = np .shape (y )[0 ]
102- x = np .arange (0 , length , 1 ) * resolution
103- return x ,y
95+ try :
96+ y = self .file [:,channel ]
97+ except :
98+ res , y = self .file .get_curve (channel )
99+ # TO DO - check if res read in is the same as selected
100+ time_window = int (np .floor (self .file .get_time_window_in_ns (channel )))
101+ y = y [0 :time_window ]
102+
103+ length = np .shape (y )[0 ]
104+ x = np .arange (0 , length , 1 ) * resolution
105+ return x ,y
106+
107+ except Exception as e :
108+ self .ui .Result_textBrowser .setText (str (e ))
104109
105110 def plot (self ):
106- x ,y = self .acquire_settings ()
107- self .ui .plot .plot (x , y , clear = False , pen = 'r' )
108- self .ui .plot .setLabel ('left' , 'Intensity' , units = 'a.u.' )
109- self .ui .plot .setLabel ('bottom' , 'Time (ns)' )
110111 try :
111- self .ui .Result_textBrowser .setText ("Integral Counts :\n " "{:.2E}" .format (
112- self .file .get_integral_counts (int (self .ui .Channel_comboBox .currentText ()))))
112+ x ,y = self .acquire_settings ()
113+ self .ui .plot .plot (x , y , clear = False , pen = 'r' )
114+ try :
115+ self .ui .Result_textBrowser .setText ("Integral Counts :\n " "{:.2E}" .format (
116+ self .file .get_integral_counts (int (self .ui .Channel_comboBox .currentText ()))))
117+ except :
118+ self .ui .Result_textBrowser .setText ("Integral Counts :\n " "{:.2E}" .format (np .sum (y )))
113119 except :
114- self .ui .Result_textBrowser .setText ("Integral Counts :\n " "{:.2E}" .format (np .sum (y )))
120+ pass
121+ self .ui .plot .setLabel ('left' , 'Intensity' , units = 'a.u.' )
122+ self .ui .plot .setLabel ('bottom' , 'Time (ns)' )
123+
115124
116125 def make_semilog (self ):
117126 self .ui .plot .setLogMode (False ,True )
0 commit comments