예제 #1
0
    def add_fitting_info_to_ADS_if_required(self, base_name,
                                            fit_workspace_name):
        if not self.view.output_fit_information:
            return

        muon_workspace_wrapper = MuonWorkspaceWrapper(fit_workspace_name)
        muon_workspace_wrapper.show()
예제 #2
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)
예제 #3
0
    def add_fft_workspace_to_ADS(self, input_workspace, imaginary_input_workspace, fft_workspace_label):
        run = re.search('[0-9]+', input_workspace).group()
        fft_workspace = mantid.AnalysisDataService.retrieve(fft_workspace_label)
        Im_run = ""
        if imaginary_input_workspace != "":
            Im_run = re.search('[0-9]+', imaginary_input_workspace).group()
        fft_workspace_name = get_fft_workspace_name(input_workspace, imaginary_input_workspace)
        directory = get_fft_workspace_group_name(fft_workspace_name, self.load.data_context.instrument,
                                                 self.load.workspace_suffix)
        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], fft_workspace_name + spec_type)

            self.load._frequency_context.add_FFT(fft_workspace_name + spec_type, run, Re, Im_run, Im)

            muon_workspace_wrapper = MuonWorkspaceWrapper(extracted_ws)
            muon_workspace_wrapper.show(directory + fft_workspace_name + spec_type)

        # This is a small hack to get the output name to a location where it can be part of the calculation finished
        # signal.
        self._output_workspace_name = fft_workspace_name + '_mod'
    def test_that_hiding_the_workspace_removes_it_from_ADS(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)
        workspace_handle.show("test")

        workspace_handle.hide()

        self.assertEqual(workspace_handle.is_hidden, True)
        self.assertFalse(simpleapi.mtd.doesExist("test"))
    def test_that_workspace_property_returns_workspace_when_in_ADS(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)

        workspace_handle.show("arbitrary_name")
        ws_property = workspace_handle.workspace

        self.assertCountEqual(ws_property.readX(0), [1, 2, 3, 4])
        self.assertCountEqual(ws_property.readY(0), [10, 10, 10, 10])
예제 #6
0
    def test_that_workspace_added_correctly_for_single_nested_structure(self):
        workspace = create_simple_workspace(data_x=[1, 2, 3, 4],
                                            data_y=[10, 10, 10, 10])
        workspace_handle = MuonWorkspaceWrapper(workspace=workspace)

        workspace_handle.show("group1/ws1")

        self.assert_group_workspace_exists("group1")
        self.assert_workspace_in_group("ws1", "group1")
예제 #7
0
    def test_that_if_workspace_exists_with_same_name_as_group_then_it_is_replaced(
            self):
        simpleapi.CreateWorkspace([1, 2, 3, 4], [10, 10, 10, 10],
                                  OutputWorkspace="group")

        workspace_handle = MuonWorkspaceWrapper('group')
        workspace_handle.show("group/ws1")

        self.assert_group_workspace_exists("group")
    def test_that_showing_the_workspace_puts_it_in_ADS(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)

        workspace_handle.show("test")

        self.assertTrue(simpleapi.mtd.doesExist("test"))
        ads_workspace = simpleapi.mtd["test"]
        self.assertCountEqual(ads_workspace.readX(0), [1, 2, 3, 4])
        self.assertCountEqual(ads_workspace.readY(0), [10, 10, 10, 10])
    def test_that_setting_a_new_workspace_removes_the_previous_one_from_the_ADS(
            self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)
        workspace_handle.show("name1")

        workspace2 = create_simple_workspace(data_x=[5, 6, 7, 8],
                                             data_y=[20, 20, 20, 20])

        self.assertTrue(simpleapi.mtd.doesExist("name1"))
        workspace_handle.workspace = workspace2
        self.assertFalse(simpleapi.mtd.doesExist("name1"))
예제 #10
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, self.view.get_method)
        directory = get_maxent_workspace_group_name(base_name, self.context.data_context.instrument, self.context.workspace_suffix)

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

        maxent_output_options = self.get_maxent_output_options()
        self.context.frequency_context.add_maxEnt(run, maxent_workspace)
        self.add_optional_outputs_to_ADS(alg, maxent_output_options, base_name, directory)

        # Storing this on the class so it can be sent as part of the calculation
        # finished signal.
        self._maxent_output_workspace_name = base_name
예제 #11
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)
예제 #12
0
    def test_that_workspaces_in_existing_folders_are_not_moved_by_directory_manipulation(
            self):
        workspace1 = create_simple_workspace(data_x=[1, 2, 3, 4],
                                             data_y=[10, 10, 10, 10])
        workspace2 = create_simple_workspace(data_x=[1, 2, 3, 4],
                                             data_y=[10, 10, 10, 10])
        workspace_handle1 = MuonWorkspaceWrapper(workspace=workspace1)
        workspace_handle2 = MuonWorkspaceWrapper(workspace=workspace2)

        workspace_handle1.show("group2/ws1")
        workspace_handle2.show("group3/ws2")

        self.assert_group_workspace_exists("group2")
        self.assert_group_workspace_exists("group3")
        self.assert_workspace_in_group("ws1", "group2")
        self.assert_workspace_in_group("ws2", "group3")
예제 #13
0
 def add_optional_outputs_to_ADS(self, alg, output_options, base_name, directory):
     for key in output_options:
         if key == GROUPINGTABLE and output_options[key]:
             output = GROUPINGTABLE
             self.context.ads_observer.observeRename(False)
             wrapped_workspace = MuonWorkspaceWrapper(output)
             name = directory + base_name + " " + GROUPINGTABLE
             self._optional_output_names[key] = name
             wrapped_workspace.show(name)
             self.context.ads_observer.observeRename(True)
         elif output_options[key]:
             output = alg.getProperty(key).valueAsStr
             self.context.ads_observer.observeRename(False)
             wrapped_workspace = MuonWorkspaceWrapper(output)
             name = directory + base_name + "(" + str(self.get_num_groups)+" groups) "+ optional_output_suffixes[key]
             self._optional_output_names[key] = name
             wrapped_workspace.show(name)
             self.context.ads_observer.observeRename(True)
예제 #14
0
def create_workspace_wrapper_stub_object(name):
    workspace = CreateWorkspace([0], [0])
    wrapped_workspace = MuonWorkspaceWrapper(workspace)
    wrapped_workspace.show(name)
    return wrapped_workspace
    def test_that_if_workspace_deleted_from_ADS_then_hide_does_nothing(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)
        workspace_handle.show("name1")

        simpleapi.mtd.clear()
    def test_that_hiding_workspace_more_than_once_has_no_effect(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)
        workspace_handle.show("name1")

        workspace_handle.hide()
    def test_that_showing_the_workspace_with_empty_string_for_name_raises_ValueError(
            self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)

        with self.assertRaises(ValueError):
            workspace_handle.show("")