def test_that_correctly_identifies_normalisation_for_artificial_double_pulse_data( self): delta = 0.33 x = np.linspace(0., 15., 100) x_offset = np.linspace(delta / 2, 15. + delta / 2, 100) x_offset_neg = np.linspace(-delta / 2, 15. - delta / 2, 100) testFunction = GausOsc(Frequency=1.5, A=0.22) y1 = testFunction(x_offset_neg) y2 = testFunction(x_offset) N0 = 6.38 y = N0 * (1 + y1 / 2 + y2 / 2) y_norm = y1 / 2 + y2 / 2 CreateWorkspace(x, y, OutputWorkspace="unnormalised_workspace") CreateWorkspace(x, y, OutputWorkspace="ws_to_normalise") CreateWorkspace(x, y_norm, OutputWorkspace="ws_correctly_normalised") AddSampleLog(Workspace='ws_to_normalise', LogName="analysis_asymmetry_norm", LogText="1") innerFunction = FunctionFactory.createInitialized( 'name=GausOsc,A=0.20,Sigma=0.2,Frequency=1.0,Phi=0') tf_function = ConvertFitFunctionForMuonTFAsymmetry( InputFunction=innerFunction, WorkspaceList=['ws_to_normalise']) CalculateMuonAsymmetry( MaxIterations=100, EnableDoublePulse=True, PulseOffset=delta, UnNormalizedWorkspaceList='unnormalised_workspace', ReNormalizedWorkspaceList='ws_to_normalise', OutputFitWorkspace='DoublePulseFit', StartX=0, InputFunction=str(tf_function), Minimizer='Levenberg-Marquardt') double_parameter_workspace = AnalysisDataService.retrieve( 'DoublePulseFit_Parameters') values_column = double_parameter_workspace.column(1) # Check that the correct normalisation is found. self.assertAlmostEqual(values_column[0], N0, places=3) # Check that normalised data is correct result, message = CompareWorkspaces('ws_to_normalise', 'ws_correctly_normalised', Tolerance=1e-3) self.assertTrue(result) AnalysisDataService.clear()
def calculate_tf_function(self, algorithm_parameters): return ConvertFitFunctionForMuonTFAsymmetry(StoreInADS=False, **algorithm_parameters)
def convert_to_tf_function(algorithm_parameters): return ConvertFitFunctionForMuonTFAsymmetry(StoreInADS=False, **algorithm_parameters)