Esempio n. 1
0
    def plot_1d(self):

        self.parent.ui.graphicsView_fitResult.reset_viewer()

        # get the sample log/meta data name
        o_gui = GuiUtilities(parent=self.parent)
        x_axis_name = str(self.parent.ui.comboBox_xaxisNames.currentText())
        y_axis_name = str(self.parent.ui.comboBox_yaxisNames.currentText())
        x_axis_peak_index = o_gui.get_plot1d_axis_peak_label_index(is_xaxis=True)
        y_axis_peak_index = o_gui.get_plot1d_axis_peak_label_index(is_xaxis=False)

        o_data_retriever = DataRetriever(parent=self.parent)

        is_plot_with_error = False

        axis_x_data, axis_x_error = o_data_retriever.get_data(name=x_axis_name, peak_index=x_axis_peak_index)
        axis_y_data, axis_y_error = o_data_retriever.get_data(name=y_axis_name, peak_index=y_axis_peak_index)

        if ((x_axis_name in LIST_AXIS_TO_PLOT['fit'].keys()) or
                (y_axis_name in LIST_AXIS_TO_PLOT['fit'].keys())):
            is_plot_with_error = True

        # is_plot_with_error = False  # REMOVE that line once the error bars are correctAT
        if is_plot_with_error:
            self.parent.ui.graphicsView_fitResult.plot_scatter_with_errors(vec_x=axis_x_data,
                                                                           vec_y=axis_y_data,
                                                                           vec_x_error=axis_x_error,
                                                                           vec_y_error=axis_y_error,
                                                                           x_label=x_axis_name,
                                                                           y_label=y_axis_name)
        else:
            self.parent.ui.graphicsView_fitResult.plot_scatter(axis_x_data,
                                                               axis_y_data,
                                                               x_axis_name,
                                                               y_axis_name)
Esempio n. 2
0
    def update_fit_peak_ranges_table(self, **kwargs):

        self.parent.ui.peak_range_table.blockSignals(True)

        def __get_kwargs_value(key='', data_type='boolean'):
            if data_type == 'boolean':
                _default = False
            elif data_type == 'array':
                _default = []
            return kwargs[key] if key in kwargs.keys() else _default

        # click = __get_kwargs_value('click', data_type='boolean')
        # move = __get_kwargs_value('move', data_type='boolean')
        # release = __get_kwargs_value('release', data_type='boolean')

        list_fit_peak_ranges = __get_kwargs_value('list_fit_peak_ranges',
                                                  data_type='array')
        # list_fit_peak_ranges_matplotlib_id = __get_kwargs_value('list_fit_peak_ranges_matplotlib_id',
        #                                                         data_type='array')
        list_fit_peak_labels = __get_kwargs_value('list_fit_peak_labels',
                                                  data_type='array')
        list_fit_peak_d0 = __get_kwargs_value('list_fit_peak_d0',
                                              data_type='array')

        o_gui = GuiUtilities(parent=self.parent)
        o_gui.reset_peak_range_table()
        o_gui.fill_peak_range_table(list_fit_peak_ranges=list_fit_peak_ranges,
                                    list_fit_peak_labels=list_fit_peak_labels,
                                    list_fit_peak_d0=list_fit_peak_d0)

        self.parent.ui.peak_range_table.blockSignals(False)
        o_gui.check_if_fitting_widgets_can_be_enabled()
