def testDetectorGrouping(self):
     ws = illhelpers.create_poor_mans_in5_workspace(0.0,
                                                    _groupingTestDetectors)
     originalNDetectors = ws.getNumberHistograms()
     detectorIds = list()
     for i in range(originalNDetectors):
         detectorIds.append(ws.getDetector(i).getID())
     _add_natural_angle_step_parameter(ws)
     mtd.addOrReplace('inWS', ws)
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': ws,
         'OutputWorkspace': outWSName,
         'Cleanup': 'Cleanup OFF',
         'Transposing': 'Transposing OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     groupedWSName = outWSName + '_grouped_detectors_'
     self.assertTrue(groupedWSName in mtd)
     groupedWS = mtd[groupedWSName]
     self.assertEqual(groupedWS.getNumberHistograms(), 2)
     groupIds = list(groupedWS.getDetector(0).getDetectorIDs())
     groupIds += groupedWS.getDetector(1).getDetectorIDs()
     self.assertEqual(collections.Counter(detectorIds),
                      collections.Counter(groupIds))
 def testDetectorGroupingWithUserGivenAngleStep(self):
     ws = illhelpers.create_poor_mans_in5_workspace(0.0,
                                                    _groupingTestDetectors)
     nhisto = ws.getNumberHistograms()
     spectrumInfo = ws.spectrumInfo()
     minAngle = 180.
     maxAngle = 0.
     for i in range(nhisto):
         angle = numpy.rad2deg(spectrumInfo.twoTheta(i))
         minAngle = min(minAngle, angle)
         maxAngle = max(maxAngle, angle)
     mtd.addOrReplace('inWS', ws)
     outWSName = 'unused'
     outSThetaWName = 'SofThetaW'
     angleStep = 0.2
     algProperties = {
         'InputWorkspace': ws,
         'OutputWorkspace': outWSName,
         'GroupingAngleStep': angleStep,
         'OutputSofThetaEnergyWorkspace': outSThetaWName,
         'Transposing': 'Transposing OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(outSThetaWName in mtd)
     SThetaWWS = mtd[outSThetaWName]
     spectrumInfo = SThetaWWS.spectrumInfo()
     firstAngleBin = int(minAngle / angleStep)
     lastAngleBin = int(maxAngle / angleStep) + 1
     expected = lastAngleBin - firstAngleBin
     self.assertEqual(spectrumInfo.size(), expected)
 def testDetectorGroupingWithUserGivenAngleStep(self):
     ws = illhelpers.create_poor_mans_in5_workspace(0.0, _groupingTestDetectors)
     nhisto = ws.getNumberHistograms()
     spectrumInfo = ws.spectrumInfo()
     minAngle = 180.
     maxAngle = 0.
     for i in range(nhisto):
         angle = numpy.rad2deg(spectrumInfo.twoTheta(i))
         minAngle = min(minAngle, angle)
         maxAngle = max(maxAngle, angle)
     mtd.addOrReplace('inWS', ws)
     outWSName = 'unused'
     outSThetaWName = 'SofThetaW'
     angleStep = 0.2
     algProperties = {
         'InputWorkspace': ws,
         'OutputWorkspace': outWSName,
         'GroupingAngleStep': angleStep,
         'OutputSofThetaEnergyWorkspace': outSThetaWName,
         'Transposing': 'Transposing OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(outSThetaWName in mtd)
     SThetaWWS = mtd[outSThetaWName]
     spectrumInfo = SThetaWWS.spectrumInfo()
     firstAngleBin = int(minAngle / angleStep)
     lastAngleBin = int(maxAngle / angleStep) + 1
     expected = lastAngleBin - firstAngleBin
     self.assertEqual(spectrumInfo.size(), expected)
 def setUp(self):
     if self._TEST_WS is None:
         self._TEST_WS = illhelpers.create_poor_mans_in5_workspace(
             self._BKG_LEVEL, illhelpers.default_test_detectors)
     algProperties = {
         'InputWorkspace': self._TEST_WS,
         'OutputWorkspace': self._TEST_WS_NAME,
     }
     run_algorithm('CloneWorkspace', **algProperties)
Example #5
0
 def setUp(self):
     if DirectILLSelfShieldingTest._TEST_WS is None:
         bkgLevel = 0.0
         DirectILLSelfShieldingTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(
             bkgLevel, illhelpers.default_test_detectors)
     tempMonitorWSName = 'monitors'
     kwargs = {
         'InputWorkspace': DirectILLSelfShieldingTest._TEST_WS,
         'DetectorWorkspace': self._TEST_WS_NAME,
         'MonitorWorkspace': tempMonitorWSName
     }
     run_algorithm('ExtractMonitors', **kwargs)
     kwargs = {'Workspace': tempMonitorWSName}
     run_algorithm('DeleteWorkspace', **kwargs)
 def setUp(self):
     if DirectILLDiagnosticsTest._TEST_WS is None:
         DirectILLDiagnosticsTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(
             self._BKG_LEVEL, illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, DirectILLDiagnosticsTest._TEST_WS)
     kwargs = {
         'InputWorkspace': DirectILLDiagnosticsTest._TEST_WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'EPPCreationMethod': 'Fit EPP',
         'FlatBkg': 'Flat Bkg ON',
         'OutputEPPWorkspace': self._EPP_WS_NAME,
         'OutputRawWorkspace': self._RAW_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     mtd.remove(inWSName)
 def setUp(self):
     if DirectILLSelfShieldingTest._TEST_WS is None:
         bkgLevel = 0.0
         DirectILLSelfShieldingTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(bkgLevel,
                                                                                         illhelpers.default_test_detectors)
     tempMonitorWSName = 'monitors'
     kwargs = {
         'InputWorkspace': DirectILLSelfShieldingTest._TEST_WS,
         'DetectorWorkspace': self._TEST_WS_NAME,
         'MonitorWorkspace': tempMonitorWSName
     }
     run_algorithm('ExtractMonitors', **kwargs)
     kwargs = {
         'Workspace': tempMonitorWSName
     }
     run_algorithm('DeleteWorkspace', **kwargs)
 def setUp(self):
     if DirectILLDiagnosticsTest._TEST_WS is None:
         DirectILLDiagnosticsTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL,
                                                                                       illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, DirectILLDiagnosticsTest._TEST_WS)
     kwargs = {
         'InputWorkspace': DirectILLDiagnosticsTest._TEST_WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'EPPCreationMethod': 'Fit EPP',
         'FlatBkg': 'Flat Bkg ON',
         'OutputEPPWorkspace': self._EPP_WS_NAME,
         'OutputRawWorkspace': self._RAW_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     mtd.remove(inWSName)
 def testDetectorGrouping(self):
     ws = illhelpers.create_poor_mans_in5_workspace(0.0, _groupingTestDetectors)
     originalNDetectors = ws.getNumberHistograms()
     detectorIds = list()
     for i in range(originalNDetectors):
         detectorIds.append(ws.getDetector(i).getID())
     mtd.addOrReplace('inWS', ws)
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': ws,
         'OutputWorkspace': outWSName,
         'Cleanup': 'Cleanup OFF',
         'Transposing': 'Transposing OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     groupedWSName = outWSName + '_grouped_detectors_'
     self.assertTrue(groupedWSName in mtd)
     groupedWS = mtd[groupedWSName]
     self.assertEqual(groupedWS.getNumberHistograms(), 1)
     groupIds = groupedWS.getDetector(0).getDetectorIDs()
     self.assertEqual(collections.Counter(detectorIds), collections.Counter(groupIds))
 def setUp(self):
     if not self._testIN5WS:
         self._testIN5WS = illhelpers.create_poor_mans_in5_workspace(
             self._BKG_LEVEL, illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, self._testIN5WS)
     kwargs = {
         'InputWorkspace': self._testIN5WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'OutputEPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     kwargs = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': self._VANADIUM_WS_NAME,
         'EPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLIntegrateVanadium', **kwargs)
     vanadiumWS = mtd[self._VANADIUM_WS_NAME]
     for i in range(vanadiumWS.getNumberHistograms()):
         vanadiumYs = vanadiumWS.dataY(i)
         vanadiumYs.fill(1.0)
     mtd.remove(inWSName)
Example #11
0
 def setUp(self):
     if not self._testIN5WS:
         self._testIN5WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL,
                                                                     illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, self._testIN5WS)
     kwargs = {
         'InputWorkspace': self._testIN5WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'OutputEPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     kwargs = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': self._VANADIUM_WS_NAME,
         'EPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLIntegrateVanadium', **kwargs)
     vanadiumWS = mtd[self._VANADIUM_WS_NAME]
     for i in range(vanadiumWS.getNumberHistograms()):
         vanadiumYs = vanadiumWS.dataY(i)
         vanadiumYs.fill(1.0)
     mtd.remove(inWSName)
Example #12
0
 def __init__(self, methodName='runTest'):
     unittest.TestCase.__init__(self, methodName)
     self._testIN5WS = illhelpers.create_poor_mans_in5_workspace(
         self._BKG_LEVEL, illhelpers.default_test_detectors)
 def __init__(self, methodName='runTest'):
     unittest.TestCase.__init__(self, methodName)
     self._testIN5WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL, illhelpers.default_test_detectors)
Example #14
0
 def setUp(self):
     if not DirectILLCollectDataTest._TEST_WS:
         DirectILLCollectDataTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(
             self._BKG_LEVEL, illhelpers.default_test_detectors)
     mtd.addOrReplace(self._TEST_WS_NAME, DirectILLCollectDataTest._TEST_WS)
 def setUp(self):
     if not DirectILLCollectDataTest._TEST_WS:
         DirectILLCollectDataTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL,
                                                                                       illhelpers.default_test_detectors)
     mtd.addOrReplace(self._TEST_WS_NAME, DirectILLCollectDataTest._TEST_WS)