2525from H5_Pkl import h5_pkl_view
2626sys .path .append (os .path .abspath ('../Export_Windows' ))
2727try :
28- from Export_window import ExportFigureWindow
28+ from Export_window import ExportFigureWindow , ExportPlotWindow
2929except :
30- from Export_Windows .Export_window import ExportFigureWindow
30+ from Export_Windows .Export_window import ExportFigureWindow , ExportPlotWindow
3131# local modules
3232try :
3333 from Spectra_fit_funcs import Spectra_Fit , Single_Gaussian , Single_Lorentzian , Double_Gaussian , Multi_Gaussian
@@ -93,7 +93,7 @@ def __init__(self):
9393 # self.ui.config_fit_params_pushButton.clicked.connect(self.configure_fit_params)
9494 self .ui .clear_pushButton .clicked .connect (self .clear_plot )
9595 self .ui .add_to_mem_pushButton .clicked .connect (self .add_trace_to_mem )
96- self .ui .export_single_figure_pushButton .clicked .connect (self .pub_ready_plot_export )
96+ self .ui .export_single_figure_pushButton .clicked .connect (self .export_plot_window )
9797 self .ui .export_scan_figure_pushButton .clicked .connect (self .export_window )
9898 self .ui .analyze_spectra_fits_pushButton .clicked .connect (self .analyze_spectra_fits )
9999
@@ -347,6 +347,7 @@ def plot(self):
347347 self .y = self .file [:,1 ]
348348
349349 self .check_loaded_files ()
350+ self .check_eV_state ()
350351
351352 if self .check_loaded_files () == True : #check the following conditions if all required files have been provided
352353 if self .ui .subtract_bck_radioButton .isChecked () == True and self .ui .WLRef_checkBox .isChecked () == False :
@@ -364,20 +365,29 @@ def plot(self):
364365
365366 if self .ui .norm_checkBox .isChecked ():
366367 self .normalize ()
367-
368+
368369 self .ui .plot .plot (self .x , self .y , clear = self .clear_check (), pen = 'r' )
369370
370371 except Exception as e :
371372 self .ui .result_textBrowser .append (str (e ))
372373 pass
373374 self .ui .plot .setLabel ('left' , 'Intensity' , units = 'a.u.' )
374- self .ui .plot .setLabel ('bottom' , 'Wavelength (nm)' )
375+ if self .ui .fit_in_eV .isChecked ():
376+ self .ui .plot .setLabel ('bottom' , 'Energy (eV)' )
377+ else :
378+ self .ui .plot .setLabel ('bottom' , 'Wavelength (nm)' )
375379
376380 self .single_spec_fit_called = False
377381
378382 def normalize (self ):
379383 self .y = (self .y ) / np .amax (self .y )
380384
385+ def check_eV_state (self ):
386+ if self .ui .fit_in_eV .isChecked ():
387+ self .x = 1240 / self .file [:,0 ]
388+ else :
389+ self .x = self .file [:,0 ]
390+
381391 def clear_plot (self ):
382392 self .ui .plot .clear ()
383393 self .ui .result_textBrowser .clear ()
@@ -419,9 +429,9 @@ def fit_and_plot(self):
419429 elif self .opened_from_flim :
420430 pass
421431 else :
422-
432+ self . check_eV_state ()
423433 if fit_func == "Single Gaussian" : #and self.ui.subtract_bck_radioButton.isChecked() == True:
424- single_gauss = Single_Gaussian (self .file , self .bck_file , wlref = self .wlref_file )
434+ single_gauss = Single_Gaussian (self .file , self .bck_file , wlref = self .wlref_file , fit_in_eV = self . ui . fit_in_eV . isChecked () )
425435 if self .ui .adjust_param_checkBox .isChecked ():
426436 center1_min = self .ui .single_peakcenter1_min_spinBox .value ()
427437 center1_max = self .ui .single_peakcenter1_max_spinBox .value ()
@@ -436,7 +446,7 @@ def fit_and_plot(self):
436446 self .ui .result_textBrowser .setText (self .result .fit_report ())
437447
438448 elif fit_func == "Single Lorentzian" : #and self.ui.subtract_bck_radioButton.isChecked() == True:
439- single_lorentzian = Single_Lorentzian (self .file , self .bck_file , wlref = self .wlref_file )
449+ single_lorentzian = Single_Lorentzian (self .file , self .bck_file , wlref = self .wlref_file , fit_in_eV = self . ui . fit_in_eV . isChecked () )
440450
441451 if self .ui .adjust_param_checkBox .isChecked ():
442452 center1_min = self .ui .single_peakcenter1_min_spinBox .value ()
@@ -452,7 +462,7 @@ def fit_and_plot(self):
452462 self .ui .result_textBrowser .setText (self .result .fit_report ())
453463
454464 elif fit_func == "Double Gaussian" : #and self.ui.subtract_bck_radioButton.isChecked() == True:
455- double_gauss = Double_Gaussian (self .file , self .bck_file , wlref = self .wlref_file )
465+ double_gauss = Double_Gaussian (self .file , self .bck_file , wlref = self .wlref_file , fit_in_eV = self . ui . fit_in_eV . isChecked () )
456466 if self .ui .adjust_param_checkBox .isChecked ():
457467 center1_min = self .ui .double_peakcenter1_min_spinBox .value ()
458468 center1_max = self .ui .double_peakcenter1_max_spinBox .value ()
@@ -482,7 +492,7 @@ def fit_and_plot(self):
482492
483493 elif fit_func == "Triple Gaussian" : #and self.ui.subtract_bck_radioButton.isChecked() == True:
484494 #currently only works for triple gaussian (n=3)
485- multiple_gauss = Multi_Gaussian (self .file , self .bck_file , 3 , wlref = self .wlref_file )
495+ multiple_gauss = Multi_Gaussian (self .file , self .bck_file , 3 , wlref = self .wlref_file , fit_in_eV = self . ui . fit_in_eV . isChecked () )
486496 if self .ui .adjust_param_checkBox .isChecked ():
487497 center1_min = self .ui .multi_peakcenter1_min_spinBox .value ()
488498 center1_max = self .ui .multi_peakcenter1_max_spinBox .value ()
@@ -523,6 +533,10 @@ def fit_and_plot(self):
523533 def export_window (self ):
524534 self .export_window = ExportImages ()
525535 self .export_window .export_fig_signal .connect (self .pub_ready_plot_export )
536+
537+ def export_plot_window (self ):
538+ self .exportplotwindow = ExportPlotWindow ()
539+ self .exportplotwindow .export_fig_signal .connect (self .pub_ready_plot_export )
526540
527541 def pub_ready_plot_export (self ):
528542 filename = QtWidgets .QFileDialog .getSaveFileName (self ,caption = "Filename with EXTENSION" )
@@ -566,10 +580,14 @@ def pub_ready_plot_export(self):
566580 plt .plot (self .x_mem [i ], self .y_mem [i ], label = str (self .legend [i ]))
567581 if self .single_spec_fit_called == True :
568582 plt .plot (self .x_mem [i ], self .best_fit_mem [i ],'k' )
569- #plt.plot(self.x, self.y)
570- #plt.plot(self.x, self.result.best_fit,'k')
571- plt .xlabel ("Wavelength (nm)" , fontsize = 20 , fontweight = 'bold' )
583+
584+ if self .ui .fit_in_eV .isChecked ():
585+ plt .xlabel ("Energy (eV)" , fontsize = 20 , fontweight = 'bold' )
586+ else :
587+ plt .xlabel ("Wavelength (nm)" , fontsize = 20 , fontweight = 'bold' )
572588 plt .ylabel ("Intensity (a.u.)" , fontsize = 20 , fontweight = 'bold' )
589+ plt .xlim ([self .exportplotwindow .ui .lowerX_spinBox .value (),self .exportplotwindow .ui .upperX_spinBox .value ()])
590+ plt .ylim ([self .exportplotwindow .ui .lowerY_spinBox .value (),self .exportplotwindow .ui .upperY_doubleSpinBox .value ()])
573591 plt .legend ()
574592 plt .tight_layout ()
575593
0 commit comments