Beispiel #1
0
    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 runTest(self):
     ZOOM()
     MaskFile(
         "USER_ZOOM_SANSteam_4m_SampleChanger_202A_12mm_Large_BEAMSTOP.txt")
     AssignSample("ZOOM9898")
     TransmissionSample("ZOOM9947_histo", "ZOOM9947_histo")
     WavRangeReduction()
Beispiel #3
0
    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 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 runTest(self):
     UseCompatibilityMode()
     SANS2D()
     MaskFile('MaskSANS2DReductionGUI.txt')
     BatchReduce('sans2d_reduction_gui_batch.csv',
                 '.nxs',
                 combineDet='rear')
Beispiel #6
0
    def runTest(self):
        UseCompatibilityMode()
        config['default.instrument'] = 'SANS2D'
        SANS2DTUBES()
        Set1D()
        Detector("rear-detector")
        # This contains two MASKFILE commands, each resulting in a separate 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_rear_1D_1.75_12.5')

        # 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_rear_1D_1.75_12.5.nxs')
        self._final_workspace = 'ws'
        Load(Filename=self._final_output,
             OutputWorkspace=self._final_workspace)
    def runTest(self):
        UseCompatibilityMode()
        ZOOM()
        MaskFile("16812_Userfile.toml")
        Set1D()

        AssignSample('16182')
        WavRangeReduction()
Beispiel #8
0
    def test_mask_file_handles_non_existent_user_files(self):
        tmp_dir = tempfile.gettempdir()
        non_existent_file = str(uuid.uuid1())
        file_not_there = os.path.join(tmp_dir, non_existent_file)

        self.assertFalse(os.path.exists(file_not_there))
        with self.assertRaises(FileNotFoundError):
            MaskFile(file_not_there)
    def runTest(self):
        UseCompatibilityMode()
        SANS2D()
        MaskFile('MaskSANS2DReductionGUI.txt')
        SetEventSlices("0.0-451, 5-10")

        batch_file = FileFinder.getFullPath('sans2d_reduction_gui_batch.csv')
        BatchReduce(batch_file, '.nxs', saveAlgs={}, combineDet='rear')
Beispiel #10
0
 def runTest(self):
     UseCompatibilityMode()
     SANS2D()
     Set2D()
     MaskFile("USER_SANS2D_212A_2p4_4m_M4_Sans2d_Team_8mm_Changer_After_GuideRealignment.toml")
     AssignSample("SANS2D00068982.nxs")
     TransmissionSample("SANS2D00068976.nxs", "SANS2D00069299.nxs")
     self.returned = WavRangeReduction()
Beispiel #11
0
 def runTest(self):
     UseCompatibilityMode()
     LOQ()
     MaskFile('MaskLOQData.txt')
     BatchReduce('loq_batch_mode_reduction.csv',
                 '.nxs',
                 combineDet='merged',
                 saveAlgs={})
    def runTest(self):
        UseCompatibilityMode()
        ZOOM()
        MaskFile(
            "USER_ZOOM_SANSteam_4m_SampleChanger_202A_12mm_Large_BEAMSTOP.txt")
        Set1D()

        AssignSample('16182')
        WavRangeReduction()
Beispiel #13
0
    def test_mask_file_for_existing_file(self):
        tmp_file = tempfile.NamedTemporaryFile(mode='r')

        file_name = os.path.basename(tmp_file.name)
        with mock.patch(
                'sans.command_interface.ISISCommandInterface.find_full_file_path'
        ) as mocked_finder:
            mocked_finder.return_value = tmp_file.name
            self.assertIsNone(MaskFile(file_name))
 def runTest(self):
     """
     Loads data using raw event transmission data
     """
     ZOOM()
     MaskFile(
         "USER_ZOOM_SANSteam_4m_SampleChanger_202A_12mm_Large_BEAMSTOP.txt")
     AssignSample("ZOOM9898")
     TransmissionSample("ZOOM9946", "ZOOM9946")
     WavRangeReduction()
 def runTest(self):
     UseCompatibilityMode()
     SANS2D()
     MaskFile('MaskSANS2DReductionGUI.txt')
     AssignSample('22048')
     AssignCan('22023')
     TransmissionSample('22041', '22024')
     TransmissionCan('22024', '22024')
     reduced = WavRangeReduction()
     RenameWorkspace(reduced, OutputWorkspace='trans_test_rear')
    def runTest(self):
        UseCompatibilityMode()
        SANS2D()
        Set1D()
        Detector("rear-detector")
        MaskFile('Mask_SANS2D_091_options.toml')
        Gravity(True)

        AssignSample('5512')
        self.reduced = WavRangeReduction()
    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_p7rear_1D_2.0_14.0Phi-45.0_45.0.xml'))
Beispiel #18
0
    def runTest(self):
        pass
        UseCompatibilityMode()
        SANS2D()
        Set1D()
        Detector("rear-detector")
        MaskFile('MASKSANS2Doptions.091A')
        Gravity(True)

        AssignSample('5512')
        self.reduced = WavRangeReduction()
 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')
Beispiel #20
0
    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_rear_1DPhi-45.0_45.0'
 def runTest(self):
     UseCompatibilityMode()
     SANS2D()
     MaskFile('MaskSANS2DReductionGUI.txt')
     AssignSample('22048')
     AssignCan('22023')
     TransmissionSample('22041', '22024')
     TransmissionCan('22024', '22024')
     centre = FindBeamCentre(rlow=41.0, rupp=280.0, xstart=float(150)/1000., ystart=float(-160)/1000.,
                             tolerance=0.0001251, MaxIter=3, reduction_method=True)
     self.assertDelta(centre['pos2'], -0.145, 0.0001)
     self.assertDelta(centre['pos1'], 0.15, 0.0001)
Beispiel #22
0
    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 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)
Beispiel #24
0
    def runTest(self):
        UseCompatibilityMode()
        LOQ()
        Set2D()
        Detector("main-detector-bank")
        MaskFile('MASK_094AA.toml')
        # 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)
Beispiel #25
0
 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)
Beispiel #26
0
    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)
Beispiel #27
0
    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 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)
Beispiel #29
0
    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")
Beispiel #30
0
 def runTest(self):
     UseCompatibilityMode()
     LOQ()
     MaskFile(MASKFILE)
     BatchReduce(BATCHFILE, '.nxs', combineDet='merged', saveAlgs={})