Exemplo n.º 1
0
def check_integrals():
    """Check that Sherpa normed models integrate to 1."""
    from sherpa.astro import ui
    from sherpa.astro.ui import normgauss2d
    from models import normdisk2d, normshell2d
    
    ui.clean()
    
    g = normgauss2d('g')
    g.xpos, g.ypos, g.ampl, g.fwhm = 100, 100, 42, 5
    
    d = normdisk2d('d')
    d.xpos, d.ypos, d.ampl, d.r0 = 100, 100, 42, 50
    
    s = normshell2d('s')
    s.xpos, s.ypos, s.ampl, s.r0, s.width = 100, 100, 42, 30, 20
    
    models = [g, d, s]
    
    ui.dataspace2d((200, 200))
    for model in models:
        ui.set_model(model)
        # In sherpa normed model values are flux per pixel area.
        # So to get the total flux (represented by the `ampl` parameter)
        # one can simply sum over all pixels, because a pixel has area 1 pix^2.
        # :-) 
        integral = ui.get_model_image().y.sum()
        print model.name, integral
Exemplo n.º 2
0
def check_integrals():
    """Check that Sherpa normed models integrate to 1."""
    from sherpa.astro import ui
    from sherpa.astro.ui import normgauss2d
    from models import normdisk2d, normshell2d

    ui.clean()

    g = normgauss2d('g')
    g.xpos, g.ypos, g.ampl, g.fwhm = 100, 100, 42, 5

    d = normdisk2d('d')
    d.xpos, d.ypos, d.ampl, d.r0 = 100, 100, 42, 50

    s = normshell2d('s')
    s.xpos, s.ypos, s.ampl, s.r0, s.width = 100, 100, 42, 30, 20

    models = [g, d, s]

    ui.dataspace2d((200, 200))
    for model in models:
        ui.set_model(model)
        # In sherpa normed model values are flux per pixel area.
        # So to get the total flux (represented by the `ampl` parameter)
        # one can simply sum over all pixels, because a pixel has area 1 pix^2.
        # :-)
        integral = ui.get_model_image().y.sum()
        print model.name, integral
Exemplo n.º 3
0
def print_values_sherpa():
    """Print some Sherpa model values that can be used for unit tests."""
    from sherpa.astro import ui
    from sherpa.astro.ui import normgauss2d
    from models import normdisk2d, normshell2d
    
    ui.clean()
    
    g = normgauss2d('g2')
    g.ampl, g.fwhm = INTEGRAL, GAUSS_FWHM
    
    d = normdisk2d('d')
    d.ampl, d.r0 = INTEGRAL, DISK_R0
    
    s = normshell2d('s')
    s.ampl, s.r0, s.width = INTEGRAL, SHELL_R0, SHELL_WIDTH

    models = [g, d, s]
    for model in models:
        for theta in THETAS:
            value = model(0, theta)
            print model.name, theta, value
Exemplo n.º 4
0
def print_values_sherpa():
    """Print some Sherpa model values that can be used for unit tests."""
    from sherpa.astro import ui
    from sherpa.astro.ui import normgauss2d
    from models import normdisk2d, normshell2d

    ui.clean()

    g = normgauss2d('g2')
    g.ampl, g.fwhm = INTEGRAL, GAUSS_FWHM

    d = normdisk2d('d')
    d.ampl, d.r0 = INTEGRAL, DISK_R0

    s = normshell2d('s')
    s.ampl, s.r0, s.width = INTEGRAL, SHELL_R0, SHELL_WIDTH

    models = [g, d, s]
    for model in models:
        for theta in THETAS:
            value = model(0, theta)
            print model.name, theta, value