def test_late_rebinning(self):
        run_monitors=CreateSampleWorkspace(Function='Multiple Peaks', NumBanks=4, BankPixelWidth=1, NumEvents=100000, XUnit='Energy',
                                                     XMin=3, XMax=200, BinWidth=0.1)
        LoadInstrument(run_monitors,InstrumentName='MARI')
        ConvertUnits(InputWorkspace='run_monitors', OutputWorkspace='run_monitors', Target='TOF')
        run_monitors = mtd['run_monitors']
        tof = run_monitors.dataX(3)
        tMin = tof[0]
        tMax = tof[-1]
        run = CreateSampleWorkspace( Function='Multiple Peaks',WorkspaceType='Event',NumBanks=8, BankPixelWidth=1, NumEvents=100000,
                                    XUnit='TOF',xMin=tMin,xMax=tMax)
        LoadInstrument(run,InstrumentName='MARI')
        wb_ws   = Rebin(run,Params=[tMin,1,tMax],PreserveEvents=False)

        # References used to test against ordinary reduction
        ref_ws = Rebin(run,Params=[tMin,1,tMax],PreserveEvents=False)
        ref_ws_monitors = CloneWorkspace('run_monitors')
        # just in case, wb should work without clone too.
        wb_clone = CloneWorkspace(wb_ws)

        # Run Mono
        tReducer = DirectEnergyConversion(run.getInstrument())
        tReducer.energy_bins =  [-20,0.2,60]
        ei_guess = 67.
        mono_s = tReducer.mono_sample(run, ei_guess,wb_ws)


        #
        mono_ref = tReducer.mono_sample(ref_ws, ei_guess,wb_clone)

        rez = CheckWorkspacesMatch(mono_s,mono_ref)
        self.assertEqual(rez,'Success!')
Beispiel #2
0
    def test_late_rebinning(self):
        run_monitors = CreateSampleWorkspace(Function='Multiple Peaks',
                                             NumBanks=4,
                                             BankPixelWidth=1,
                                             NumEvents=100000,
                                             XUnit='Energy',
                                             XMin=3,
                                             XMax=200,
                                             BinWidth=0.1)
        LoadInstrument(run_monitors,
                       InstrumentName='MARI',
                       RewriteSpectraMap=True)
        ConvertUnits(InputWorkspace='run_monitors',
                     OutputWorkspace='run_monitors',
                     Target='TOF')
        run_monitors = mtd['run_monitors']
        tof = run_monitors.dataX(3)
        tMin = tof[0]
        tMax = tof[-1]
        run = CreateSampleWorkspace(Function='Multiple Peaks',
                                    WorkspaceType='Event',
                                    NumBanks=8,
                                    BankPixelWidth=1,
                                    NumEvents=100000,
                                    XUnit='TOF',
                                    xMin=tMin,
                                    xMax=tMax)
        LoadInstrument(run, InstrumentName='MARI', RewriteSpectraMap=True)

        run.setMonitorWorkspace(run_monitors)

        wb_ws = Rebin(run, Params=[tMin, 1, tMax], PreserveEvents=False)

        # References used to test against ordinary reduction
        ref_ws = Rebin(run, Params=[tMin, 1, tMax], PreserveEvents=False)
        ref_ws_monitors = CloneWorkspace('run_monitors')
        ref_ws.setMonitorWorkspace(ref_ws_monitors)
        # just in case, wb should work without clone too.
        wb_clone = CloneWorkspace(wb_ws)

        # Run Mono
        tReducer = DirectEnergyConversion(run.getInstrument())
        tReducer.energy_bins = [-20, 0.2, 60]
        ei_guess = 67.
        mono_s = tReducer.mono_sample(run, ei_guess, wb_ws)

        #
        mono_ref = tReducer.mono_sample(ref_ws, ei_guess, wb_clone)

        rez = CompareWorkspaces(mono_s, mono_ref)
        self.assertTrue(rez[0])
    def test_late_rebinning(self):
        run_monitors = CreateSampleWorkspace(
            Function="Multiple Peaks",
            NumBanks=4,
            BankPixelWidth=1,
            NumEvents=100000,
            XUnit="Energy",
            XMin=3,
            XMax=200,
            BinWidth=0.1,
        )
        LoadInstrument(run_monitors, InstrumentName="MARI", RewriteSpectraMap=True)
        ConvertUnits(InputWorkspace="run_monitors", OutputWorkspace="run_monitors", Target="TOF")
        run_monitors = mtd["run_monitors"]
        tof = run_monitors.dataX(3)
        tMin = tof[0]
        tMax = tof[-1]
        run = CreateSampleWorkspace(
            Function="Multiple Peaks",
            WorkspaceType="Event",
            NumBanks=8,
            BankPixelWidth=1,
            NumEvents=100000,
            XUnit="TOF",
            xMin=tMin,
            xMax=tMax,
        )
        LoadInstrument(run, InstrumentName="MARI", RewriteSpectraMap=True)

        run.setMonitorWorkspace(run_monitors)

        wb_ws = Rebin(run, Params=[tMin, 1, tMax], PreserveEvents=False)

        # References used to test against ordinary reduction
        ref_ws = Rebin(run, Params=[tMin, 1, tMax], PreserveEvents=False)
        ref_ws_monitors = CloneWorkspace("run_monitors")
        ref_ws.setMonitorWorkspace(ref_ws_monitors)
        # just in case, wb should work without clone too.
        wb_clone = CloneWorkspace(wb_ws)

        # Run Mono
        tReducer = DirectEnergyConversion(run.getInstrument())
        tReducer.energy_bins = [-20, 0.2, 60]
        ei_guess = 67.0
        mono_s = tReducer.mono_sample(run, ei_guess, wb_ws)

        #
        mono_ref = tReducer.mono_sample(ref_ws, ei_guess, wb_clone)

        rez = CheckWorkspacesMatch(mono_s, mono_ref)
        self.assertEqual(rez, "Success!")