def handle_guess_alpha(self, pair_name, group1_name, group2_name):
        """
        Calculate alpha for the pair for which "Guess Alpha" button was clicked.
        """
        if len(self._model._data.current_runs) > 1:
            run, index, ok_clicked = RunSelectionDialog.get_run(
                self._model._data.current_runs, self._model._data.instrument,
                self._view)
            if not ok_clicked:
                return
            run_to_use = self._model._data.current_runs[index]
        else:
            run_to_use = self._model._data.current_runs[0]

        try:
            ws1 = self._model.get_group_workspace(group1_name, run_to_use)
            ws2 = self._model.get_group_workspace(group2_name, run_to_use)
        except KeyError:
            self._view.display_warning_box(
                'Group workspace not found, try updating all and then recalculating.'
            )
            return

        ws = algorithm_utils.run_AppendSpectra(ws1, ws2)

        new_alpha = algorithm_utils.run_AlphaCalc({
            "InputWorkspace": ws,
            "ForwardSpectra": [0],
            "BackwardSpectra": [1]
        })

        self._model.update_pair_alpha(pair_name, new_alpha)
        self.pairing_table_widget.update_view_from_model()

        self.handle_update_all_clicked()
예제 #2
0
    def handle_guess_alpha(self, pair_name, group1_name, group2_name):
        """
        Calculate alpha for the pair for which "Guess Alpha" button was clicked.
        """
        if len(self._model._data.current_runs) > 1:
            run, index, ok_clicked = RunSelectionDialog.get_run(self._model._data.current_runs, self._model._data.instrument, self._view)
            if not ok_clicked:
                return
            run_to_use = self._model._data.current_runs[index]
        else:
            run_to_use = self._model._data.current_runs[0]

        ws1 = self._model.get_group_workspace(group1_name, run_to_use)
        ws2 = self._model.get_group_workspace(group2_name, run_to_use)

        ws = algorithm_utils.run_AppendSpectra(ws1, ws2)

        AnalysisDataService.addOrReplace('workspace used in calc', ws)

        new_alpha = algorithm_utils.run_AlphaCalc({"InputWorkspace": ws,
                                                   "ForwardSpectra": [0],
                                                   "BackwardSpectra": [1]})
        self._model.update_pair_alpha(pair_name, new_alpha)
        self.pairing_table_widget.update_view_from_model()

        self.groupingNotifier.notify_subscribers()
        self.handle_update_all_clicked()