def export_bragg_peak_profile(self): working_dir = str(Path(self.parent.working_dir).parent) _export_folder = QFileDialog.getExistingDirectory(self.parent, directory=working_dir, caption="Select Output Folder") QtGui.QGuiApplication.processEvents() # to close QFileDialog if _export_folder: o_gui = GuiUtility(parent=self.parent) list_row_selected = o_gui.get_rows_of_table_selected(table_ui=self.parent.ui.bragg_edge_tableWidget) for row_selected in list_row_selected: # make up output file name name_of_row = o_gui.get_table_str_item(table_ui=self.parent.ui.bragg_edge_tableWidget, row=row_selected, column=0) [x0, y0, width, height] = name_of_row.split("; ") name_of_row_formatted = "x0{}_y0{}_width{}_height{}".format(x0,y0, width, height) file_name = "kropff_bragg_peak_profile_{}.txt".format(name_of_row_formatted) full_file_name = str(Path(_export_folder) / Path(file_name)) o_fit = KropffFittingJobHandler(parent=self.parent) o_fit.prepare(kropff_tooldbox='bragg_peak') x_axis = o_fit.xaxis_to_fit y_axis = o_fit.list_yaxis_to_fit[row_selected] a0 = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['high']['a0'] b0 = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['high']['b0'] ahkl = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['low']['ahkl'] bhkl = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['low']['bhkl'] metadata = ["# Bragg peak fitting of row {}".format(row_selected+1)] metadata.append("# x0: {}".format(x0)) metadata.append("# y0: {}".format(y0)) metadata.append("# width: {}".format(width)) metadata.append("# height: {}".format(height)) metadata.append("# a0: {}".format(a0)) metadata.append("# b0: {}".format(b0)) metadata.append("# ahkl: {}".format(ahkl)) metadata.append("# bhkl: {}".format(bhkl)) metadata.append("#") metadata.append("# lambda (Angstroms), average transmission") make_ascii_file_from_2dim_array(metadata=metadata, col1=x_axis, col2=y_axis, output_file_name=full_file_name) message = "Exported {} file(s) in {}".format(len(list_row_selected), _export_folder) self.parent.ui.statusbar.showMessage(message, 15000) # 15s self.parent.ui.statusbar.setStyleSheet("color: green")
def kropff_fit_bragg_peak_region_of_selected_rows(self, list_row_to_fit=None): self.switch_fitting_axis_to('lambda') o_fit = KropffFittingJobHandler(parent=self) o_fit.prepare(kropff_tooldbox='bragg_peak') o_fit.run_bragg_peak(update_table_ui=True, list_row_to_fit=list_row_to_fit) self.update_fitting_plot() self.update_kropff_fit_table_graph(fit_region='bragg_peak')
def kropff_fit_low_lambda_region_clicked(self): self.switch_fitting_axis_to('lambda') o_fit = KropffFittingJobHandler(parent=self) o_fit.prepare(kropff_tooldbox='low') o_fit.run_kropff_low_lambda(update_table_ui=True) self.update_fitting_plot() self.update_kropff_fit_table_graph(fit_region='low')