Esempio n. 3
0
    def fit_multi_peaks(self):

        QApplication.setOverrideCursor(Qt.WaitCursor)

        _peak_range_list = [
            tuple(_range) for _range in
            self.parent._ui_graphicsView_fitSetup.list_peak_ranges
        ]
        _peak_center_list = [
            np.mean([left, right]) for (left, right) in _peak_range_list
        ]
        _peak_tag_list = [
            "peak{}".format(_index)
            for _index, _ in enumerate(_peak_center_list)
        ]
        _peak_function_name = str(
            self.parent.ui.comboBox_peakType.currentText())

        _peak_xmin_list = [left for (left, _) in _peak_range_list]
        _peak_xmax_list = [right for (_, right) in _peak_range_list]

        # Fit peak
        hd_ws = self.parent.hidra_workspace

        _wavelength = hd_ws.get_wavelength(True, True)
        fit_engine = PeakFitEngineFactory.getInstance(hd_ws,
                                                      _peak_function_name,
                                                      'Linear',
                                                      wavelength=_wavelength)
        fit_result = fit_engine.fit_multiple_peaks(_peak_tag_list,
                                                   _peak_xmin_list,
                                                   _peak_xmax_list)
        self.parent.fit_result = fit_result

        self.parent.populate_fit_result_table(fit_result=fit_result)
        # self.parent.update_list_of_2d_plots_axis()

        o_gui = GuiUtilities(parent=self.parent)
        o_gui.set_1D_2D_axis_comboboxes(with_clear=True,
                                        fill_raw=True,
                                        fill_fit=True)
        o_gui.initialize_combobox()
        o_gui.enabled_export_csv_widgets(enabled=True)
        o_gui.enabled_2dplot_widgets(enabled=True)

        o_plot = Plot(parent=self.parent)
        o_plot.plot_2d()

        QApplication.restoreOverrideCursor()
Esempio n. 4
0
    def peak_range_table_right_click(self, position=-1):

        nbr_row = self.parent.ui.peak_range_table.rowCount()
        if nbr_row == 0:
            return

        menu = QMenu(self.parent)
        _remove_row = menu.addAction("Remove")
        action = menu.exec_(QCursor.pos())

        if action == _remove_row:
            self.remove_peak_range_table_row()

        o_gui = GuiUtilities(parent=self.parent)
        o_gui.check_if_fitting_widgets_can_be_enabled()
Esempio n. 5
0
    def update_fit_peak_ranges_plot(self):
        # retrieve all peaks and labels from table
        table_ui = self.parent.ui.peak_range_table
        table_ui.blockSignals(True)

        nbr_row = table_ui.rowCount()

        list_peak_ranges = []
        list_fit_peak_labels = []
        list_fit_peak_d0 = []
        for _row in np.arange(nbr_row):
            _value1 = GuiUtilities.get_item_value(table_ui, _row, 0)
            _value2 = GuiUtilities.get_item_value(table_ui, _row, 1)

            try:
                _value1_float = np.float(_value1)
                _value2_float = np.float(_value2)
                _array = [_value1_float, _value2_float]

                _value1 = np.nanmin(_array)
                _value2 = np.nanmax(_array)

                _item0 = QTableWidgetItem("{:.3f}".format(_value1))
                self.parent.ui.peak_range_table.setItem(_row, 0, _item0)

                _item1 = QTableWidgetItem("{:.3f}".format(_value2))
                self.parent.ui.peak_range_table.setItem(_row, 1, _item1)

                list_peak_ranges.append([_value1, _value2])

            except ValueError:
                continue

            _label = GuiUtilities.get_item_value(table_ui, _row, 2)
            list_fit_peak_labels.append(_label)

            _d0 = np.float(str(GuiUtilities.get_item_value(table_ui, _row, 3)))
            list_fit_peak_d0.append(_d0)

        # replace the list_peak_ranges and list_fit_peak_labels from mplfitplottingwidget.py
        self.parent._ui_graphicsView_fitSetup.list_peak_ranges = list_peak_ranges
        self.parent._ui_graphicsView_fitSetup.list_fit_peak_labels = list_fit_peak_labels
        self.parent._ui_graphicsView_fitSetup.list_fit_peak_d0 = list_fit_peak_d0
        self.parent._ui_graphicsView_fitSetup.plot_data_with_fitting_ranges()

        table_ui.blockSignals(False)
Esempio n. 6
0
 def fit_table_selection_changed(self):
     '''as soon as a row is selected, switch to the slider view and go to right sub_run'''
     row_selected = GuiUtilities.get_row_selected(
         table_ui=self.parent.ui.tableView_fitSummary)
     if row_selected is None:
         return
     self.parent.ui.radioButton_individualSubRuns.setChecked(True)
     self.parent.check_subRunsDisplayMode()
     self.parent.ui.horizontalScrollBar_SubRuns.setValue(row_selected + 1)
     self.parent.plot_scan()
