示例#1
0
    def show_all_pairs(self):
        self.calculate_all_pairs()
        for run in self._data_context.current_runs:
            for pair_name in self._group_pair_context.pair_names:
                run_as_string = run_list_to_string(run)
                name = get_pair_data_workspace_name(
                    self,
                    pair_name,
                    run_as_string,
                    rebin=False)
                directory = get_base_data_directory(
                    self,
                    run_as_string)

                self.group_pair_context[
                    pair_name].show_raw(run, directory + name)

                if self._do_rebin():
                    name = get_pair_data_workspace_name(
                        self,
                        pair_name,
                        run_as_string,
                        rebin=True)
                    self.group_pair_context[
                        pair_name].show_rebin(run, directory + name)
示例#2
0
    def show_group(self, run, group, rebin):
        run_as_string = run_list_to_string(run)
        group_name = group.name
        periods = run_list_to_string(group.periods)

        directory = get_base_data_directory(self, run_as_string)

        name = get_group_data_workspace_name(self,
                                             group_name,
                                             run_as_string,
                                             periods,
                                             rebin=rebin)
        asym_name = get_group_asymmetry_name(self,
                                             group_name,
                                             run_as_string,
                                             periods,
                                             rebin=rebin)
        asym_name_unnorm = get_group_asymmetry_unnorm_name(self,
                                                           group_name,
                                                           run_as_string,
                                                           periods,
                                                           rebin=rebin)

        if not rebin:
            self.group_pair_context[group_name].show_raw(
                run, directory + name, directory + asym_name, asym_name_unnorm)
        else:
            self.group_pair_context[group_name].show_rebin(
                run, directory + name, directory + asym_name, asym_name_unnorm)
示例#3
0
 def add_phase_table_to_ADS(self, base_name):
     run = get_run_numbers_as_string_from_workspace_name(
         base_name, self.context.data_context.instrument)
     directory = get_base_data_directory(self.context, run)
     muon_workspace_wrapper = MuonWorkspaceWrapper(directory + base_name)
     muon_workspace_wrapper.show()
     self.context.phase_context.add_phase_table(muon_workspace_wrapper)
示例#4
0
    def add_fft_workspace_to_ADS(self, input_workspace, imaginary_input_workspace, fft_workspace):
        run = re.search('[0-9]+', input_workspace).group()
        fft_workspace_name = get_fft_workspace_name(input_workspace, imaginary_input_workspace)
        group = get_fft_workspace_group_name(fft_workspace_name, self.load.data_context.instrument)
        directory = get_base_data_directory(self.load, run) + group

        muon_workspace_wrapper = MuonWorkspaceWrapper(fft_workspace, directory + fft_workspace_name)
        muon_workspace_wrapper.show()
