Esempio n. 1
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. 2
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')