Ejemplo n.º 1
0
def test_combine_models2d():
    """Check we can combine 2D models"""

    mdls = [
        basic.Box2D(),
        basic.Const2D(),
        basic.Gauss2D(),
        basic.NormGauss2D()
    ]
    mdl = reduce(operator.add, mdls)
    assert isinstance(mdl, BinaryOpModel)

    # now multiply by a constant
    #
    mdl *= 2
    assert isinstance(mdl, BinaryOpModel)
    assert mdl.ndim == 2

    # Check we can call it as a 2D model; there is minimal checks
    # of the response.
    #
    bins1 = np.arange(2, 10, 2)
    bins2 = bins1 - 4

    # only test non-integrated model
    y1 = mdl(bins1, bins2)

    assert y1.shape == (4, )
Ejemplo n.º 2
0
def test_combine_models_1d_2d():
    """What happens when we combine 1D and 2D models?"""

    m1 = basic.Box1D()
    m2 = basic.Box2D()

    with pytest.raises(ModelErr) as exc:
        m1 + m2

    assert str(exc.value) == 'Models do not match: 1D (box1d) and 2D (box2d)'
Ejemplo n.º 3
0
def example_psf():
    """Create an example PSF."""

    # Note that the PSF coordinates have to match the data.
    #
    psf = basic.Box2D()
    psf.xlow = 8
    psf.xhi = 12
    psf.ylow = 0
    psf.yhi = 3
    return psf