diff --git a/Testing/SystemTests/tests/analysis/LOQCentreNoGrav_V2.py b/Testing/SystemTests/tests/analysis/LOQCentreNoGrav_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..30855b7f3e8c0f15d9ced5e9cdb48fa4cc0189ca --- /dev/null +++ b/Testing/SystemTests/tests/analysis/LOQCentreNoGrav_V2.py @@ -0,0 +1,66 @@ +#pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.simpleapi import * +from ISISCommandInterface import * +from sans.command_interface.ISISCommandInterface import (LOQ, Set1D, Detector, MaskFile, Gravity, AssignSample, + TransmissionSample, AssignCan, TransmissionCan, + FindBeamCentre, WavRangeReduction, DefaultTrans, SetCentre, + UseCompatibilityMode) + +# The Find beam centre command has not been implemented yet in SANS2 hence we cannot run this test correctly +# +# class LOQCentreNoGrav(stresstesting.MantidStressTest): +# def __init__(self): +# stresstesting.MantidStressTest.__init__(self) +# self.tolerance = 1e-6 +# +# def runTest(self): +# UseCompatibilityMode() +# LOQ() +# +# Set1D() +# Detector("rear-detector") +# MaskFile('MASK.094AA') +# Gravity(False) +# +# AssignSample('54431.raw') +# TransmissionSample('54435.raw', '54433.raw') +# AssignCan('54432.raw') +# TransmissionCan('54434.raw', '54433.raw') +# +# FindBeamCentre(60, 200, 9) +# +# WavRangeReduction(3, 9, DefaultTrans) +# +# def validate(self): +# self.disableChecking.append('Instrument') +# return '54431main_1D_3.0_9.0','LOQCentreNoGravSearchCentreFixed.nxs' + + +class LOQCentreNoGravDefineCentreTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + LOQ() + Set1D() + Detector("rear-detector") + MaskFile('MASK.094AA') + Gravity(False) + SetCentre(324.765, 327.670) + + AssignSample('54431.raw') + TransmissionSample('54435.raw', '54433.raw') + AssignCan('54432.raw') + TransmissionCan('54434.raw', '54433.raw') + + WavRangeReduction(3, 9, DefaultTrans) + + def validate(self): + # Need to disable checking of the Spectra-Detector map becauseit isn't + # fully saved out to the nexus file (it's limited to the spectra that + # are actually present in the saved workspace). + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + + return '54431main_1D_3.0_9.0', 'LOQCentreNoGrav_V2.nxs' diff --git a/Testing/SystemTests/tests/analysis/LOQReductionGUITest_V2.py b/Testing/SystemTests/tests/analysis/LOQReductionGUITest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..f2797b8ac640554f234bc849d5ef469ce3f99d21 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/LOQReductionGUITest_V2.py @@ -0,0 +1,29 @@ +#pylint: disable=attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.kernel import config +from mantid.api import FileFinder, AnalysisDataService +from sans.command_interface.ISISCommandInterface import (UseCompatibilityMode, LOQ, MaskFile, BatchReduce) + +MASKFILE = FileFinder.getFullPath('MaskLOQData.txt') +BATCHFILE = FileFinder.getFullPath('loq_batch_mode_reduction.csv') + + +class LOQMinimalBatchReductionTest_V2(stresstesting.MantidStressTest): + def __init__(self): + super(LOQMinimalBatchReductionTest_V2, self).__init__() + config['default.instrument'] = 'LOQ' + + def runTest(self): + UseCompatibilityMode() + LOQ() + MaskFile(MASKFILE) + BatchReduce(BATCHFILE, '.nxs', combineDet='merged', saveAlgs={}) + + def validate(self): + # note increased tolerance to something which quite high + # this is partly a temperary measure, but also justified by + # when overlaying the two options they overlap very well --> what does this comment mean? + self.tolerance = 1.0e+1 + self.disableChecking.append('Instrument') + return 'first_time_merged', 'LOQReductionMergedData.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..650140bd212548ed5b9f41f42c636858e32d178d --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py @@ -0,0 +1,117 @@ +#pylint: disable=no-init,attribute-defined-outside-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting + +from mantid import config +from mantid.api import (FileFinder) +from mantid.simpleapi import (Load, DeleteWorkspace, mtd) +from sans.command_interface.ISISCommandInterface import (SANS2DTUBES, SANS2D, Set1D, Detector, + MaskFile, Gravity, BatchReduce, UseCompatibilityMode) +import os.path + + +class SANS2DBatchTest_V2(stresstesting.MantidStressTest): + + def runTest(self): + UseCompatibilityMode() + SANS2D() + Set1D() + Detector("rear-detector") + MaskFile('MASKSANS2Doptions.091A') + Gravity(True) + + csv_file = FileFinder.getFullPath('SANS2D_periodTests.csv') + + BatchReduce(csv_file, 'nxs', plotresults=False, saveAlgs={'SaveCanSAS1D': 'xml', 'SaveNexus': 'nxs'}) + os.remove(os.path.join(config['defaultsave.directory'], '5512p7_SANS2DBatch.xml')) + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + + return '5512p7_SANS2DBatch', 'SANS2DBatch.nxs' + + +class SANS2DNewSettingsCarriedAcrossInBatchModeTest_V2(stresstesting.MantidStressTest): + """ + We want to make sure that any settings saved in the PropertyManager objects + are used across all iterations of the reduction in Batch mode. The MASKFILE + command uses this new way of storing settings in ISIS SANS, and so we'll + see if the same masks get applied in the second iteration as they do in the + first. + """ + + def runTest(self): + UseCompatibilityMode() + config['default.instrument'] = 'SANS2D' + SANS2D() + Set1D() + Detector("rear-detector") + # This contains two MASKFILE commands, each resulting in a separate call to MaskDetectors. + MaskFile('MaskSANS2DReductionGUI_MaskFiles.txt') + Gravity(True) + + # This does 2 separate reductions of the same data, but saving the result of each to a different workspace. + csv_file = FileFinder.getFullPath("SANS2D_mask_batch.csv") + BatchReduce(csv_file, 'nxs', plotresults=False) + + path1 = os.path.join(config['defaultsave.directory'], 'iteration_1.xml') + path2 = os.path.join(config['defaultsave.directory'], 'iteration_2.xml') + if os.path.exists(path1): + os.remove(path1) + if os.path.exists(path2): + os.remove(path2) + + def validate(self): + self.tolerance_is_reller = True + self.tolerance = 1.0e-2 + self.disableChecking.append('Instrument') + return "iteration_2", "SANS2DNewSettingsCarriedAcross.nxs" + + +class SANS2DTUBESBatchWithZeroErrorCorrectionTest_V2(stresstesting.MantidStressTest): + """ + We want to make sure that the BatchMode can remove zero error values + and replace them with a large default value. + """ + + def runTest(self): + UseCompatibilityMode() + config['default.instrument'] = 'SANS2D' + SANS2DTUBES() + Set1D() + Detector("rear-detector") + # This contains two MASKFILE commands, each resulting in a seperate call to MaskDetectors. + MaskFile('SANS2DTube_ZerroErrorFreeTest.txt') + + # Saves a file which produces an output file which does not contain any zero errors + csv_file = FileFinder.getFullPath("SANS2DTUBES_ZeroErrorFree_batch.csv") + save_alg = {"SaveNexus": "nxs"} + BatchReduce(csv_file, 'nxs', saveAlgs=save_alg, plotresults=False, save_as_zero_error_free=True) + DeleteWorkspace('zero_free_out') + + # The zero correction only occurs for the saved files. Stephen King mentioned that the + # original workspaces should not be tampered with + self._final_output = os.path.join(config['defaultsave.directory'], 'zero_free_out.nxs') + self._final_workspace = 'ws' + Load(Filename=self._final_output, OutputWorkspace=self._final_workspace) + + def validate(self): + self.tolerance_is_reller = True + self.tolerance = 1.0e-2 + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Instrument') + self.disableChecking.append('Axes') + return self._final_workspace, "SANS2DTube_withZeroErrorCorrections.nxs" + + def validateMethod(self): + return "WorkspaceToNexus" + + def cleanup(self): + # Delete the stored file + os.remove(self._final_output) + # Delete the workspace + if self._final_workspace in mtd: + DeleteWorkspace(self._final_workspace) diff --git a/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..9069328084db0782294ab0bf0902cadc999f3cc8 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py @@ -0,0 +1,49 @@ +#pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.simpleapi import * +from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, SetDetectorOffsets, Gravity, Set1D, + UseCompatibilityMode, AssignSample, WavRangeReduction) + + +class SANS2DFrontNoGravTest_V2(stresstesting.MantidStressTest): + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile('MASKSANS2D_094i_RKH.txt') + SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0) + SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0) + Gravity(False) + Set1D() + + AssignSample('2500.nxs') + + WavRangeReduction(4.6, 12.85, False) + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '2500front_1D_4.6_12.85', 'SANS2DFrontNoGrav.nxs' + + +class SANS2DWithExtraLengthGravityTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile('MASKSANS2D_094i_RKH.txt') + SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0) + SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0) + + extraLength = 1 + Gravity(True, extraLength) + Set1D() + AssignSample('2500.nxs') + WavRangeReduction(4.6, 12.85, False) + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '2500front_1D_4.6_12.85','SANS2DWithExtraLengthGravity.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..4649d6a4b3a762c45aa629a43470969a8caee2a0 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py @@ -0,0 +1,22 @@ +#pylint: disable=no-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting +import mantid +from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, AssignSample, WavRangeReduction, + UseCompatibilityMode) + + +class SANS2DLimitEventsTimeTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile('MaskSANS2DReductionGUI_LimitEventsTime.txt') + AssignSample('22048') + WavRangeReduction() + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '22048rear_1D_1.5_12.5', 'SANSReductionGUI_LimitEventsTime.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..3a614906d754483382f0926da2d4272fc9a1043f --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py @@ -0,0 +1,85 @@ +#pylint: disable=no-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting +import os +from mantid.kernel import config +from mantid.api import AnalysisDataService +from sans.command_interface.ISISCommandInterface import (SANS2D, Set1D, Detector, MaskFile, Gravity, AssignSample, + WavRangeReduction, DefaultTrans, UseCompatibilityMode, + AddRuns, LARMOR) + + +class SANS2DMultiPeriodAddFiles_V2(stresstesting.MantidStressTest): + + def requiredMemoryMB(self): + """Requires 2.5Gb""" + return 2500 + + def runTest(self): + UseCompatibilityMode() + SANS2D() + Set1D() + Detector("rear-detector") + MaskFile('MASKSANS2Doptions.091A') + Gravity(True) + AddRuns(('5512', '5512'), 'SANS2D', 'nxs', lowMem=True) + + # one period of a multi-period Nexus file + AssignSample('5512-add.nxs', period=7) + + WavRangeReduction(2, 4, DefaultTrans) + paths = [os.path.join(config['defaultsave.directory'], 'SANS2D00005512-add.nxs'), + os.path.join(config['defaultsave.directory'], 'SANS2D00005512.log')] + for path in paths: + if os.path.exists(path): + os.remove(path) + + def validate(self): + # Need to disable checking of the Spectra-Detector map because it isn't + # fully saved out to the nexus file (it's limited to the spectra that + # are actually present in the saved workspace). + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Instrument') + self.disableChecking.append('Axes') + + return '5512p7rear_1D_2.0_4.0Phi-45.0_45.0', 'SANS2DMultiPeriodAddFiles.nxs' + + +class LARMORMultiPeriodAddEventFilesTest_V2(stresstesting.MantidStressTest): + def requiredMemoryMB(self): + """Requires 2.5Gb""" + return 2500 + + def runTest(self): + UseCompatibilityMode() + LARMOR() + Set1D() + Detector("DetectorBench") + MaskFile('USER_LARMOR_151B_LarmorTeam_80tubes_BenchRot1p4_M4_r3699.txt') + Gravity(True) + AddRuns(('13065', '13065'), 'LARMOR', 'nxs', lowMem=True) + + AssignSample('13065-add.nxs') + WavRangeReduction(2, 4, DefaultTrans) + + # Clean up + for element in AnalysisDataService.getObjectNames(): + if AnalysisDataService.doesExist(element) and element != "13065p1rear_1D_2.0_4.0": + AnalysisDataService.remove(element) + + paths = [os.path.join(config['defaultsave.directory'], 'LARMOR00013065-add.nxs'), + os.path.join(config['defaultsave.directory'], 'SANS2D00013065.log')] # noqa + for path in paths: + if os.path.exists(path): + os.remove(path) + + def validate(self): + # Need to disable checking of the Spectra-Detector map because it isn't + # fully saved out to the nexus file (it's limited to the spectra that + # are actually present in the saved workspace). + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Instrument') + self.disableChecking.append('Axes') + + return "13065p1rear_1D_2.0_4.0", "LARMORMultiPeriodAddEventFiles.nxs" diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..eb3bbccc24e5975a758f15ae7a88440e4a757597 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py @@ -0,0 +1,108 @@ +#pylint: disable=no-init,too-few-public-methods + +from __future__ import (absolute_import, division, print_function) +import stresstesting +import mantid + +from mantid.api import (AnalysisDataService, FileFinder) +from sans.command_interface.ISISCommandInterface import (SANS2D, Set1D, Detector, MaskFile, Gravity, + UseCompatibilityMode, AssignSample, WavRangeReduction, + LARMOR, BatchReduce) + +# test batch mode with sans2d and selecting a period in batch mode + + +class SANS2DMultiPeriodSingleTest_V2(stresstesting.MantidStressTest): + + reduced = '' + + def runTest(self): + pass + UseCompatibilityMode() + SANS2D() + Set1D() + Detector("rear-detector") + MaskFile('MASKSANS2Doptions.091A') + Gravity(True) + + AssignSample('5512') + self.reduced = WavRangeReduction() + + def validate(self): + # Need to disable checking of the Spectra-Detector map because it isn't + # fully saved out to the nexus file (it's limited to the spectra that + # are actually present in the saved workspace). + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return AnalysisDataService[self.reduced][6].name(),'SANS2DBatch.nxs' + + +class SANS2DMultiPeriodBatchTest_V2(SANS2DMultiPeriodSingleTest_V2): + + def runTest(self): + UseCompatibilityMode() + SANS2D() + Set1D() + Detector("rear-detector") + MaskFile('MASKSANS2Doptions.091A') + Gravity(True) + + csv_file = FileFinder.getFullPath('SANS2D_multiPeriodTests.csv') + + BatchReduce(csv_file, 'nxs', saveAlgs={}) + self.reduced = '5512_SANS2DBatch' + + +class LARMORMultiPeriodEventModeLoadingTest_V2(stresstesting.MantidStressTest): + """ + This test checks if the positioning of all workspaces of a + multi-period event-type file are the same. + """ + def __init__(self): + super(LARMORMultiPeriodEventModeLoadingTest_V2, self).__init__() + self.success = True + + def _get_position_and_rotation(self, workspace): + instrument = workspace.getInstrument() + component = instrument.getComponentByName("DetectorBench") + position = component.getPos() + rotation = component.getRotation() + return position, rotation + + def _clean_up(self, base_name, number_of_workspaces): + for index in range(1, number_of_workspaces + 1): + workspace_name = base_name + str(index) + monitor_name = workspace_name + "_monitors" + AnalysisDataService.remove(workspace_name) + AnalysisDataService.remove(monitor_name) + AnalysisDataService.remove("80tubeCalibration_18-04-2016_r9330-9335") + + def _check_if_all_multi_period_workspaces_have_the_same_position(self, base_name, number_of_workspaces): + + reference_name = base_name + str(1) + reference_workspace = AnalysisDataService.retrieve(reference_name) + reference_position, reference_rotation = self._get_position_and_rotation(reference_workspace) + for index in range(2, number_of_workspaces + 1): + ws_name = base_name + str(index) + workspace = AnalysisDataService.retrieve(ws_name) + position, rotation = self._get_position_and_rotation(workspace) + if position != reference_position or rotation != reference_rotation: + self.success = False + + def runTest(self): + LARMOR() + Set1D() + Detector("DetectorBench") + MaskFile('USER_Larmor_163F_HePATest_r13038.txt') + AssignSample('13038') + # Different in V2. We need to call the reduction in order to load the data. Hence we add the + # WaveRangeReduction here. + WavRangeReduction() + base_name = "13038_sans_nxs_" + number_of_workspaces = 4 + self._check_if_all_multi_period_workspaces_have_the_same_position(base_name, number_of_workspaces) + self._clean_up(base_name, number_of_workspaces) + + def validate(self): + return self.success diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..506d867ad4baae69ab175600ddc102ced78904c0 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py @@ -0,0 +1,143 @@ +#pylint: disable=invalid-name + +""" +One test has been removed from the port since it uses the ReductionSingleton. +""" + +from __future__ import (absolute_import, division, print_function) +import mantid +import stresstesting +import os +from mantid.api import AnalysisDataService +from mantid.kernel import config +from mantid.simpleapi import DeleteWorkspace +import SANSadd2 +from sans.command_interface.ISISCommandInterface import (SANS2DTUBES, MaskFile, SetDetectorOffsets, Gravity, Set1D, + AddRuns, AssignSample, AssignCan, TransmissionSample, + TransmissionCan, WavRangeReduction, UseCompatibilityMode) + + +class SANS2DAddedEventFilesWithOverlayTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + SANS2DTUBES() + MaskFile('USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt') + SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0) + SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0) + Gravity(False) + Set1D() + + # add files (SAMPLE and CAN) + AddRuns(runs=('28827', '28797'), instrument='SANS2DTUBES', defType='.nxs', rawTypes=('.add', '.raw', '.s*'), + lowMem=False, saveAsEvent=True, isOverlay=True) + AddRuns(('28823', '28793'), 'SANS2DTUBES', defType='.nxs', rawTypes=('.add', '.raw', '.s*'), + lowMem=False, saveAsEvent=True, isOverlay=True) + + AssignSample(r'SANS2D00028797-add.nxs', reload=True) + AssignCan(r'SANS2D00028793-add.nxs', reload=True) + TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs') + TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs') + + WavRangeReduction() + + def validate(self): + self.tolerance = 0.01 + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '28827rear_1D_1.75_16.5', 'SANS2DTUBES_AddedEventFilesWithOverlay.nxs' + + def cleanup(self): + # Delete all workspaces + for ws in AnalysisDataService.getObjectNames(): + DeleteWorkspace(Workspace=ws) + # Delete the stored files + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028793-add.nxs')) + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028797-add.nxs')) + + +class SANS2DAddedEventFilesWithOverlayAndTimeShiftTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + SANS2DTUBES() + MaskFile('USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt') + SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0) + SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0) + Gravity(False) + Set1D() + + # add files (SAMPLE and CAN) + time_shifts = [1] + SANSadd2.add_runs(('28827', '28797'), 'SANS2DTUBES', '.nxs', + rawTypes=('.add', '.raw', '.s*'), lowMem=False, + saveAsEvent=True, isOverlay=True, time_shifts=time_shifts) + SANSadd2.add_runs(('28823', '28793'), 'SANS2DTUBES', '.nxs', + rawTypes=('.add', '.raw', '.s*'), lowMem=False, + saveAsEvent=True, isOverlay=True, time_shifts=time_shifts) + + AssignSample(r'SANS2D00028797-add.nxs', reload=True) + AssignCan(r'SANS2D00028793-add.nxs', reload=True) + TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs') + TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs') + + WavRangeReduction() + + def validate(self): + # we have double the sample and the can, this means that the reduced data will be + # almost the same + self.tolerance = 0.01 + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '28827rear_1D_1.75_16.5', 'SANS2DTUBES_AddedEventFilesWithOverlayAndTimeShifts.nxs' + + def cleanup(self): + # Delete all workspaces + for ws in AnalysisDataService.getObjectNames(): + DeleteWorkspace(Workspace=ws) + # Delete the stored files + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028793-add.nxs')) + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028797-add.nxs')) + + +class SANS2DAddedEventFilesWithoutOverlayTest_V2(stresstesting.MantidStressTest): + def runTest(self): + UseCompatibilityMode() + SANS2DTUBES() + MaskFile('USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt') + SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0) + SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0) + Gravity(False) + Set1D() + + # add files (SAMPLE and CAN) + SANSadd2.add_runs(('28827', '28797'), 'SANS2DTUBES', '.nxs', + rawTypes=('.add', '.raw', '.s*'), lowMem=False, + saveAsEvent=True, isOverlay=False) + SANSadd2.add_runs(('28823', '28793'), 'SANS2DTUBES', '.nxs', + rawTypes=('.add', '.raw', '.s*'), lowMem=False, + saveAsEvent=True, isOverlay=False) + + AssignSample(r'SANS2D00028797-add.nxs', reload=True) + AssignCan(r'SANS2D00028793-add.nxs', reload=True) + TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs') + TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs') + + WavRangeReduction() + + def validate(self): + # we have double the sample and the can, this means that the reduced data will be + # almost the same + self.tolerance = 0.01 + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + return '28827rear_1D_1.75_16.5', 'SANS2DTUBES_AddedEventFilesWithoutOverlay.nxs' + + def cleanup(self): + # Delete all workspaces + for ws in AnalysisDataService.getObjectNames(): + DeleteWorkspace(Workspace=ws) + # Delete the stored files + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028793-add.nxs')) + os.remove(os.path.join(config['defaultsave.directory'], 'SANS2D00028797-add.nxs')) diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..b7a7808547d6e45120e7cd87c1ab108faaca0a68 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py @@ -0,0 +1,62 @@ +#pylint: disable=invalid-name,attribute-defined-outside-init +""" +The tests here are ports from the original SANS2DReductionGUI.py test suite. Not all tests can be ported since they +include details about the ReductionSingleton +""" + +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.kernel import (config) +from mantid.api import (FileFinder) +from mantid.simpleapi import RenameWorkspace +from sans.command_interface.ISISCommandInterface import (BatchReduce, SANS2D, MaskFile, AssignSample, AssignCan, + TransmissionSample, TransmissionCan, WavRangeReduction, + UseCompatibilityMode, Set1D) + +MASKFILE = FileFinder.getFullPath('MaskSANS2DReductionGUI.txt') +BATCHFILE = FileFinder.getFullPath('sans2d_reduction_gui_batch.csv') + + +class SANS2DMinimalBatchReductionTest_V2(stresstesting.MantidStressTest): + """Minimal script to perform full reduction in batch mode + """ + def __init__(self): + super(SANS2DMinimalBatchReductionTest_V2, self).__init__() + config['default.instrument'] = 'SANS2D' + self.tolerance_is_reller = True + self.tolerance = 1.0e-2 + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile(MASKFILE) + BatchReduce(BATCHFILE, '.nxs', combineDet='rear') + + def validate(self): + self.disableChecking.append('Instrument') + return "trans_test_rear", "SANSReductionGUI.nxs" + + +class SANS2DMinimalSingleReductionTest_V2(stresstesting.MantidStressTest): + """Minimal script to perform full reduction in single mode""" + + def __init__(self): + super(SANS2DMinimalSingleReductionTest_V2, self).__init__() + config['default.instrument'] = 'SANS2D' + self.tolerance_is_reller = True + self.tolerance = 1.0e-2 + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile(MASKFILE) + AssignSample('22048') + AssignCan('22023') + TransmissionSample('22041', '22024') + TransmissionCan('22024', '22024') + reduced = WavRangeReduction() + RenameWorkspace(reduced, OutputWorkspace='trans_test_rear') + + def validate(self): + self.disableChecking.append('Instrument') + return "trans_test_rear", "SANSReductionGUI.nxs" diff --git a/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..9c9a9534fe974bbaeb091c8e85c9d4c7e2647278 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py @@ -0,0 +1,57 @@ +#pylint: disable=invalid-name,attribute-defined-outside-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.api import (AnalysisDataService, FileFinder) +from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, BatchReduce, SetEventSlices, + UseCompatibilityMode, AssignSample, AssignCan, + TransmissionSample, TransmissionCan, WavRangeReduction) +from mantid.simpleapi import RenameWorkspace + +MASKFILE = FileFinder.getFullPath('MaskSANS2DReductionGUI.txt') +BATCHFILE = FileFinder.getFullPath('sans2d_reduction_gui_batch.csv') + + +class SANS2DMinimalBatchReductionSlicedTest_V2(stresstesting.MantidStressTest): + def __init__(self): + super(SANS2DMinimalBatchReductionSlicedTest_V2, self).__init__() + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile(MASKFILE) + SetEventSlices("0.0-451, 5-10") + BatchReduce(BATCHFILE, '.nxs', saveAlgs={}, combineDet='rear') + + def validate(self): + self.tolerance = 0.02 + self.tolerance_is_reller=True + self.disableChecking.append('Instrument') + return str(AnalysisDataService['trans_test_rear'][0]), 'SANSReductionGUI.nxs' + + +class SANS2DMinimalSingleReductionSlicedTest_V2(stresstesting.MantidStressTest): + def __init__(self): + super(SANS2DMinimalSingleReductionSlicedTest_V2, self).__init__() + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile(MASKFILE) + AssignSample('22048') + AssignCan('22023') + TransmissionSample('22041', '22024') + TransmissionCan('22024', '22024') + SetEventSlices("0.0-450, 5-10") + reduced = WavRangeReduction() + RenameWorkspace(reduced, OutputWorkspace='trans_test_rear') + + def validate(self): + self.tolerance = 0.02 + self.tolerance_is_reller=True + self.disableChecking.append('Instrument') + return str(AnalysisDataService['trans_test_rear'][0]), 'SANSReductionGUI.nxs' + +# if __name__ == "__main__": +# test = SANS2DMinimalBatchReductionSlicedTest_V2() +# test.execute() diff --git a/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..8c8255bb2f39dc82f49acb9d1384822cf36fa5b4 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py @@ -0,0 +1,31 @@ +#pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) +import stresstesting +import mantid +from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, Gravity, Set1D, AssignSample, + TransmissionSample, AssignCan, TransmissionCan, + CompWavRanges, UseCompatibilityMode) + + +class SANS2DWaveloopsTest_V2(stresstesting.MantidStressTest): + + def runTest(self): + UseCompatibilityMode() + SANS2D() + MaskFile('MASKSANS2D.091A') + Gravity(True) + Set1D() + + AssignSample('992.raw') + TransmissionSample('988.raw', '987.raw') + AssignCan('993.raw') + TransmissionCan('989.raw', '987.raw') + CompWavRanges([3, 5, 7, 11], False) + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + # testing one of the workspaces that is produced, best not to choose the + # first one in produced by the loop as this is the least error prone + return '992rear_1D_7.0_11.0', 'SANS2DWaveloops.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py b/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..c394aceab17463c573a3dfe822032076ace88cad --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py @@ -0,0 +1,40 @@ +#pylint: disable=no-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting +import os.path +from mantid.kernel import config +from mantid.api import FileFinder +from mantid.simpleapi import (LoadNexus, Plus) +from sans.command_interface.ISISCommandInterface import (LOQ, Detector, Set1D, MaskFile, Gravity, + BatchReduce, UseCompatibilityMode) + + +class SANSLOQBatchTest_V2(stresstesting.MantidStressTest): + + def runTest(self): + UseCompatibilityMode() + LOQ() + Detector("main-detector-bank") + csv_file = FileFinder.getFullPath('batch_input.csv') + + Set1D() + MaskFile('MASK.094AA') + Gravity(True) + + BatchReduce(csv_file, 'raw', plotresults=False, saveAlgs={'SaveCanSAS1D': 'xml', 'SaveNexus': 'nxs'}) + + LoadNexus(Filename='54433sans.nxs', OutputWorkspace='result') + Plus(LHSWorkspace='result', RHSWorkspace='99630sanotrans', OutputWorkspace= 'result') + + os.remove(os.path.join(config['defaultsave.directory'],'54433sans.nxs')) + os.remove(os.path.join(config['defaultsave.directory'],'99630sanotrans.nxs')) + os.remove(os.path.join(config['defaultsave.directory'],'54433sans.xml')) + os.remove(os.path.join(config['defaultsave.directory'],'99630sanotrans.xml')) + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + + return 'result','SANSLOQBatch.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py b/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..4f70610523b6fd4747e37da8edc9ae1c1d1d7959 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py @@ -0,0 +1,39 @@ +#pylint: disable=no-init + +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.simpleapi import * +from sans.command_interface.ISISCommandInterface import (LOQ, Set2D, Detector, MaskFile, SetDetectorOffsets, Gravity, + AssignSample, AssignCan, WavRangeReduction, + UseCompatibilityMode) + +# Test is giving odd results on Linux, but only this 2D one. + + +class SANSLOQCan2DTest_V2(stresstesting.MantidStressTest): + + def runTest(self): + UseCompatibilityMode() + LOQ() + Set2D() + Detector("main-detector-bank") + MaskFile('MASK.094AA') + # apply some small artificial shift + SetDetectorOffsets('REAR', -1.0, 1.0, 0.0, 0.0, 0.0, 0.0) + Gravity(True) + + AssignSample('99630.RAW') # They file seems to be named wrongly. + AssignCan('99631.RAW') # The file seems to be named wrongly. + + WavRangeReduction(None, None, False) + + def validate(self): + # Need to disable checking of the Spectra-Detector map because it isn't + # fully saved out to the nexus file (it's limited to the spectra that + # are actually present in the saved workspace). + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Instrument') + #when comparing LOQ files you seem to need the following + self.disableChecking.append('Axes') + + return '53615main_2D_2.2_10.0','SANSLOQCan2D.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py new file mode 100644 index 0000000000000000000000000000000000000000..45d2f797db83c9e32490aed5460f39b976ed97c3 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py @@ -0,0 +1,52 @@ +#pylint: disable=invalid-name + +from __future__ import (absolute_import, division, print_function) +import stresstesting +from mantid.simpleapi import DeleteWorkspace, mtd +from sans.command_interface.ISISCommandInterface import (SANS2DTUBES, MaskFile, SetDetectorOffsets, Gravity, Set1D, + SetFrontDetRescaleShift, WavRangeReduction, AssignSample, + AssignCan, TransmissionSample, TransmissionCan, + UseCompatibilityMode) + + +class SANSMergedDetectorsTest_V2(stresstesting.MantidStressTest): + def __init__(self): + stresstesting.MantidStressTest.__init__(self) + + def runTest(self): + # Select instrument and user file + #UseCompatibilityMode() + SANS2DTUBES() + MaskFile(file_name='USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt') + + # Setup detector positions + SetDetectorOffsets(bank='REAR', x=-16.0, y=58.0, z=0.0, rot=0.0, radius=0.0, side=0.0) + SetDetectorOffsets(bank='FRONT', x=-44.0, y=-20.0, z=47.0, rot=0.0, radius=1.0, side=1.0) + Gravity(False) + + # Set the front detector fitting + SetFrontDetRescaleShift(scale=1.0, shift=0.0, fitScale=True, fitShift=True) + Set1D() + + # Assign data + AssignSample(r'SANS2D00028797.nxs', reload=True) + AssignCan(r'SANS2D00028793.nxs', reload=True) + TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs') + TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs') + + # Run the reduction and request FRONT and BACK to be merged + WavRangeReduction(combineDet="merged") + from mantid.simpleapi import SaveNexus + SaveNexus(Filename="C:/Sandbox/merged_event.nxs", InputWorkspace="28797merged_1D_1.75_16.5") + + def validate(self): + self.disableChecking.append('SpectraMap') + self.disableChecking.append('Axes') + self.disableChecking.append('Instrument') + self.tolerance = 1e-07 + return '28797merged_1D_1.75_16.5', 'SANS2DTUBES_Merged_Reduction.nxs' + + def cleanup(self): + # Delete all workspaces + for ws in mtd.getObjectNames(): + DeleteWorkspace(Workspace=ws)