コード例 #1
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN4/084446.nxs', ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def rosace_corr(x):
            return 1.0 - numpy.exp(-6.1343 / numpy.sqrt(x))

        def wide_angle_corr(x):
            return 0.951 * numpy.exp(-0.0887 / numpy.sqrt(x)) * (1 - numpy.exp(-5.597 / numpy.sqrt(x)))

        def eff_factor(x, corr_func):
            return corr_func(Ei) / corr_func(x)

        # Wide-angle detectors are at ws indices 0-299
        for i in range(0, 300):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            assert_almost_equal(corr.readY(i), eff_factor(e, wide_angle_corr))
        # Rosace detectors are at ws indices 300-395
        for i in range(300, 396):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            assert_almost_equal(corr.readY(i), eff_factor(e, rosace_corr))
コード例 #2
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN4/084446.nxs', ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def rosace_corr(x):
            return 1.0 - numpy.exp(-6.1343 / numpy.sqrt(x))

        def wide_angle_corr(x):
            return 0.951 * numpy.exp(-0.0887 / numpy.sqrt(x)) * (1 - numpy.exp(-5.597 / numpy.sqrt(x)))

        def eff_factor(x, corr_func):
            return corr_func(Ei) / corr_func(x)

        # Wide-angle detectors are at ws indices 0-299
        for i in range(0, 300):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            numpy.testing.assert_almost_equal(corr.readY(i), eff_factor(e, wide_angle_corr))
        # Rosace detectors are at ws indices 300-395
        for i in range(300, 396):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            numpy.testing.assert_almost_equal(corr.readY(i), eff_factor(e, rosace_corr))
コード例 #3
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN6/164192.nxs',
                                  ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF',
                                  Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def det_corr(x):
            high = x > 5.113
            low = x <= 5.113
            c = numpy.empty_like(x)
            c[high] = 0.94 * (1. - numpy.exp(-3.284 / numpy.sqrt(x[high])))
            c[low] = numpy.exp(-0.0565 / numpy.sqrt(x[low])) * (
                1. - numpy.exp(-3.284 / numpy.sqrt(x[low])))
            return c

        corr_at_Ei = det_corr(numpy.array([Ei]))[0]
        for i in range(corr.getNumberHistograms()):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            numpy.testing.assert_almost_equal(corr.readY(i),
                                              corr_at_Ei / det_corr(e))
コード例 #4
0
 def _correctByDetectorEfficiency(self, mainWS):
     """Apply detector efficiency corrections."""
     correctedWSName = self._names.withSuffix('detector_efficiency_corrected')
     correctedWS = \
         DetectorEfficiencyCorUser(InputWorkspace=mainWS,
                                   OutputWorkspace=correctedWSName,
                                   EnableLogging=self._subalgLogging)
     self._cleanup.cleanup(mainWS)
     return correctedWS
コード例 #5
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN5/104007.nxs', ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def tube_corr(x):
            return 1. - numpy.exp(-5.6 / numpy.sqrt(x))

        corr_at_Ei = tube_corr(Ei)
        for i in range(corr.getNumberHistograms()):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            assert_almost_equal(corr.readY(i), corr_at_Ei / tube_corr(e))
コード例 #6
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN5/104007.nxs', ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def tube_corr(x):
            return 1. - numpy.exp(-5.6 / numpy.sqrt(x))

        corr_at_Ei = tube_corr(Ei)
        for i in range(corr.getNumberHistograms()):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            numpy.testing.assert_almost_equal(corr.readY(i), corr_at_Ei / tube_corr(e))
コード例 #7
0
    def runTest(self):
        ws = DirectILLCollectData('ILL/IN6/164192.nxs', ElasticChannel='Default Elastic Channel',
                                  FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF')
        for i in range(ws.getNumberHistograms()):
            ws.dataY(i).fill(1)
        dE = ConvertUnits(ws, 'DeltaE', 'Direct')
        corr = DetectorEfficiencyCorUser(dE)
        Ei = corr.run().get('Ei').value

        def det_corr(x):
            high = x > 5.113
            low = x <= 5.113
            c = numpy.empty_like(x)
            c[high] = 0.94 * (1. - numpy.exp(-3.284/numpy.sqrt(x[high])))
            c[low] = numpy.exp(-0.0565 / numpy.sqrt(x[low])) * (1.- numpy.exp(-3.284 / numpy.sqrt(x[low])))
            return c

        corr_at_Ei = det_corr(numpy.array([Ei]))[0]
        for i in range(corr.getNumberHistograms()):
            x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2.
            e = Ei - x
            numpy.testing.assert_almost_equal(corr.readY(i), corr_at_Ei / det_corr(e))