Skip to the navigation links
Last modified: 10 December 2024

URL: https://cxc.cfa.harvard.edu/sherpa/bugs/delta2d.html

Bugs: delta2d


Bugs

The delta2d model parameters remain unchanged in a fit to 2D non-integrated data

If the delta2d model is used to fit a non-integrated data set, with an optimization method other than Nelder-Mead, the xpos and ypos model parameters will not vary in the fit. Users can work around this issue by fitting the model to 2D integrated data sets, e.g.:

sherpa> load_data("img.ccd7.0.3-7_box_0.2bin.fits", dstype=DataIMGInt)

# instead of

sherpa> load_data("img.ccd7.0.3-7_box_0.2bin.fits")

The dataspace2d, load_data, unpack_data, unpack_image, and load_image commands accept this 'dstype' specification to determine the data set type.

Workaround:

A 2D integrated data set can be specified using dataspace2d with either:

sherpa> dataspace2d([100, 100], dstype=DataIMGInt)

or

sherpa> dataspace2d([100, 100], dstype=Data2DInt)

A work-around to force the delta2d model to be integrated from a non-integrated grid is provided in the example Python script below.

from sherpa.astro.ui import *

from sherpa.models import Delta2D

class MyDelta2D(Delta2D):
    """
    Force the calculation of Delta2D to be integrated from
    a non-integrated grid
    """
    def calc(self, p, x0, x1, *args, **kwargs):
        # NOTE: image coordinates only!
        return Delta2D.calc(self, p, x0-0.5, x1-0.5, x0+0.5, x1+0.5,
                            *args, **kwargs)


dataspace2d([100, 100])

set_source(const2d.c2)
fake()

set_method("neldermead")
set_stat("cash")

load_psf("psf2d", gauss2d.g2)
set_psf(psf2d)
g2.xpos = 30
g2.ypos = 70
freeze(g2)

add_model(MyDelta2D)

set_source(mydelta2d.sig + const2d.bkg)
sig.xpos = 50
sig.ypos = 50
sig.ampl = 1000
fake()
freeze(bkg)
fit()

# Here the g2 model is also being fit, while it is a definition of the
# psf model and it should be kept frozen.

fit()

sig.xpos = 49
sig.ypos = 51

fit()