Esempio n. 7
0
    def load(self, project_file=None):
        if project_file is None:
            return

        try:
            self.__set_up_project_name(project_file=project_file)
            ws = self.parent._core.load_hidra_project(
                project_file,
                project_name=self.parent._project_name,
                load_detector_counts=False,
                load_diffraction=True)

            # Record data key and next
            self.parent._curr_file_name = project_file
            self.parent.hidra_workspace = ws
            self.parent.create_plot_color_range()
        except (RuntimeError, TypeError) as run_err:
            pop_message(self,
                        'Unable to load {}'.format(project_file),
                        detailed_message=str(run_err),
                        message_type='error')

        # # Edit information on the UI for user to visualize
        # self.parent.ui.label_loadedFileInfo.setText('Loaded {}; Project name: {}'
        #                                             .format(project_file, self.parent._project_name))

        # Get and set the range of sub runs
        o_utility = Utilities(parent=self.parent)
        sub_run_list = o_utility.get_subruns_limit()

        o_gui = GuiUtilities(parent=self.parent)
        o_gui.initialize_fitting_slider(max=len(sub_run_list))

        o_gui.set_1D_2D_axis_comboboxes(with_clear=True, fill_raw=True)
        o_gui.enabled_1dplot_widgets(enabled=True)
        o_gui.initialize_combobox()
Esempio n. 8
0
    def list_subruns_2dplot(self):
        raw_input = str(self.parent.ui.lineEdit_subruns_2dplot.text())
        o_gui = GuiUtilities(parent=self.parent)

        try:
            parse_input = parse_integers(raw_input)
            o_gui.make_visible_listsubruns_warning(False)
        except RuntimeError:
            o_gui.make_visible_listsubruns_warning(True)

        return parse_input
Esempio n. 9
0
    def fit_peaks(self, all_sub_runs=False):
        """ Fit peaks either all peaks or selected peaks
        The workflow includes
        1. parse sub runs, peak and background type
        2. fit peaks
        3. show the fitting result in table
        4. plot the peak in first sub runs that is fit
        :param all_sub_runs: Flag to fit peaks of all sub runs without checking
        :return:
        """
        # Get the sub runs to fit or all the peaks
        # if not all_sub_runs:
        #     # Parse sub runs specified in lineEdit_scanNumbers
        #     o_utilities = Utilities(parent=self.parent)
        #     sub_run_list = o_utilities.parse_sub_runs()
        # else:
        sub_run_list = None

        # Get peak function and background function
        peak_function = str(self.parent.ui.comboBox_peakType.currentText())
        bkgd_function = str(
            self.parent.ui.comboBox_backgroundType.currentText())

        # Get peak fitting range from the range of figure
        fit_range = self.parent._ui_graphicsView_fitSetup.get_x_limit()
        print('[INFO] Peak fit range: {0}'.format(fit_range))

        # Fit Peaks: It is better to fit all the peaks at the same time after testing
        guessed_peak_center = 0.5 * (fit_range[0] + fit_range[1])
        peak_info_dict = {
            'Peak 1': {
                'Center': guessed_peak_center,
                'Range': fit_range
            }
        }
        self.parent._core.fit_peaks(project_name=self.parent._project_name,
                                    sub_run_list=sub_run_list,
                                    peak_type=peak_function,
                                    background_type=bkgd_function,
                                    peaks_fitting_setup=peak_info_dict)

        # Process fitted peaks
        # TEST - #84 - This shall be reviewed!
        try:
            # FIXME - effective_parameter=True will fail!
            # FIXME - other than return_format=dict will fail!
            # FIXME - need to give a real value to default_tag
            # FIXME - this only works if fitting 1 peak a time
            default_tag = peak_info_dict.keys()[0]
            function_params, fit_values = self.parent._core.get_peak_fitting_result(
                self.parent._project_name,
                default_tag,
                return_format=dict,
                effective_parameter=False,
                fitting_function=peak_function)
        except AttributeError as err:
            pop_message(self, 'Zoom in/out to only show peak to fit!',
                        str(err), "error")
            return

        # TODO - #84+ - Need to implement the option as effective_parameter=True

        print('[DB...BAT...FITWINDOW....FIT] returned = {}, {}'.format(
            function_params, fit_values))

        self.parent._sample_log_names_mutex = True
        for param_name in function_params:
            self.parent._function_param_name_set.add(param_name)

        # # log index and center of mass
        # size_x = len(self.parent._sample_log_names) + len(self.parent._function_param_name_set) + 2
        #
        # # center of mass
        # size_y = len(self.parent._sample_log_names) + len(self.parent._function_param_name_set) + 1

        # release the mutex: because re-plot is required anyway
        self.parent._sample_log_names_mutex = False

        # Show fitting result in Table
        # TODO - could add an option to show native or effective peak parameters
        try:
            self.show_fit_result_table(peak_function,
                                       function_params,
                                       fit_values,
                                       is_effective=False)
        except IndexError:
            return

        # plot the model and difference
        if sub_run_list is None:
            o_plot = Plot(parent=self.parent)
            o_plot.plot_diff_and_fitted_data(1, True)

        o_gui = GuiUtilities(parent=self.parent)
        o_gui.set_1D_2D_axis_comboboxes(fill_fit=True)
        o_gui.enabled_export_csv_widgets(True)
