Пример #1
0
def test_errors_with_no_stat():
    """Check we get no errors when stat is None"""

    d = Data1D('x', numpy.asarray([2, 4, 10]), numpy.asarray([2, 4, 0]))
    dp = sherpaplot.DataPlot()
    dp.prepare(d, stat=None)
    assert dp.yerr is None
Пример #2
0
def test_fit(override_plot_backend):
    p = plot.FitPlot()
    r = p._repr_html_()
    assert r is None  # note: always None

    x = np.arange(5, 8, 0.5)
    y = np.ones(x.size)
    d = Data1D('n n', x, y)

    m = Const1D()

    dplot = plot.DataPlot()
    dplot.prepare(d)

    mplot = plot.ModelPlot()
    mplot.prepare(d, m)

    p.prepare(dplot, mplot)
    r = p._repr_html_()

    # different to previous checks
    assert r is not None

    if plot.backend.name == 'pylab':
        assert '<summary>FitPlot</summary>' in r
        assert '<svg ' in r
        return

    assert '<summary>DataPlot (' in r
    assert '<summary>ModelPlot (' in r
    assert '<div class="dataval">n n</div>' in r
    assert '<div class="dataval">Model</div>' in r
Пример #3
0
def test_data(override_plot_backend):
    p = plot.DataPlot()
    r = p._repr_html_()
    check_full(r, 'DataPlot', 'None', 'None', nsummary=7)  # NOT empty

    x = np.arange(5, 8, 0.5)
    y = np.ones(x.size)
    dr = y / 0.1
    d = Data1D('n n', x, y, staterror=dr)
    p.prepare(d)
    r = p._repr_html_()
    check_full(r, 'DataPlot', 'y', 'n n', nsummary=7)
Пример #4
0
print(sim_model)
print([p.fullname for p in sim_model.pars])

s1.ampl = 1.0
s1.pos = 0.0
s1.fwhm = 0.5
s2.ampl = 2.5
s2.pos = 0.5
s2.fwhm = 0.25

x = np.linspace(-1, 1, 200)
y = sim_model(x) + np.random.normal(0., 0.2, x.shape)

d = data.Data1D('simulated', x, y)
dplot = plot.DataPlot()
dplot.prepare(d)
print(">>> dplot.plot()")
print(">>> save to _static/models/combine/model_combine_data.png")

print(sim_model)
print(sim_model.op)
print(repr(sim_model.lhs))
print(repr(sim_model.rhs))
print(sim_model.parts)
for cpt in sim_model.parts:
    print(cpt)

print(sim_model([-1.0, 0, 1]))

g1 = models.Gauss1D('g1')