diff --git a/addie/addiedriver.py b/addie/addiedriver.py index b9e5fdd8..e95e1b45 100644 --- a/addie/addiedriver.py +++ b/addie/addiedriver.py @@ -45,6 +45,12 @@ def calculate_sqAlt(self, ws_name, initType, outputType): OutputWorkspace=ws_name, From='F(Q)', To='S(Q)') + out_x_tmp = simpleapi.mtd[ws_name].readX(0) + out_y_tmp = simpleapi.mtd[ws_name].readY(0) + if abs(out_x_tmp[0]) < 1.E-5: + out_y_copy = out_y_tmp.copy() + out_y_copy[0] = out_y_copy[1] + simpleapi.mtd[ws_name].setY(0, out_y_copy) if outputType == 'S(Q)': # don't do anything return ws_name @@ -491,7 +497,7 @@ def load_sq(self, file_name): # The S(Q) file is in fact S(Q)-1 in sq file. So need to add 1 to # the workspace out_ws = AnalysisDataService.retrieve(sq_ws_name) - out_ws += 1 + # out_ws += 1 elif ext == 'SQ': try: simpleapi.LoadAscii( diff --git a/addie/calculate_gr/event_handler.py b/addie/calculate_gr/event_handler.py index 0a833f35..b9ff97f6 100644 --- a/addie/calculate_gr/event_handler.py +++ b/addie/calculate_gr/event_handler.py @@ -82,6 +82,9 @@ def load_sq(main_window): os.path.abspath(sq_file_names[0]))[0] check_in_fixed_dir_structure(main_window, 'SofQ') + sq_type = str(main_window.calculategr_ui.comboBox_inSofQType.currentText()) + main_window.sofq_type_in_mem = sq_type + # load S(q) for sq_file_name in sq_file_names: sq_file_name = str(sq_file_name) @@ -105,7 +108,13 @@ def load_sq(main_window): # plot S(Q) - TODO why is it getting the name again? ws_name = main_window._myController.get_current_sq_name() - plot_sq(main_window, ws_name, color=color, clear_prev=False) + plot_sq( + main_window, + ws_name, + color=color, + clear_prev=False, + is_load=True + ) # calculate and calculate G(R) generate_gr_step1(main_window) @@ -113,12 +122,17 @@ def load_sq(main_window): check_widgets_status(main_window) -def plot_sq(main_window, ws_name, color, clear_prev): +def plot_sq(main_window, + ws_name, + color, + clear_prev, + is_load=False): """ Plot S(Q) :param ws_name: :param sq_color: S(Q) color (if None, find it from PDF color manager) :param clear_prev: + :param is_load: initially loaded data to plot or not :return: """ # clear previous lines @@ -133,10 +147,25 @@ def plot_sq(main_window, ws_name, color, clear_prev): color = main_window._pdfColorManager.add_sofq(ws_name) # convert to the function to plot - sq_type = str(main_window.calculategr_ui.comboBox_SofQType.currentText()) - plottable_name = main_window._myController.calculate_sqAlt( - ws_name, main_window.sofq_type_in_mem, sq_type) - main_window.sofq_type_in_mem = sq_type + if is_load: + sq_type_in = str( + main_window.calculategr_ui.comboBox_SofQType.currentText() + ) + sq_type = str( + main_window.calculategr_ui.comboBox_inSofQType.currentText() + ) + plottable_name = main_window._myController.calculate_sqAlt( + ws_name, sq_type_in, sq_type + ) + main_window.sofq_type_in_mem = sq_type + else: + sq_type = str( + main_window.calculategr_ui.comboBox_inSofQType.currentText() + ) + plottable_name = main_window._myController.calculate_sqAlt( + ws_name, main_window.sofq_type_in_mem, sq_type + ) + main_window.sofq_type_in_mem = sq_type main_window.calculategr_ui.graphicsView_sq.plot_sq( plottable_name, @@ -616,8 +645,15 @@ def do_save_sq(main_window): # skip if the user cancel the operation on this S(Q) continue + sq_type = str( + main_window.calculategr_ui.comboBox_inSofQType.currentText() + ) + plottable_name = main_window._myController.calculate_sqAlt( + sq_name, "S(Q)", sq_type, + ) + # save file - main_window._myController.save_ascii(sq_name, filename, filetype) + main_window._myController.save_ascii(plottable_name, filename, filetype) def do_edit_sq(main_window): diff --git a/addie/calculate_gr/gofrtree.py b/addie/calculate_gr/gofrtree.py index 75286c83..f232bfd4 100644 --- a/addie/calculate_gr/gofrtree.py +++ b/addie/calculate_gr/gofrtree.py @@ -359,8 +359,16 @@ def do_plot(self): None, None, None, None, None, auto=True) + self._mainWindow.calculategr_ui.comboBox_inSofQType.setCurrentIndex(0) + self._mainWindow.sofq_type_in_mem = "S(Q)" for sq_name in sq_list: - event_handler.plot_sq(self._mainWindow, sq_name, None, False) + event_handler.plot_sq( + self._mainWindow, + sq_name, + None, + False + ) + def do_remove_from_plot(self): """ diff --git a/addie/initialization/events/calculategr_tab.py b/addie/initialization/events/calculategr_tab.py index 161a6b08..c035d9f4 100644 --- a/addie/initialization/events/calculategr_tab.py +++ b/addie/initialization/events/calculategr_tab.py @@ -1,6 +1,6 @@ def run(main_window=None): main_window.calculategr_ui.pushButton_loadSQ.clicked.connect(main_window.do_load_sq) - main_window.calculategr_ui.comboBox_SofQType.currentIndexChanged.connect(main_window.evt_change_sq_type) + main_window.calculategr_ui.comboBox_inSofQType.currentIndexChanged.connect(main_window.evt_change_sq_type) main_window.calculategr_ui.pushButton_rescaleSq.clicked.connect(main_window.do_rescale_sofq) main_window.calculategr_ui.pushButton_rescaleGr.clicked.connect(main_window.do_rescale_gofr) main_window.calculategr_ui.pushButton_clearSofQ.clicked.connect(main_window.do_clear_sq) diff --git a/addie/initialization/widgets/calculategr_tab.py b/addie/initialization/widgets/calculategr_tab.py index 1202a577..74098b0c 100644 --- a/addie/initialization/widgets/calculategr_tab.py +++ b/addie/initialization/widgets/calculategr_tab.py @@ -47,10 +47,15 @@ def run(main_window=None): as_current_index=False) main_window.calculategr_ui.comboBox_SofQType.clear() - main_window.calculategr_ui.comboBox_SofQType.addItem('S(Q)') main_window.calculategr_ui.comboBox_SofQType.addItem('S(Q)-1') + main_window.calculategr_ui.comboBox_SofQType.addItem('S(Q)') main_window.calculategr_ui.comboBox_SofQType.addItem('Q[S(Q)-1]') main_window.calculategr_ui.comboBox_SofQType.setCurrentIndex(0) + main_window.calculategr_ui.comboBox_inSofQType.clear() + main_window.calculategr_ui.comboBox_inSofQType.addItem('S(Q)') + main_window.calculategr_ui.comboBox_inSofQType.addItem('S(Q)-1') + main_window.calculategr_ui.comboBox_inSofQType.addItem('Q[S(Q)-1]') + main_window.calculategr_ui.comboBox_inSofQType.setCurrentIndex(0) main_window.calculategr_ui.comboBox_pdfType.addItems(['G(r)', 'g(r)', 'RDF(r)']) diff --git a/addie/ui/splitui_calculategr_tab.ui b/addie/ui/splitui_calculategr_tab.ui index 42cf0095..13a59658 100644 --- a/addie/ui/splitui_calculategr_tab.ui +++ b/addie/ui/splitui_calculategr_tab.ui @@ -165,6 +165,32 @@ + + + S(Q)-1 + + + + + S(Q) + + + + + Q[S(Q)-1] + + + + + + + + SQ Form to Present/Output + + + + + S(Q)