Esempio n. 10
0
    def plot_2d(self):

        o_gui = GuiUtilities(parent=self.parent)
        x_axis_name = str(
            self.parent.ui.comboBox_xaxisNames_2dplot.currentText())
        y_axis_name = str(
            self.parent.ui.comboBox_yaxisNames_2dplot.currentText())
        z_axis_name = str(
            self.parent.ui.comboBox_zaxisNames_2dplot.currentText())

        x_axis_peak_index = o_gui.get_plot2d_axis_peak_label_index(axis='x')
        y_axis_peak_index = o_gui.get_plot2d_axis_peak_label_index(axis='y')
        z_axis_peak_index = o_gui.get_plot2d_axis_peak_label_index(axis='z')

        o_data_retriever = DataRetriever(parent=self.parent)

        axis_x_data, axis_x_error = o_data_retriever.get_data(
            name=x_axis_name, peak_index=x_axis_peak_index)
        axis_y_data, axis_y_error = o_data_retriever.get_data(
            name=y_axis_name, peak_index=y_axis_peak_index)
        axis_z_data, axis_z_error = o_data_retriever.get_data(
            name=z_axis_name, peak_index=z_axis_peak_index)

        if not self.parent.ui.radioButton_3dscatter.isChecked():

            array_dict = self.format_3D_axis_data(axis_x=axis_x_data,
                                                  axis_y=axis_y_data,
                                                  axis_z=axis_z_data)
            x_axis = array_dict['x_axis']
            y_axis = array_dict['y_axis']
            z_axis = array_dict['z_axis']

            if len(x_axis) < 2:
                return

        self.parent.ui.graphicsView_plot2D.ax.clear()
        if self.parent.ui.graphicsView_plot2D.colorbar:
            self.parent.ui.graphicsView_plot2D.colorbar.remove()
            self.parent.ui.graphicsView_plot2D.colorbar = None

        if self.parent.ui.radioButton_contour.isChecked():

            self.parent.ui.graphicsView_plot2D.ax = self.parent.ui.graphicsView_plot2D.figure.gca(
            )
            my_plot = self.parent.ui.graphicsView_plot2D.ax.contourf(
                x_axis, y_axis, z_axis)

            self.parent.ui.graphicsView_plot2D.colorbar = \
                self.parent.ui.graphicsView_plot2D.figure.colorbar(my_plot)
            self.parent.ui.graphicsView_plot2D._myCanvas.draw()

            self.parent.ui.graphicsView_plot2D.ax.set_xlabel(x_axis_name)
            self.parent.ui.graphicsView_plot2D.ax.set_ylabel(y_axis_name)

        elif self.parent.ui.radioButton_3dline.isChecked():

            x, y = np.meshgrid(x_axis, y_axis)

            self.parent.ui.graphicsView_plot2D.ax = self.parent.ui.graphicsView_plot2D.figure.gca(
                projection='3d')
            my_plot = self.parent.ui.graphicsView_plot2D.ax.plot_surface(
                x, y, z_axis, cmap=cm.coolwarm, linewidth=0, antialiased=False)
            self.parent.ui.graphicsView_plot2D.colorbar = self.parent.ui.graphicsView_plot2D.figure.colorbar(
                my_plot)
            self.parent.ui.graphicsView_plot2D.ax.set_xlabel(x_axis_name)
            self.parent.ui.graphicsView_plot2D.ax.set_ylabel(y_axis_name)
            self.parent.ui.graphicsView_plot2D.ax.set_zlabel(z_axis_name)

            # maybe look at projections on the wall (matplotlib.org/gallery/mplot3d/contour3d_3.html)
            self.parent.ui.graphicsView_plot2D.ax.contour(
                x,
                y,
                z_axis,
                zdir='z',
                offset=np.nanmin(z_axis),
                cmap=cm.coolwarm)
            self.parent.ui.graphicsView_plot2D.ax.contour(x,
                                                          y,
                                                          z_axis,
                                                          zdir='y',
                                                          offset=np.nanmax(y),
                                                          cmap=cm.coolwarm)
            self.parent.ui.graphicsView_plot2D.ax.contour(x,
                                                          y,
                                                          z_axis,
                                                          zdir='x',
                                                          offset=np.nanmax(x),
                                                          cmap=cm.coolwarm)

            self.parent.ui.graphicsView_plot2D._myCanvas.draw()

        else:

            self.parent.ui.graphicsView_plot2D.ax = self.parent.ui.graphicsView_plot2D.figure.gca(
                projection='3d')
            self.parent.ui.graphicsView_plot2D.ax.scatter(
                axis_x_data, axis_y_data, axis_z_data)
            self.parent.ui.graphicsView_plot2D._myCanvas.draw()

            self.parent.ui.graphicsView_plot2D.ax.set_xlabel(x_axis_name)
            self.parent.ui.graphicsView_plot2D.ax.set_ylabel(y_axis_name)
            self.parent.ui.graphicsView_plot2D.ax.set_zlabel(z_axis_name)