示例#5
0
    def add_phase_table_to_ADS(self, base_name, detector_table):
        run = re.search('[0-9]+', base_name).group()

        directory = get_base_data_directory(self.context, run)
        muon_workspace_wrapper = MuonWorkspaceWrapper(detector_table, directory + base_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_table(muon_workspace_wrapper)
示例#6
0
    def add_phase_quad_to_ADS(self, input_workspace, phasequad_workspace_name):
        run = re.search('^{}([0-9, -]+)[;,_]?'.format(self.context.data_context.instrument), input_workspace).group(1)

        directory = get_base_data_directory(self.context, run)

        muon_workspace_wrapper = MuonWorkspaceWrapper(directory + phasequad_workspace_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_quad(muon_workspace_wrapper, run)
        self.phase_quad_calculation_complete_nofifier.notify_subscribers()
    def add_phase_table_to_ADS(self, base_name, detector_table):
        run = re.search('[0-9]+', base_name).group()

        phase_table_group = get_phase_table_workspace_group_name(base_name,
                                                                 self.context.data_context.instrument)
        directory = get_base_data_directory(self.context, run) + phase_table_group
        muon_workspace_wrapper = MuonWorkspaceWrapper(detector_table, directory + base_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_table(muon_workspace_wrapper)
示例#8
0
    def add_phase_quad_to_ADS(self, input_workspace, input_phase_table, phase_quad):
        run = re.search('[0-9]+', input_workspace).group()
        phasequad_workspace_name = get_phase_quad_workspace_name(input_workspace, input_phase_table)

        directory = get_base_data_directory(self.context, run)

        muon_workspace_wrapper = MuonWorkspaceWrapper(phase_quad, directory + phasequad_workspace_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_quad(muon_workspace_wrapper)
        self.phase_quad_calculation_complete_nofifier.notify_subscribers()
示例#9
0
    def add_fft_workspace_to_ADS(self, input_workspace,
                                 imaginary_input_workspace, fft_workspace):
        run = re.search('[0-9]+', input_workspace).group()
        fft_workspace_name = get_fft_workspace_name(input_workspace,
                                                    imaginary_input_workspace)
        group = get_fft_workspace_group_name(fft_workspace_name,
                                             self.load.data_context.instrument)
        directory = get_base_data_directory(self.load, run) + group

        muon_workspace_wrapper = MuonWorkspaceWrapper(
            fft_workspace, directory + fft_workspace_name)
        muon_workspace_wrapper.show()
示例#10
0
    def add_fitting_info_to_ADS_if_required(self, base_name, fit_workspace_name):
        if not self.view.output_fit_information:
            return

        run = re.search('[0-9]+', base_name).group()
        phase_table_group = get_phase_table_workspace_group_name(base_name,
                                                                 self.context.data_context.instrument,
                                                                 self.context.workspace_suffix)
        directory = get_base_data_directory(self.context, run) + phase_table_group

        muon_workspace_wrapper = MuonWorkspaceWrapper(directory + fit_workspace_name)
        muon_workspace_wrapper.show()
示例#11
0
    def add_maxent_workspace_to_ADS(self, input_workspace, maxent_workspace, alg):
        run = re.search('[0-9]+', input_workspace).group()
        base_name = get_maxent_workspace_name(input_workspace)
        group = get_maxent_workspace_group_name(base_name, self.load.data_context.instrument, self.load.workspace_suffix)
        directory = get_base_data_directory(self.load, run) + group

        muon_workspace_wrapper = MuonWorkspaceWrapper(maxent_workspace, directory + base_name)
        muon_workspace_wrapper.show()

        maxent_output_options = self.get_maxent_output_options()
        self.load._frequency_context.add_maxEnt(run, maxent_workspace)
        self.add_optional_outputs_to_ADS(alg, maxent_output_options, base_name, directory)
    def add_fitting_info_to_ADS_if_required(self, base_name, fitting_information):
        if not self.view.output_fit_information:
            return

        run = re.search('[0-9]+', base_name).group()
        phase_table_group = get_phase_table_workspace_group_name(base_name,
                                                                 self.context.data_context.instrument)
        fitting_workspace_name = get_fitting_workspace_name(base_name)
        directory = get_base_data_directory(self.context, run) + phase_table_group

        muon_workspace_wrapper = MuonWorkspaceWrapper(fitting_information, directory + fitting_workspace_name)
        muon_workspace_wrapper.show()
    def add_maxent_workspace_to_ADS(self, input_workspace, maxent_workspace, alg):
        run = re.search('[0-9]+', input_workspace).group()
        base_name = get_maxent_workspace_name(input_workspace)
        group = get_maxent_workspace_group_name(base_name, self.load.data_context.instrument)
        directory = get_base_data_directory(self.load, run) + group

        muon_workspace_wrapper = MuonWorkspaceWrapper(maxent_workspace, directory + base_name)
        muon_workspace_wrapper.show()

        maxent_output_options = self.get_maxent_output_options()

        self.add_optional_outputs_to_ADS(alg, maxent_output_options, base_name, directory)
    def add_phase_quad_to_ADS(self, input_workspace, input_phase_table, phase_quad):
        run = re.search('[0-9]+', input_workspace).group()
        phasequad_workspace_name = get_phase_quad_workspace_name(input_workspace, input_phase_table)
        phase_table_group = get_phase_table_workspace_group_name(phasequad_workspace_name,
                                                                 self.context.data_context.instrument)
        directory = get_base_data_directory(self.context, run) + phase_table_group

        muon_workspace_wrapper = MuonWorkspaceWrapper(phase_quad, directory + phasequad_workspace_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_quad(muon_workspace_wrapper)
        self.phase_quad_calculation_complete_nofifier.notify_subscribers()
示例#15
0
    def show_all_pairs(self):
        self.calculate_all_pairs()
        for run in self._data_context.current_runs:
            for pair_name in self._group_pair_context.pair_names:
                run_as_string = run_list_to_string(run)
                name = get_pair_data_workspace_name(self, pair_name, run_as_string, rebin=False)
                directory = get_base_data_directory(self, run_as_string) + get_pair_data_directory(self, run_as_string)

                self.group_pair_context[pair_name].show_raw(run, directory + name)

                if self._do_rebin():
                    name = get_pair_data_workspace_name(self, pair_name, run_as_string, rebin=True)
                    self.group_pair_context[pair_name].show_rebin(run, directory + name)
示例#16
0
    def add_phase_table_to_ADS(self, base_name, detector_table):
        run = re.search('[0-9]+', base_name).group()

        phase_table_group = get_phase_table_workspace_group_name(
            base_name, self.context.data_context.instrument,
            self.context.workspace_suffix)
        directory = get_base_data_directory(self.context,
                                            run) + phase_table_group
        muon_workspace_wrapper = MuonWorkspaceWrapper(detector_table,
                                                      directory + base_name)
        muon_workspace_wrapper.show()

        self.context.phase_context.add_phase_table(muon_workspace_wrapper)
示例#17
0
    def show_all_groups(self):
        self.calculate_all_groups()
        for run in self._data_context.current_runs:
            with WorkspaceGroupDefinition():
                for group in self._group_pair_context.groups:
                    run_as_string = run_list_to_string(run)
                    group_name = group.name
                    periods = run_list_to_string(group.periods)

                    directory = get_base_data_directory(self, run_as_string)

                    name = get_group_data_workspace_name(self,
                                                         group_name,
                                                         run_as_string,
                                                         periods,
                                                         rebin=False)
                    asym_name = get_group_asymmetry_name(self,
                                                         group_name,
                                                         run_as_string,
                                                         periods,
                                                         rebin=False)
                    asym_name_unnorm = get_group_asymmetry_unnorm_name(
                        self, group_name, run_as_string, periods, rebin=False)

                    self.group_pair_context[group_name].show_raw(
                        run, directory + name, directory + asym_name,
                        asym_name_unnorm)

                    if self._do_rebin():
                        name = get_group_data_workspace_name(self,
                                                             group_name,
                                                             run_as_string,
                                                             periods,
                                                             rebin=True)
                        asym_name = get_group_asymmetry_name(self,
                                                             group_name,
                                                             run_as_string,
                                                             periods,
                                                             rebin=True)
                        asym_name_unnorm = get_group_asymmetry_unnorm_name(
                            self,
                            group_name,
                            run_as_string,
                            periods,
                            rebin=True)

                        self.group_pair_context[group_name].show_rebin(
                            run, directory + name, directory + asym_name,
                            asym_name_unnorm)
示例#18
0
    def _calculate_phasequads(self, phasequad_obj, rebin):
        for run in self._data_context.current_runs:
            if self._data_context.num_periods(run) > 1:
                raise ValueError("Cannot support multiple periods")

            ws_list = self.calculate_phasequad(phasequad_obj, run, rebin)
            run_string = run_list_to_string(run)
            directory = get_base_data_directory(self, run_string)
            for ws in ws_list:
                muon_workspace_wrapper = MuonWorkspaceWrapper(directory + ws)
                muon_workspace_wrapper.show()

            phasequad_obj.update_asymmetry_workspaces(ws_list,
                                                      run,
                                                      rebin=rebin)
示例#19
0
    def show_raw_data(self):
        for run in self.data_context.current_runs:
            run_string = run_list_to_string(run)
            loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                'OutputWorkspace']
            directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string)

            if len(loaded_workspace) > 1:
                # Multi-period data
                for i, single_ws in enumerate(loaded_workspace):
                    name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1))
                    single_ws.show(name)
            else:
                # Single period data
                name = directory + get_raw_data_workspace_name(self, run_string)
                loaded_workspace[0].show(name)
示例#20
0
    def show_raw_data(self):
        for run in self.data_context.current_runs:
            run_string = run_list_to_string(run)
            loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                'OutputWorkspace']
            directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string)

            if len(loaded_workspace) > 1:
                # Multi-period data
                for i, single_ws in enumerate(loaded_workspace):
                    name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1))
                    single_ws.show(name)
            else:
                # Single period data
                name = directory + get_raw_data_workspace_name(self, run_string)
                loaded_workspace[0].show(name)
