diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py index 1fc30aa512ab..dfee47c7c0f7 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py @@ -125,7 +125,7 @@ def PyExec(self): self._setup() # CheckXrange(xRange, 'Time') - outWSlist = [] + out_ws_list = [] for index, filename in enumerate(self._raw_files): raw_file = self._read_raw_file(filename) @@ -139,7 +139,7 @@ def PyExec(self): unit = mtd[slice_file].getAxis(0).setUnit("Label") unit.setLabel("Spectrum Number", "") - outWSlist.append(slice_file) + out_ws_list.append(slice_file) DeleteWorkspace(raw_file) if self._save: @@ -150,6 +150,10 @@ def PyExec(self): if self._verbose: logger.notice('Output file :' + save_path) + if self._out_ws_group is not None: + all_workspaces = ','.join(out_ws_list) + GroupWorkspaces(InputWorkspaces=all_workspaces, OutputWorkspace=self._out_ws_group) + if self._plot: try: from IndirectImport import import_mantidplot diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt index f1a60d76c0b6..508f536efef0 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt @@ -39,6 +39,7 @@ set ( TEST_PY_FILES SuggestTibHYSPECTest.py UpdatePeakParameterTableValueTest.py SANSSubtractTest.py + TimeSliceTest.py ExportSampleLogsToCSVFileTest.py ExportExperimentLogTest.py PoldiMergeTest.py diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/TimeSliceTest.py b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/TimeSliceTest.py new file mode 100644 index 000000000000..093118b8effe --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/TimeSliceTest.py @@ -0,0 +1,47 @@ +import unittest +from mantid.simpleapi import * +from mantid.api import * + +class TimeSliceTest(unittest.TestCase): + + def test_basic(self): + """ + Test to ensure that algorithm completes succesfully. + """ + + TimeSlice(InputFiles=['IRS26173.raw'], + SpectraRange=[3, 53], + PeakRange=[62500, 65000], + BackgroundRange=[59000, 61500]) + + self.assertTrue(mtd.doesExist('irs26173_slice')) + + def test_group(self): + """ + Tests to ensure that result workspaces are goruped correctly. + """ + + TimeSlice(InputFiles=['IRS26173.raw'], + SpectraRange=[3, 53], + PeakRange=[62500, 65000], + BackgroundRange=[59000, 61500], + OutputWorkspaceGroup='SliceTestOut') + + self.assertTrue(mtd.doesExist('SliceTestOut')) + self.assertTrue(mtd.doesExist('irs26173_slice')) + + def test_suffix(self): + """ + Tests to ensure that output names have a suffic appended correctly. + """ + + TimeSlice(InputFiles=['IRS26173.raw'], + SpectraRange=[3, 53], + PeakRange=[62500, 65000], + BackgroundRange=[59000, 61500], + OutputNameSuffix='_graphite002_slice') + + self.assertTrue(mtd.doesExist('irs26173_graphite002_slice')) + +if __name__ == '__main__': + unittest.main() diff --git a/Code/Mantid/docs/source/algorithms/TimeSlice-v1.rst b/Code/Mantid/docs/source/algorithms/TimeSlice-v1.rst index e37faeed8349..fa9cad85fb99 100644 --- a/Code/Mantid/docs/source/algorithms/TimeSlice-v1.rst +++ b/Code/Mantid/docs/source/algorithms/TimeSlice-v1.rst @@ -23,4 +23,25 @@ A background range can also be provided which will first calculate and subtract a flat background from the raw data before the integration is performed. +Usage +----- + +.. include:: ../usagedata-note.txt + +**Example - Running TimeSlice** + +.. testcode:: ExIndirectTransmissionSimple + + TimeSlice(InputFiles=['IRS26173.raw'], + SpectraRange=[3, 53], + PeakRange=[62500, 65000]) + + print mtd.doesExist('irs26173_slice') + +Output: + +.. testoutput:: ExIndirectTransmissionSimple + + True + .. categories::