def test_to_and_from_json(self): os.chdir(dir_path) self.sp.to_json(Path("spectrum.json")) ssp = pysfg.json_to_spectrum(Path("results/spectrum.json")) # There is some numerical uncertainty self.assertEqual(np.all(self.sp.normalized - ssp.normalized < 0.0001), True)
def test_spe4(self): sp = pysfg.json_to_spectrum(dir_path / Path("results/sample_spe.json")) self.assertAlmostEqual(sp.normalized.mean(), 0.14295257054703953)
def test_spe3(self): sp = pysfg.json_to_spectrum(dir_path / Path("results/sample_spe.json")) self.assertAlmostEqual(sp.basesubed.mean(), 100.2533, 4)
def test_spe2(self): sp = pysfg.json_to_spectrum(dir_path / Path("results/sample_spe.json")) self.assertAlmostEqual(sp.wavenumber.mean(), 2574.9315, 4)
def test_spe7(self): sp = pysfg.json_to_spectrum(dir_path / Path("./results/quartz_v2_spe.json")) self.assertAlmostEqual(sp.wavenumber.mean(), 1796.6368, 4)
def test_spe6(self): sp = pysfg.json_to_spectrum(dir_path / Path("results/quartz_v2_spe.json")) self.assertEqual(sp.basesubed.mean(), 1647.569375)