Example #1
0
    def _fit_tof(self, tof_data):
        """
        Runs a fit against the loaded data
        """
        fit_opts = parse_fit_options(mass_values=self.getProperty("Masses").value,
                                     profile_strs=self.getProperty("MassProfiles").value,
                                     background_str=self.getProperty("Background").value,
                                     constraints_str=self.getProperty("IntensityConstraints").value)

        return self._run_fit(tof_data, self.getProperty("WorkspaceIndex").value, fit_opts)
Example #2
0
    def test_parse_fit_options(self):
        mass_values = [1.0079, 16]
        profile_strs = "function=Gaussian,width=[2,5,7];function=Gaussian,width=10.000000"
        background_str = "function=Polynomial,order=2"
        constraints_str = "[1,-4]"

        fit_opts = parse_fit_options(mass_values, profile_strs, background_str, constraints_str)
        self.assertEquals(2, len(fit_opts.mass_profiles))
        self.assertTrue(isinstance(fit_opts.background, PolynomialBackground))
        self.assertEquals(1, len(fit_opts.intensity_constraints))
        self.assertEquals(2, len(fit_opts.intensity_constraints[0]))
    def test_parse_fit_options(self):
        mass_values = [1.0079, 16]
        profile_strs = "function=Gaussian,width=[2,5,7];function=Gaussian,width=10.000000"
        background_str = "function=Polynomial,order=2"
        constraints_str = "[1,-4]"

        fit_opts = parse_fit_options(mass_values, profile_strs, background_str, constraints_str)
        self.assertEquals(2, len(fit_opts.mass_profiles))
        self.assertTrue(isinstance(fit_opts.background, PolynomialBackground))
        self.assertEquals(1, len(fit_opts.intensity_constraints))
        self.assertEquals(2, len(fit_opts.intensity_constraints[0]))
Example #4
0
    def _fit_tof(self, tof_data):
        """
        Runs a fit against the loaded data
        """
        fit_opts = parse_fit_options(
            mass_values=self.getProperty("Masses").value,
            profile_strs=self.getProperty("MassProfiles").value,
            background_str=self.getProperty("Background").value,
            constraints_str=self.getProperty("IntensityConstraints").value)

        return self._run_fit(tof_data,
                             self.getProperty("WorkspaceIndex").value,
                             fit_opts)
    def _gamma_correction(self):
        correction_background_ws = str(self._correction_wsg) + "_GammaBackground"

        fit_opts = parse_fit_options(mass_values=self._masses,
                                     profile_strs=self.getProperty("MassProfiles").value,
                                     constraints_str=self.getProperty("IntensityConstraints").value)
        params_dict = TableWorkspaceDictionaryFacade(self.getProperty("FitParameters").value)
        func_str = fit_opts.create_function_str(params_dict)

        ms.VesuvioCalculateGammaBackground(InputWorkspace=self._output_ws,
                                           ComptonFunction=func_str,
                                           BackgroundWorkspace=correction_background_ws,
                                           CorrectedWorkspace='__corrected_dummy')
        ms.DeleteWorkspace('__corrected_dummy')

        return correction_background_ws
    def _gamma_correction(self):
        from mantid.simpleapi import (CalculateGammaBackground, CloneWorkspace,
                                      DeleteWorkspace)
        correction_background_ws = str(self._correction_wsg) + "_GammaBackground"

        fit_opts = parse_fit_options(mass_values=self.getProperty("Masses").value,
                                     profile_strs=self.getProperty("MassProfiles").value,
                                     constraints_str=self.getProperty("IntensityConstraints").value)
        params_ws_name = self.getPropertyValue("FitParameters")
        params_dict = TableWorkspaceDictionaryFacade(mtd[params_ws_name])
        func_str = fit_opts.create_function_str(params_dict)

        CalculateGammaBackground(InputWorkspace=self._output_ws,
                                 ComptonFunction=func_str,
                                 BackgroundWorkspace=correction_background_ws,
                                 CorrectedWorkspace='__corrected_dummy')
        DeleteWorkspace('__corrected_dummy')

        return correction_background_ws
    def _gamma_correction(self):
        correction_background_ws = str(
            self._correction_wsg) + "_GammaBackground"

        fit_opts = parse_fit_options(
            mass_values=self._masses,
            profile_strs=self.getProperty("MassProfiles").value,
            constraints_str=self.getProperty("IntensityConstraints").value)
        params_dict = TableWorkspaceDictionaryFacade(
            self.getProperty("FitParameters").value)
        func_str = fit_opts.create_function_str(params_dict)

        ms.VesuvioCalculateGammaBackground(
            InputWorkspace=self._output_ws,
            ComptonFunction=func_str,
            BackgroundWorkspace=correction_background_ws,
            CorrectedWorkspace='__corrected_dummy')
        ms.DeleteWorkspace('__corrected_dummy')

        return correction_background_ws