Skip to content
Snippets Groups Projects
Commit b588e94c authored by Tom Perkins's avatar Tom Perkins
Browse files

Add system test with real dataset

Fits the Keren function to MUT00053591 (copper data from muon training
course) and compares parameters to those Peter got with WiMDA

re #16212
parent 4ddd4441
No related branches found
No related tags found
No related merge requests found
125543727e1387609d3bdc22a78890a5
\ No newline at end of file
#pylint: disable=no-init,attribute-defined-outside-init
import stresstesting
from mantid.simpleapi import *
class MuonKerenFittingTest(stresstesting.MantidStressTest):
'''Tests the Keren fitting function on a real workspace, to check results vs. WiMDA'''
def runTest(self):
# Load dataset
MUT53591 = LoadMuonNexus(Filename='MUT00053591.nxs', DetectorGroupingTable='gp')
# Process like MuonAnalysis interface would
processed = MuonProcess(InputWorkspace='MUT53591', Mode='Combined', SummedPeriodSet='1',\
ApplyDeadTimeCorrection=False, DetectorGroupingTable='gp', LoadedTimeZero=0, TimeZero=0,\
Xmin=0.08, Xmax=10.0, OutputType="PairAsymmetry", PairFirstIndex="0", PairSecondIndex="1",\
Alpha=1.0)
# Fit the Keren function to the data
func = "name=FlatBackground,A0=0.1;name=Keren,A=0.1,Delta=0.2,Field=18,Fluct=0.2"
Fit(InputWorkspace='processed', Function=func, Output='out', CreateOutput=True)
# Get fitted parameters
params = mtd['out_Parameters']
A0 = params.cell(0,1)
A = params.cell(1,1)
Delta = params.cell(2,1)
Field = params.cell(3,1)
Fluct = params.cell(4,1)
Chisq = params.cell(5,1)
# Check that params are within the errors of those obtained in WiMDA
self.assertTrue(Chisq < 1.1, "Fitted chi-square too large")
self.assertDelta(A0, 0.1623, 0.0046, "Fitted A0 outside errors")
self.assertDelta(A, 0.0389, 0.0040, "Fitted A outside errors")
self.assertDelta(Delta, 0.96, 0.11, "Fitted Delta outside errors")
self.assertDelta(Field, 20.0, 1.0, "Fitted Field outside errors")
self.assertDelta(Fluct, 0.1, 0.01, "Fitted Fluct outside errors")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment