Ejemplo n.º 1
0
def test_infer_with_level_keys():
    t = lines.Generic(E_l=[100],E_u=[150])
    assert t['E_l'] == [100.]
    assert t['E_u'] == [150.]
    assert t['ν'] == [50.]
    t = lines.Generic(data={'ν':[100],'E_u':[150]})
    assert t['E_l'] == [50.]
    t = lines.Generic(data={'E_l':[100],'E_l:unc':[0.5],'E_u':[150],'E_u:unc':[0.2]})
    t.set('E_l','unc',0.5)
    t.set('E_u','unc',0.2)
    assert t['ν'] == [50.]
    assert t['ν','unc'] == [approx(np.sqrt(0.5**2+0.2**2))]
Ejemplo n.º 2
0
def test_get_upper_lower_levels():
    t = lines.Generic()
    t.load('data/test_lines')
    u = t.get_upper_level()
    l = t.get_lower_level()
    assert len(u) == 32
    assert len(l) == 32
Ejemplo n.º 3
0
def test_assignment():
    t = lines.Generic(name='ddd')
    assert t.name == 'ddd'
    t.description = 'fff'
    t['ν'] = [1,2]
    assert all(t['ν'] == [1,2])
    t['ν'] = 100.
    t['E_l'] = 150.
Ejemplo n.º 4
0
def test_calculate_plot_spectrum():
    t = lines.Generic()
    t.load('data/test_lines')
    x,y = t.calculate_spectrum(xkey='ν',ykey='f')
    assert len(x)==10000
    assert sum(y) == approx(0.00903753325337632)
    t.plot_spectrum(xkey='ν',ykey='f')
    if show_plots:
        plotting.plt.title('test_calculate_plot_spectrum')
        plotting.show()
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
def test_load_lines():
    t = lines.Generic()
    t.load('data/test_lines')
    assert abs(t['ν'][0]-38358.664)<1e-2
    assert len(t)==32
Ejemplo n.º 7
0
def test_construct():
    t = lines.Generic()