示例#21
0
    def show_raw_data(self):
        self.ads_observer.observeRename(False)
        for run in self.data_context.current_runs:
            with WorkspaceGroupDefinition():
                run_string = run_list_to_string(run)
                loaded_workspace = \
                    self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][
                        'OutputWorkspace']
                loaded_workspace_deadtime_table = self.data_context._loaded_data.get_data(
                    run=run, instrument=self.data_context.instrument
                )['workspace']['DataDeadTimeTable']
                directory = get_base_data_directory(self, run_string)

                deadtime_name = get_deadtime_data_workspace_name(
                    self.data_context.instrument,
                    str(run[0]),
                    workspace_suffix=self.workspace_suffix)
                MuonWorkspaceWrapper(loaded_workspace_deadtime_table).show(
                    directory + deadtime_name)
                self.data_context._loaded_data.get_data(
                    run=run, instrument=self.data_context.instrument
                )['workspace']['DataDeadTimeTable'] = deadtime_name

                if len(loaded_workspace) > 1:
                    # Multi-period data
                    for i, single_ws in enumerate(loaded_workspace):
                        name = directory + get_raw_data_workspace_name(
                            self.data_context.instrument,
                            run_string,
                            multi_period=True,
                            period=str(i + 1),
                            workspace_suffix=self.workspace_suffix)
                        single_ws.show(name)
                else:
                    # Single period data
                    name = directory + get_raw_data_workspace_name(
                        self.data_context.instrument,
                        run_string,
                        multi_period=False,
                        workspace_suffix=self.workspace_suffix)
                    loaded_workspace[0].show(name)

        self.ads_observer.observeRename(True)