Esempio n. 11
0
    def load_and_plot(self, hidra_file_name):
        try:
            o_load = Load(parent=self.parent)
            o_load.load(project_file=hidra_file_name)

        except RuntimeError as run_err:
            pop_message(self, 'Failed to load {}'.format(hidra_file_name),
                        str(run_err), 'error')
        except KeyError as key_err:
            pop_message(self, 'Failed to load {}'.format(hidra_file_name),
                        str(key_err), 'error')

        self.parent.current_root_statusbar_message = "Working with: {} " \
                                                     "\t\t\t\t Project Name: {}" \
                                                     "".format(hidra_file_name,
                                                               self.parent._project_name)
        self.parent.ui.statusbar.showMessage(
            self.parent.current_root_statusbar_message)

        try:
            o_plot = Plot(parent=self.parent)
            o_plot.plot_diff_data(plot_model=False)
            o_plot.reset_fitting_plot()

        except RuntimeError as run_err:
            pop_message(self, 'Failed to plot {}'.format(hidra_file_name),
                        str(run_err), 'error')

        try:
            o_fit = Fit(parent=self.parent)
            o_fit.initialize_fitting_table()

            # enabled all fitting widgets and main plot
            o_gui = GuiUtilities(parent=self.parent)
            o_gui.check_if_fitting_widgets_can_be_enabled()
            o_gui.enabled_sub_runs_interation_widgets(True)
            # o_gui.enabled_fitting_widgets(True)
            o_gui.enabled_data_fit_plot(True)
            o_gui.enabled_peak_ranges_widgets(True)
            o_gui.enabled_1dplot_widgets(True)

        except RuntimeError as run_err:
            pop_message(
                self,
                'Failed to initialize widgets for {}'.format(hidra_file_name),
                str(run_err), 'error')
