def test_background_out_of_range_throws_error(self): x1 = np.linspace(0, 10) x2 = np.linspace(-10, -1) spec = Pattern(x1, x1) background_spectrum = Pattern(x2, x2) with self.assertRaises(BkgNotInRangeError): spec.background_pattern = background_spectrum
def test_using_background_spectrum(self): x = np.linspace(-5, 5, 100) spec_y = x ** 2 bkg_y = x spec = Pattern(x, spec_y) background_spectrum = Pattern(x, bkg_y) spec.background_pattern = background_spectrum new_x, new_y = spec.data self.array_almost_equal(new_x, x) self.array_almost_equal(new_y, spec_y - bkg_y)
def test_using_background_spectrum(self): x = np.linspace(-5, 5, 100) spec_y = x**2 bkg_y = x spec = Pattern(x, spec_y) background_spectrum = Pattern(x, bkg_y) spec.background_pattern = background_spectrum new_x, new_y = spec.data self.array_almost_equal(new_x, x) self.array_almost_equal(new_y, spec_y - bkg_y)
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 = Pattern(x, spec_y) background_spectrum = Pattern(x_bkg, bkg_y) spec.background_pattern = background_spectrum new_x, new_y = spec.data self.array_almost_equal(new_x, x) self.array_almost_equal(new_y, spec_y - x)
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 = Pattern(x, spec_y) background_spectrum = Pattern(x_bkg, bkg_y) spec.background_pattern = background_spectrum new_x, new_y = spec.data self.array_almost_equal(new_x, x) self.array_almost_equal(new_y, spec_y - x)