示例#22
0
    def show_diff(self, run: list, diff: MuonDiff):
        diff_name = diff.name

        run_as_string = run_list_to_string(run)
        name = get_diff_asymmetry_name(self,
                                       diff_name,
                                       run_as_string,
                                       rebin=False)
        directory = get_base_data_directory(self, run_as_string)

        self.group_pair_context[diff_name].show_raw(run, directory + name)

        if self._do_rebin():
            name = get_diff_asymmetry_name(self,
                                           diff_name,
                                           run_as_string,
                                           rebin=True)
            self.group_pair_context[diff_name].show_rebin(
                run, directory + name)
示例#23
0
    def add_fft_workspace_to_ADS(self, input_workspace,
                                 imaginary_input_workspace, fft_workspace):
        run = re.search('[0-9]+', input_workspace).group()
        Im_run = re.search('[0-9]+', imaginary_input_workspace).group()
        fft_workspace_name = get_fft_workspace_name(input_workspace,
                                                    imaginary_input_workspace)
        group = get_fft_workspace_group_name(fft_workspace_name,
                                             self.load.data_context.instrument,
                                             self.load.workspace_suffix)
        directory = get_base_data_directory(self.load, run) + group

        Re = get_group_or_pair_from_name(input_workspace)
        Im = get_group_or_pair_from_name(imaginary_input_workspace)

        shift = 3 if fft_workspace.getNumberHistograms() == 6 else 0
        spectra = {
            "_" + FREQUENCY_EXTENSIONS["RE"]: 0 + shift,
            "_" + FREQUENCY_EXTENSIONS["IM"]: 1 + shift,
            "_" + FREQUENCY_EXTENSIONS["MOD"]: 2 + shift
        }
        for spec_type in list(spectra.keys()):
            extracted_ws = extract_single_spec(fft_workspace,
                                               spectra[spec_type])

            if 'PhaseQuad' in self.view.workspace:
                self.load._frequency_context.add_FFT(fft_workspace_name +
                                                     spec_type,
                                                     run,
                                                     Re,
                                                     Im_run,
                                                     Im,
                                                     phasequad=True)
            else:
                self.load._frequency_context.add_FFT(
                    fft_workspace_name + spec_type, run, Re, Im_run, Im)

            muon_workspace_wrapper = MuonWorkspaceWrapper(
                extracted_ws, directory + fft_workspace_name + spec_type)
            muon_workspace_wrapper.show()