Esempio n. 12
0
    def setup_ui(self):
        """define the layout, widgets and signals"""

        # promote
        self.ui.graphicsView_fitResult = qt_util.promote_widget(self, self.ui.graphicsView_fitResult_frame,
                                                                GeneralDiffDataView)
        self.ui.graphicsView_fitResult.setEnabled(False)
        self.ui.graphicsView_fitResult.set_subplots(1, 1)
        self.ui.graphicsView_plot2D = qt_util.promote_widget(self, self.ui.graphicsView_2dPlot_frame,
                                                             MplGraphicsViewContourPlot)
        self.ui.tableView_fitSummary = qt_util.promote_widget(self, self.ui.tableView_fitSummary_frame,
                                                              FitResultTable)
        self._promote_peak_fit_setup()
        self._init_widgets()

        # set up handling
        self.ui.pushButton_browseHDF.clicked.connect(self.browse_hdf)
        self.ui.lineEdit_listSubRuns.returnPressed.connect(self.plot_diff_data)
        self.ui.pushButton_FitPeaks.clicked.connect(self.fit_peaks)
        self.ui.horizontalScrollBar_SubRuns.valueChanged.connect(self.plot_scan)
        self.ui.radioButton_individualSubRuns.clicked.connect(self.individual_sub_runs)
        self.ui.radioButton_listSubRuns.clicked.connect(self.list_sub_runs)
        self.ui.actionQuit.triggered.connect(self.do_quit)
        self.ui.actionSave.triggered.connect(self.save)
        self.ui.actionSaveAs.triggered.connect(self.save_as)
        self.ui.actionAdvanced_Peak_Fit_Settings.triggered.connect(self.do_launch_adv_fit)
        self.ui.pushButton_exportCSV.clicked.connect(self.export_csv)
        self.ui.actionQuick_Fit_Result_Check.triggered.connect(self.do_make_movie)
        self.ui.lineEdit_subruns_2dplot.returnPressed.connect(self.list_subruns_2dplot_returned)
        self.ui.lineEdit_subruns_2dplot.textChanged.connect(self.list_subruns_2dplot_changed)
        self.ui.pushButton_save_peak_range.clicked.connect(self.clicked_save_peak_range)
        self.ui.pushButton_load_peak_range.clicked.connect(self.clicked_load_peak_range)
        self.ui.tableView_fitSummary.itemSelectionChanged.connect(self.fit_result_table_selection_changed)

        self.ui.radioButton_fit_value.clicked.connect(self.fit_table_radio_buttons)
        self.ui.radioButton_fit_error.clicked.connect(self.fit_table_radio_buttons)
        self.ui.spinBox_peak_index.valueChanged.connect(self.fit_table_radio_buttons)

        self.ui.comboBox_xaxisNames.currentIndexChanged.connect(self.axis_1d_changed)
        self.ui.comboBox_yaxisNames.currentIndexChanged.connect(self.axis_1d_changed)
        self.ui.plot1d_xaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_1d_changed)
        self.ui.plot1d_yaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_1d_changed)

        self.ui.comboBox_xaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed)
        self.ui.comboBox_yaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed)
        self.ui.comboBox_zaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed)
        self.ui.plot2d_xaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed)
        self.ui.plot2d_yaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed)
        self.ui.plot2d_zaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed)

        self.ui.radioButton_contour.clicked.connect(self.axis_2d_changed)
        self.ui.radioButton_3dline.clicked.connect(self.axis_2d_changed)
        self.ui.radioButton_3dscatter.clicked.connect(self.axis_2d_changed)

        self.ui.peak_range_table.cellChanged.connect(self.peak_range_table_changed)

        # tracker for sample log names and peak parameter names
        self._sample_log_name_set = set()
        self._function_param_name_set = set()

        # mutexes
        self._sample_log_names_mutex = False

        # TODO - 20181124 - New GUI parameters (After FitPeaks)
        # checkBox_showFitError
        # checkBox_showFitValue
        # others
        # TODO - 20181124 - Make this table's column flexible!
        self.ui.tableView_fitSummary.setup(peak_param_names=list())

        o_gui = GuiUtilities(parent=self)
        o_gui.enabled_fitting_widgets(False)
        o_gui.enabled_1dplot_widgets(False)
        o_gui.check_axis1d_status()
        o_gui.enabled_2dplot_widgets(False)
        o_gui.check_axis2d_status()
        o_gui.make_visible_listsubruns_warning(False)
        o_gui.enabled_export_csv_widgets(False)
        o_gui.enabled_peak_ranges_widgets(False)
        o_gui.enabled_save_peak_range_widget(False)
        o_gui.enabled_sub_runs_interation_widgets(False)

        # for debugging only
        self.ui.radioButton_contour.setEnabled(False)
        self.ui.radioButton_3dline.setEnabled(False)
