Beispiel #1
0
    def kropff_fitting_range_changed(self):
        [global_left_range, global_right_range] = self.bragg_edge_range

        if not self.fitting_peak_ui:
            return

        [left_range, right_range] = list(self.fitting_peak_ui.getRegion())
        xaxis_dict = self.fitting_input_dictionary['xaxis']
        o_get = Get(parent=self)
        x_axis_selected = o_get.x_axis_checked()
        xaxis_index, _ = xaxis_dict[x_axis_selected]

        [left_xaxis_index, right_xaxis_index] = self.bragg_edge_range
        xaxis = xaxis_index[left_xaxis_index: right_xaxis_index]

        left_index = find_nearest_index(array=xaxis, value=left_range)
        right_index = find_nearest_index(array=xaxis, value=right_range)

        global_left_index = find_nearest_index(array=xaxis, value=global_left_range)
        global_right_index = find_nearest_index(array=xaxis, value=global_right_range)

        self.kropff_fitting_range['high'] = [right_index, global_right_index]
        self.kropff_fitting_range['low'] = [global_left_index, left_index]
        self.kropff_fitting_range['bragg_peak'] = [left_index, right_index]
        self.bragg_peak_selection_range = [left_index, right_index]

        o_kropff = Kropff(parent=self)
        o_kropff.update_roi_labels()
Beispiel #2
0
    def update_fitting_plot(self):
        o_gui = GuiUtility(parent=self)
        algorithm_tab_selected = o_gui.get_tab_selected(tab_ui=self.ui.tab_algorithm)

        if algorithm_tab_selected == 'Kropff':
            o_kropff = Kropff(parent=self)
            o_kropff.update_fitting_plot()

        elif algorithm_tab_selected == 'March-Dollase':
            o_march = MarchDollase(parent=self)
            o_march.update_fitting_plot()
Beispiel #3
0
    def fit_that_selection_pushed_by_program(self, initialize_region=True):
        o_get = Get(parent=self)
        x_axis = o_get.all_x_axis()
        dict_regions = o_get.all_russian_doll_region_full_infos()

        o_init = PeakFittingInitialization(parent=self)
        fitting_input_dictionary = o_init.fitting_input_dictionary(nbr_rois=len(dict_regions))
        o_init.set_top_keys_values(fitting_input_dictionary,
                                   {'xaxis': x_axis,
                                    'bragg_edge_range': self.bragg_edge_range})
        self.append_dict_regions_to_fitting_input_dictionary(dict_regions, fitting_input_dictionary)

        # fitting_input_dictionary['xaxis'] = x_axis
        # fitting_input_dictionary['bragg_edge_range'] = self.bragg_edge_range

        self.fitting_input_dictionary = fitting_input_dictionary

        o_kropff = Kropff(parent=self)
        o_kropff.reset_all_table()

        o_march = MarchDollase(parent=self)
        o_march.reset_table()

        if initialize_region:
            self.initialize_default_peak_regions()
        else:
            if self.fitting_procedure_started['kropff']:
                o_kropff.fill_table_with_fitting_information()
        o_march.fill_tables_with_fitting_information()

        if initialize_region:
            o_march_fitting = MarchDollaseFittingJobHandler(parent=self)
            o_march_fitting.initialize_fitting_input_dictionary()

        self.ui.tabWidget.setTabEnabled(1, True)
        self.ui.actionExport.setEnabled(True)
        self.select_first_row_of_all_fitting_table()
Beispiel #4
0
 def kropff_bragg_peak_right_click(self, position):
     o_kropff = Kropff(parent=self)
     o_kropff.bragg_peak_right_click(position=position)
Beispiel #5
0
    def run(self):
        working_dir = str(Path(self.parent.working_dir).parent)
        ascii_file = QFileDialog.getOpenFileName(self.parent,
                                                 caption="Select ASCII file",
                                                 directory=working_dir,
                                                 filter="ASCII (*.txt)")

        if ascii_file[0]:

            self.parent.full_reset_of_ui()
            self.parent.block_table_ui(True)
            self.parent.is_file_imported = True
            result_of_import = read_bragg_edge_fitting_ascii_format(
                full_file_name=str(ascii_file[0]))
            self.save_initial_roi_dimension_from_config_file(
                result_of_import['metadata']['columns']['3'])
            self.save_march_dollase_parameters(result_of_import['metadata'])
            self.parent.bragg_edge_range = result_of_import['metadata'][
                'bragg_edge_range']
            self.parent.bragg_peak_selection_range = result_of_import[
                'metadata']['bragg_peak_selection_range']

            self.update_selection_tab(result_of_import=result_of_import)
            self.update_interface(result_of_import=result_of_import)

            self.parent.ui.statusbar.showMessage(
                "{} has been imported!".format(ascii_file[0]), 10000)  # 10s
            self.parent.ui.statusbar.setStyleSheet("color: green")

            o_selection = BraggEdgeSelectionTab(parent=self.parent)
            o_selection.update_profile_of_bin_slider_widget()
            o_selection.update_selection_plot()

            self.parent.ui.tabWidget.setTabEnabled(
                1, self.parent.is_fit_infos_loaded())
            self.parent.ui.tabWidget.setEnabled(True)
            self.parent.ui.actionExport.setEnabled(True)

            self.parent.fitting_procedure_started[
                'kropff'] = result_of_import.get('metadata').get(
                    'kropff fitting '
                    'procedure '
                    'started', False)
            self.parent.fitting_procedure_started[
                'march-dollase'] = result_of_import.get('metadata').get(
                    'march-dollase fitting procedure started', False)

            o_kropff = Kropff(parent=self.parent)
            o_kropff.reset_all_table()

            o_march = MarchDollase(parent=self.parent)
            o_march.reset_table()

            if result_of_import.get('metadata').get(
                    'kropff fitting procedure started', False):
                # fill tables with minimum contains
                o_kropff.fill_table_with_fitting_information()

            if result_of_import.get('metadata').get(
                    'march-dollase fitting procedure started', False):
                # fill tables with minimum contains
                o_march.fill_tables_with_fitting_information()
            o_march.fill_history_table_with_fitting_information()

            self.parent.select_first_row_of_all_fitting_table()

            # self.parent.initialize_default_peak_regions()

            self.parent.block_table_ui(False)
            self.parent.update_vertical_line_in_profile_plot()
            self.parent.update_fitting_plot()
            self.parent.kropff_fitting_range_changed()

            o_gui = GuiUtility(parent=self.parent)
            o_gui.check_status_of_kropff_fitting_buttons()