def testReflectedBeamSumInQExecutes(self): dirWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_chopper_configuration_D17(dirWS) dirBeamPosWS = illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128) dirWS = illhelpers.refl_preprocess('dirWS', dirWS, dirBeamPosWS) args = { 'InputWorkspace': dirWS, 'OutputWorkspace': 'dirForeground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted()) dirForeground = alg.getProperty('OutputWorkspace').value reflWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(reflWS, 1.2) illhelpers.add_chopper_configuration_D17(reflWS) reflBeamPosWS = illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.2, 128) reflWS = illhelpers.refl_preprocess('refWS', reflWS, reflBeamPosWS) args = { 'InputWorkspace': reflWS, 'OutputWorkspace': 'foreground', 'DirectForegroundWorkspace': dirForeground, 'SummationType': 'SumInQ', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted())
def testSumInQModeProducesDX(self): dirWS = illhelpers.create_poor_mans_d17_workspace() mtd.add('dirWS', dirWS) illhelpers.add_slit_configuration_D17(dirWS, 0.03, 0.02) illhelpers.add_chopper_configuration_D17(dirWS) illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128) dirWS = illhelpers.refl_preprocess('dirWS', dirWS, 'dirBeamPosWS') dirFgdWS = illhelpers.refl_sum_foreground('dirFgdWS', 'SumInLambda', dirWS) reflWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_chopper_configuration_D17(reflWS) illhelpers.add_slit_configuration_D17(reflWS, 0.03, 0.02) illhelpers.refl_rotate_detector(reflWS, 1.5) mtd.add('reflWS', reflWS) illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.5, 128) reflWS = illhelpers.refl_preprocess('reflWS', reflWS, 'reflBeamPosWS') fgdWS = illhelpers.refl_sum_foreground('fgdWS', 'SumInQ', reflWS, dirFgdWS, dirWS) args = { 'InputWorkspace': fgdWS, 'OutputWorkspace': 'inQ', 'DirectForegroundWorkspace': dirFgdWS, 'GroupingQFraction': 0.2, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLConvertToQ', **args) assertRaisesNothing(self, alg.execute) outWS = alg.getProperty('OutputWorkspace').value self.assertEqual(outWS.getNumberHistograms(), 1) self.assertTrue(outWS.hasDx(0))
def testReflectedBeamSumInQExecutes(self): dirWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_chopper_configuration_D17(dirWS) illhelpers.add_slit_configuration_D17(dirWS, 0.02, 0.03) dirBeamPosWS = illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128) dirWS = illhelpers.refl_preprocess('dirWS', dirWS, dirBeamPosWS) args = { 'InputWorkspace': dirWS, 'OutputWorkspace': 'dirForeground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted()) dirForeground = alg.getProperty('OutputWorkspace').value reflWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(reflWS, 1.2) illhelpers.add_chopper_configuration_D17(reflWS) illhelpers.add_slit_configuration_D17(reflWS, 0.02, 0.03) reflBeamPosWS = illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.2, 128) reflWS = illhelpers.refl_preprocess('refWS', reflWS, reflBeamPosWS) args = { 'InputWorkspace': reflWS, 'OutputWorkspace': 'foreground', 'DirectForegroundWorkspace': dirForeground, 'SummationType': 'SumInQ', 'DirectBeamWorkspace': dirWS, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted())
def testExecutes(self): dirWS = illhelpers.create_poor_mans_d17_workspace() mtd.add('dirWS', dirWS) illhelpers.add_slit_configuration_D17(dirWS, 0.03, 0.02) illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128) dirWS = illhelpers.refl_preprocess('dirWS', dirWS, 'dirBeamPosWS') reflWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_chopper_configuration_D17(reflWS) illhelpers.add_slit_configuration_D17(reflWS, 0.03, 0.02) illhelpers.refl_rotate_detector(reflWS, 1.5) mtd.add('reflWS', reflWS) illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.5, 128) reflWS = illhelpers.refl_preprocess('reflWS', reflWS, 'reflBeamPosWS') fgdWS = illhelpers.refl_sum_in_lambda('fgdWS', reflWS) args = { 'InputWorkspace': fgdWS, 'OutputWorkspace': 'inQ', 'ReflectedBeamWorkspace': reflWS, 'DirectBeamWorkspace': dirWS, 'GroupingQFraction': 0.2, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLConvertToQ', **args) assertRaisesNothing(self, alg.execute)
def testSumInQModeProducesDX(self): dirWS = illhelpers.create_poor_mans_d17_workspace() mtd.add('dirWS', dirWS) illhelpers.add_slit_configuration_D17(dirWS, 0.03, 0.02) illhelpers.add_chopper_configuration_D17(dirWS) illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128) dirWS = illhelpers.refl_preprocess('dirWS', dirWS, 'dirBeamPosWS') dirFgdWS = illhelpers.refl_sum_foreground('dirFgdWS', 'SumInLambda', dirWS) reflWS = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_chopper_configuration_D17(reflWS) illhelpers.add_slit_configuration_D17(reflWS, 0.03, 0.02) illhelpers.refl_rotate_detector(reflWS, 1.5) mtd.add('reflWS', reflWS) illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.5, 128) reflWS = illhelpers.refl_preprocess('reflWS', reflWS, 'reflBeamPosWS') fgdWS = illhelpers.refl_sum_foreground('fgdWS', 'SumInQ', reflWS, dirFgdWS, dirWS) args = { 'InputWorkspace': fgdWS, 'OutputWorkspace': 'inQ', 'DirectForegroundWorkspace': dirFgdWS, 'GroupingQFraction': 0.2, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLConvertToQ', **args) assertRaisesNothing(self, alg.execute) outWS = alg.getProperty('OutputWorkspace').value self.assertEqual(outWS.getNumberHistograms(), 1) self.assertTrue(outWS.hasDx(0))
def testExecutes(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_flipper_configuration_D17(ws, 1, 1) mtd.add('ws', ws) illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 0., 128) ws = illhelpers.refl_preprocess('ws', ws, 'beamPosWS') ws = illhelpers.refl_sum_foreground('ws', 'SumInLambda', ws) args = { 'InputWorkspaces': 'ws', 'OutputWorkspace': 'corrected', 'EfficiencyFile': 'ILL/D17/PolarizationFactors.txt', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLPolarizationCor', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(mtd.doesExist('corrected_++'))
def testExecutes(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.add_flipper_configuration_D17(ws, 1, 1) mtd.add('ws', ws) illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 0., 128) ws = illhelpers.refl_preprocess('ws', ws, 'beamPosWS') ws = illhelpers.refl_sum_foreground('ws', 'SumInLambda', ws) args = { 'InputWorkspaces': 'ws', 'OutputWorkspace': 'corrected', 'EfficiencyFile': 'ILL/D17/PolarizationFactors.txt', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLPolarizationCor', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(mtd.doesExist('corrected_++'))
def testDirectBeamSummationExecutes(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted())
def testDirectBeamSummationExecutes(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) self.assertTrue(alg.isExecuted())
def testNotSummedDirectForegroundRaises(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'DirectForegroundWorkspace': ws, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted)
def testNotSummedDirectForegroundRaises(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws( 'beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'DirectForegroundWorkspace': ws, 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted)
def testWavelengthRangeDefault(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws('beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) out = alg.getProperty('OutputWorkspace').value self.assertEquals(out.getNumberHistograms(), 1) Xs = out.readX(0) self.assertGreater(len(Xs), 1) self.assertGreater(Xs[0], 0.) self.assertLess(Xs[-1], 30.)
def testWavelengthRangeDefault(self): ws = illhelpers.create_poor_mans_d17_workspace() illhelpers.refl_rotate_detector(ws, 1.2) beamPosWS = illhelpers.refl_create_beam_position_ws( 'beamPosWS', ws, 1.2, 128) ws = illhelpers.refl_preprocess('ws', ws, beamPosWS) args = { 'InputWorkspace': ws, 'OutputWorkspace': 'foreground', 'rethrow': True, 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) assertRaisesNothing(self, alg.execute) out = alg.getProperty('OutputWorkspace').value self.assertEquals(out.getNumberHistograms(), 1) Xs = out.readX(0) self.assertGreater(len(Xs), 1) self.assertGreater(Xs[0], 0.) self.assertLess(Xs[-1], 30.)