Skip to content

Commit

Permalink
Re #11397 Better testing for Multirep ranges routine
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Mar 21, 2015
1 parent c096241 commit 5bfd5a9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Expand Up @@ -236,7 +236,7 @@ def custom_name(prop_man):
# Uncomment this to use custom filename function
# Note: the properties are stored in prop_man class accessed as
# below.
#return custom_name(self.reducer.prop_man)
#return lambda : custom_name(self.reducer.prop_man)
# use this method to use standard file name generating function
return None

Expand Down
Expand Up @@ -90,7 +90,7 @@ def custom_name(prop_man):
# Uncomment this to use custom filename function
# Note: the properties are stored in prop_man class accessed as
# below.
#return custom_name(self.reducer.prop_man)
#return lambda : custom_name(self.reducer.prop_man)
# use this method to use standard file name generating function
return None

Expand Down
Expand Up @@ -73,13 +73,13 @@ def custom_name(prop_man):
# sample run is more then just list of runs, so we use
# the formalization below to access its methods
run_num = PropertyManager.sample_run.run_number()
name = "RUN{0}atEi{1:<4.1f}meV_One2One".format(run_num ,ei)
name = "RUN{0}atEi{1:<3.2f}meV_One2One".format(run_num ,ei)
return name

# Uncomment this to use custom filename function
# Note: the properties are stored in prop_man class accessed as
# below.
#return custom_name(self.reducer.prop_man)
#return lambda : custom_name(self.reducer.prop_man)
# use this method to use standard file name generating function
return None

Expand Down
20 changes: 15 additions & 5 deletions Code/Mantid/scripts/test/DirectEnergyConversionTest.py
Expand Up @@ -314,30 +314,35 @@ def test_tof_range(self):

red.prop_man.incident_energy = 67
red.prop_man.energy_bins = [-20,0.2,65]
red.prop_man.multirep_tof_specta_list = [5,5]
red.prop_man.multirep_tof_specta_list = [4,5,6]
MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1102, Z=3)
MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1103,Z=6)


tof_range = red.find_tof_range_for_multirep(run)

self.assertEqual(len(tof_range),3)

run_tof = ConvertUnits(run,Target='TOF',EMode='Direct',EFixed=67.)
x = run_tof.readX(4)
x = run_tof.readX(3)
dx=abs(x[1:]-x[:-1])
xMin = min(x)
xMax = max(x)
dt = min(dx)
x = run_tof.readX(5)
xMax = max(x)


self.assertAlmostEqual(tof_range[0],xMin)
self.assertAlmostEqual(tof_range[1],dt)
self.assertAlmostEqual(tof_range[2],xMax)

# check another working mode
red.prop_man.multirep_tof_specta_list = 5
red.prop_man.multirep_tof_specta_list = 4
tof_range1 = red.find_tof_range_for_multirep(run)

self.assertAlmostEqual(tof_range[0],tof_range1[0])
self.assertAlmostEqual(tof_range[1],tof_range1[1])
self.assertAlmostEqual(tof_range[2],tof_range1[2])
#self.assertAlmostEqual(tof_range[2],tof_range1[2])

def test_multirep_mode(self):
# create test workspace
Expand All @@ -352,6 +357,9 @@ def test_multirep_mode(self):
run = CreateSampleWorkspace( Function='Multiple Peaks',WorkspaceType='Event',NumBanks=8, BankPixelWidth=1,\
NumEvents=100000, XUnit='TOF',xMin=tMin,xMax=tMax)
LoadInstrument(run,InstrumentName='MARI')
MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1102,Z=1)
# MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1103,Z=4)
# MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1104,Z=5)

# do second
run2 = CloneWorkspace(run)
Expand All @@ -365,6 +373,7 @@ def test_multirep_mode(self):
tReducer.hard_mask_file=None
tReducer.map_file=None
tReducer.save_format=None
tReducer.multirep_tof_specta_list = [4,5]

result = tReducer.convert_to_energy(wb_ws,run,[67.,122.],[-2,0.02,0.8])

Expand Down Expand Up @@ -431,6 +440,7 @@ def test_multirep_abs_units_mode(self):
tReducer.prop_man.normalise_method='monitor-1'
tReducer.norm_mon_integration_range=[tMin,tMax]


result = tReducer.convert_to_energy(wb_ws,run,[67.,122.],[-2,0.02,0.8],None,mono)

self.assertEqual(len(result),2)
Expand Down

0 comments on commit 5bfd5a9

Please sign in to comment.