def test_model_intensity(): t = spectrum.Model() t.add_intensity(intensity=1) t.get_spectrum(range(5)) assert len(t.y) == 5 assert t.x[0] == 0 assert t.y[0] == 1 t = spectrum.Model() t.add_intensity(intensity=P(1, False, 1e-3)) t.get_spectrum(range(5)) assert len(t.y) == 5 assert t.x[0] == 0 assert t.y[0] == 1
def test_residual_intensity(): e = spectrum.Experiment(filename='data/CS2_experimental_spectrum.h5') t = spectrum.Model(experiment=e) t.add_intensity(intensity=1) t.construct() assert len(t.y) == 25000 assert np.min(t.residual) == approx(-0.7982384401866275) assert np.max(t.residual) == approx(0.041907587784343336)
def test_fit_intensity(): e = spectrum.Experiment(filename='data/CS2_experimental_spectrum.h5') t = spectrum.Model(experiment=e) t.add_intensity(intensity=P(1.1, True, 1e-3)) t.optimise() if make_plot: fig = plotting.qfig() t.plot() assert t.rms == approx(0.04259560696454527, 1e-3)
def test_model_some_lines(): linelist = lines.Generic('linelist') linelist.load_from_string(''' species = 'H2O' Teq = 300 ν |τ |Γ 100|0.1|1 110|0.5|1 115|2 |3 ''') mod = spectrum.Model('mod') mod.add_intensity(intensity=1) mod.add_absorption_lines(lines=linelist) mod.get_spectrum(x=np.arange(90, 130, 1e-2)) if make_plot: plotting.qfig() mod.plot()
def test_construct_model(): t = spectrum.Model() x = np.arange(1, 100, 0.1) y = t.get_spectrum(x) assert np.all(y == 0) assert len(x) == 990
def test_init(): spectrum.Experiment() spectrum.Model()