Пример #1
0
    def test_background_out_of_range_throws_error(self):
        x1 = np.linspace(0, 10)
        x2 = np.linspace(-10, -1)

        spec = Spectrum(x1, x1)
        bkg = Spectrum(x2, x2)

        spec.set_background(bkg)
        with self.assertRaises(BkgNotInRangeError):
            _, test = spec.data
Пример #2
0
    def test_background_out_of_range_throws_error(self):
        x1 = np.linspace(0, 10)
        x2 = np.linspace(-10, -1)

        spec = Spectrum(x1, x1)
        bkg = Spectrum(x2, x2)

        spec.set_background(bkg)
        with self.assertRaises(BkgNotInRangeError):
            _, test = spec.data
Пример #3
0
    def test_using_background_spectrum(self):
        x = np.linspace(-5, 5, 100)
        spec_y = x**2
        bkg_y = x

        spec = Spectrum(x, spec_y)
        bkg = Spectrum(x, bkg_y)

        spec.set_background(bkg)
        new_x, new_y = spec.data

        self.array_almost_equal(new_x, x)
        self.array_almost_equal(new_y, spec_y - bkg_y)
Пример #4
0
    def test_using_background_spectrum(self):
        x = np.linspace(-5, 5, 100)
        spec_y = x ** 2
        bkg_y = x

        spec = Spectrum(x, spec_y)
        bkg = Spectrum(x, bkg_y)

        spec.set_background(bkg)
        new_x, new_y = spec.data

        self.array_almost_equal(new_x, x)
        self.array_almost_equal(new_y, spec_y - bkg_y)
Пример #5
0
    def test_using_background_spectrum_with_different_spacing(self):
        x = np.linspace(-5, 5, 100)
        spec_y = x**2
        x_bkg = np.linspace(-5, 5, 99)
        bkg_y = x_bkg

        spec = Spectrum(x, spec_y)
        bkg = Spectrum(x_bkg, bkg_y)

        spec.set_background(bkg)
        new_x, new_y = spec.data

        self.array_almost_equal(new_x, x)
        self.array_almost_equal(new_y, spec_y - x)
Пример #6
0
    def test_using_background_spectrum_with_different_spacing(self):
        x = np.linspace(-5, 5, 100)
        spec_y = x ** 2
        x_bkg = np.linspace(-5, 5, 99)
        bkg_y = x_bkg

        spec = Spectrum(x, spec_y)
        bkg = Spectrum(x_bkg, bkg_y)

        spec.set_background(bkg)
        new_x, new_y = spec.data

        self.array_almost_equal(new_x, x)
        self.array_almost_equal(new_y, spec_y - x)