Example #1
0
def create_group_populated_by_two_rebinned_workspaces():
    group = MuonGroup(group_name="group1")
    counts_workspace_22222 = CreateWorkspace([0], [0])
    asymmetry_workspace_22222 = CreateWorkspace([0], [0])
    asymmetry_workspace_unnorm_22222 = CreateWorkspace([0], [0])

    group.update_counts_workspace(MuonRun([22222]), counts_workspace_22222,
                                  True)
    group.update_asymmetry_workspace(MuonRun([22222]),
                                     asymmetry_workspace_22222,
                                     asymmetry_workspace_unnorm_22222, True)

    group.show_rebin([22222], 'counts_name_22222_rebin',
                     'asymmetry_name_22222_rebin',
                     'asymmetry_name_22222_unnorm')
    counts_workspace_33333 = CreateWorkspace([0], [0])
    asymmetry_workspace_33333 = CreateWorkspace([0], [0])
    asymmetry_workspace_unnorm_33333 = CreateWorkspace([0], [0])

    group.update_counts_workspace(MuonRun([33333]), counts_workspace_33333,
                                  True)
    group.update_asymmetry_workspace(MuonRun([33333]),
                                     asymmetry_workspace_33333,
                                     asymmetry_workspace_unnorm_33333, True)

    group.show_rebin([33333], 'counts_name_33333_rebin',
                     'asymmetry_name_33333_rebin',
                     'asymmetry_name_33333_unnorm')

    return group
Example #2
0
 def show_rebin(self, run, name, asym_name, asym_name_unnorm):
     run_object = MuonRun(run)
     run_object not in self._counts_workspace_rebin or self._counts_workspace_rebin[
         run_object].show(name)
     run_object not in self._asymmetry_estimate_rebin or self._asymmetry_estimate_rebin[
         run_object].show(asym_name)
     run_object not in self._asymmetry_estimate_rebin_unormalised or \
         self._asymmetry_estimate_rebin_unormalised[run_object].show(asym_name_unnorm)
Example #3
0
 def show_raw(self, run: List[int], name: str, asym_name: str,
              asym_name_unnorm: str):
     run_object = MuonRun(run)
     run_object not in self._counts_workspace or self._counts_workspace[
         run_object].show(name)
     run_object not in self._asymmetry_estimate or self._asymmetry_estimate[
         run_object].show(asym_name)
     run_object not in self._asymmetry_estimate_unormalised or\
         self._asymmetry_estimate_unormalised[run_object].show(asym_name_unnorm)
Example #4
0
    def _calculate_all_counts(self, rebin):
        for run in self._data_context.current_runs:
            run_pre_processing(context=self, run=run, rebin=rebin)
            for group in self._group_pair_context.groups:
                counts_workspace = self.calculate_counts(run, group, rebin)

                if not counts_workspace:
                    continue

                self.group_pair_context[group.name].update_counts_workspace(MuonRun(run), counts_workspace, rebin)
Example #5
0
    def test_get_group_pair_name_and_run_from_workspace_name(self):
        group_1 = MuonGroup('group_1', [1, 3, 5, 7, 9])
        group_2 = MuonGroup('group_2', [1, 3, 4, 7, 9])
        group_3 = MuonGroup('group_3', [1, 3, 4, 7, 9])
        self.context.add_group(group_1)
        self.context.add_group(group_2)
        self.context.add_group(group_3)
        group_1.update_counts_workspace(MuonRun([62260]), 'group_1_counts',
                                        False)
        group_1.update_asymmetry_workspace(MuonRun([62260]), 'group_1_asym',
                                           'group_1_asym_unorm', False)
        workspace_name_list = self.context.get_group_workspace_names(
            runs=[[62260]], groups=['group_1'], rebin=False)

        group_name, run = self.context.get_group_pair_name_and_run_from_workspace_name(
            workspace_name_list[0])

        self.assertEqual(group_name, 'group_1')
        self.assertEqual(run, '62260')
Example #6
0
    def get_asymmetry_workspace_names(self, runs):
        workspace_list = []

        for run in runs:
            run_object = MuonRun(run)
            if run_object in self._asymmetry_estimate and self._asymmetry_estimate[run_object].workspace_name and not \
                    self._asymmetry_estimate[run_object].is_hidden:
                workspace_list.append(
                    self._asymmetry_estimate[run_object].workspace_name)

        return workspace_list
Example #7
0
    def test_that_get_group_pair_name_and_run_works_for_fit_workspace_names_containing_original_worspace(
            self):
        group_1 = MuonGroup('group_1', [1, 3, 5, 7, 9])
        group_2 = MuonGroup('group_2', [1, 3, 4, 7, 9])
        group_3 = MuonGroup('group_3', [1, 3, 4, 7, 9])
        self.context.add_group(group_1)
        self.context.add_group(group_2)
        self.context.add_group(group_3)
        group_1.update_counts_workspace(MuonRun([62260, 62261]),
                                        'group_1_counts', False)
        group_1.update_asymmetry_workspace(MuonRun([62260,
                                                    62261]), 'group_1_asym',
                                           'group_1_asym_unorm', False)
        workspace_name_list = self.context.get_group_workspace_names(
            runs=[[62260, 62261]], groups=['group_1'], rebin=False)

        group_name, run = self.context.get_group_pair_name_and_run_from_workspace_name(
            workspace_name_list[0] + '; Fit Seq Flatbackground')

        self.assertEqual(group_name, 'group_1')
        self.assertEqual(run, '62260-62261')
Example #8
0
 def get_asymmetry_workspace_for_run(self, run, rebin):
     if rebin:
         return self._asymmetry_estimate_rebin[MuonRun(run)].workspace_name
     else:
         return self._asymmetry_estimate[MuonRun(run)].workspace_name
Example #9
0
 def get_counts_workspace_for_run(self, run, rebin):
     if rebin:
         return self._counts_workspace_rebin[MuonRun(run)].workspace_name
     else:
         return self._counts_workspace[MuonRun(run)].workspace_name
Example #10
0
    def calculate_asymmetry_for(self, run, group, rebin):
        asymmetry_workspaces = self.calculate_asymmetry(run, group, rebin)

        if asymmetry_workspaces is not None:
            self.group_pair_context[group.name].update_asymmetry_workspace(MuonRun(run), *asymmetry_workspaces, rebin)