Esempio n. 13
0
 def update_save_peak_range_widget(self):
     o_gui = GuiUtilities(parent=self)
     o_gui.update_save_peak_range_widget_status()
Esempio n. 14
0
 def axis_2d_changed(self):
     o_gui = GuiUtilities(parent=self)
     o_gui.check_axis2d_status()
     o_plot = Plot(parent=self)
     o_plot.plot_2d()
Esempio n. 15
0
 def check_subRunsDisplayMode(self):
     o_gui = GuiUtilities(parent=self)
     o_gui.check_subRuns_display_mode()
Esempio n. 16
0
    def browse_load_plot_hdf(self):
        if self.parent._core is None:
            raise RuntimeError('Not set up yet!')

        # o_utility = Utilities(parent=self.parent)
        # hydra_file_name = o_utility.get_default_hdf()
        hidra_file_name = None
        if hidra_file_name is None:
            # No default Hidra file: browse the file
            file_filter = 'HDF (*.hdf);H5 (*.h5)'
            hidra_file_name = browse_file(self.parent,
                                          'HIDRA Project File',
                                          os.getcwd(),
                                          file_filter,
                                          file_list=False,
                                          save_file=False)

            if hidra_file_name is None:
                return  # user clicked cancel

        self.parent.current_hidra_file_name = hidra_file_name
        try:
            o_load = Load(parent=self.parent)
            o_load.load(project_file=hidra_file_name)

        except RuntimeError as run_err:
            pop_message(self, 'Failed to load {}'.format(hidra_file_name),
                        str(run_err), 'error')
        except KeyError as key_err:
            pop_message(self, 'Failed to load {}'.format(hidra_file_name),
                        str(key_err), 'error')

        self.parent.current_root_statusbar_message = "Working with: {} " \
                                                     "\t\t\t\t Project Name: {}" \
                                                     "".format(hidra_file_name,
                                                               self.parent._project_name)
        self.parent.ui.statusbar.showMessage(
            self.parent.current_root_statusbar_message)

        try:
            o_plot = Plot(parent=self.parent)
            o_plot.plot_diff_data(plot_model=False)
            o_plot.reset_fitting_plot()

        except RuntimeError as run_err:
            pop_message(self, 'Failed to plot {}'.format(hidra_file_name),
                        str(run_err), 'error')

        try:
            o_fit = Fit(parent=self.parent)
            o_fit.initialize_fitting_table()

            # enabled all fitting widgets and main plot
            o_gui = GuiUtilities(parent=self.parent)
            o_gui.check_if_fitting_widgets_can_be_enabled()
            o_gui.enabled_sub_runs_interation_widgets(True)
            # o_gui.enabled_fitting_widgets(True)
            o_gui.enabled_data_fit_plot(True)
            o_gui.enabled_peak_ranges_widgets(True)
            o_gui.enabled_1dplot_widgets(True)

        except RuntimeError as run_err:
            pop_message(
                self,
                'Failed to initialize widgets for {}'.format(hidra_file_name),
                str(run_err), 'error')