示例#24
0
    def show_pair(self, run: list, pair: MuonPair):
        pair_name = pair.name
        # Do not want to rename phasequad parts here
        if "_Re_" in pair_name or "_Im_" in pair_name:
            return

        run_as_string = run_list_to_string(run)
        name = get_pair_asymmetry_name(self,
                                       pair_name,
                                       run_as_string,
                                       rebin=False)
        directory = get_base_data_directory(self, run_as_string)

        self.group_pair_context[pair_name].show_raw(run, directory + name)

        if self._do_rebin():
            name = get_pair_asymmetry_name(self,
                                           pair_name,
                                           run_as_string,
                                           rebin=True)
            self.group_pair_context[pair_name].show_rebin(
                run, directory + name)
示例#25
0
    def show_pair_data(self, pair_name, show=True, rebin=False):
        for run in self.current_runs:
            run_as_string = run_list_to_string(run)
            name = get_pair_data_workspace_name(self, pair_name, run_as_string,
                                                rebin)
            directory = get_base_data_directory(
                self, run_as_string) + get_pair_data_directory(
                    self, run_as_string)
            pair_workspace = calculate_pair_data(self, pair_name, run, rebin)

            if not rebin:
                self._pairs[pair_name].workspace[str(
                    run)] = MuonWorkspaceWrapper(pair_workspace)
                if show:
                    self._pairs[pair_name].workspace[str(run)].show(directory +
                                                                    name)
            else:
                self._pairs[pair_name].workspace_rebin[str(
                    run)] = MuonWorkspaceWrapper(pair_workspace)
                if show:
                    self._pairs[pair_name].workspace_rebin[str(run)].show(
                        directory + name)
示例#26
0
    def show_group_data(self, group_name, show=True, rebin=False):
        for run in self.current_runs:
            run_as_string = run_list_to_string(run)
            group_workspace = calculate_group_data(self, group_name, run,
                                                   rebin)
            group_asymmetry = estimate_group_asymmetry_data(
                self, group_name, run, rebin)
            directory = get_base_data_directory(
                self, run_as_string) + get_group_data_directory(
                    self, run_as_string)

            name = get_group_data_workspace_name(self, group_name,
                                                 run_as_string, rebin)
            asym_name = get_group_asymmetry_name(self, group_name,
                                                 run_as_string, rebin)

            if not rebin:
                self._groups[group_name]._workspace[str(
                    run)] = MuonWorkspaceWrapper(group_workspace)
                self._groups[group_name]._asymmetry_estimate[str(
                    run)] = MuonWorkspaceWrapper(group_asymmetry)
                if show:
                    self._groups[group_name].workspace[str(run)].show(
                        directory + name)
                    self._groups[group_name]._asymmetry_estimate[str(
                        run)].show(directory + asym_name)
            else:
                self._groups[group_name]._workspace_rebin[str(
                    run)] = MuonWorkspaceWrapper(group_workspace)
                self._groups[group_name]._asymmetry_estimate_rebin[str(
                    run)] = MuonWorkspaceWrapper(group_asymmetry)
                if show:
                    self._groups[group_name]._workspace_rebin[str(run)].show(
                        directory + name)
                    self._groups[group_name]._asymmetry_estimate_rebin[str(
                        run)].show(directory + asym_name)