Пример #1
0
def test_pha_case_6(ds_setup, ds_datadir):

    datadir = ds_datadir
    ls = '@' + '/'.join((datadir, 'pha.lis'))
    rmf1 = '/'.join((datadir, "acisf04938_000N002_r0043_rmf3.fits"))
    rmf2 = '/'.join((datadir, "acisf07867_000N001_r0002_rmf3.fits"))
    arf1 = '/'.join((datadir, "acisf04938_000N002_r0043_arf3.fits"))
    arf2 = '/'.join((datadir, "acisf07867_000N001_r0002_arf3.fits"))
    datastack.load_pha(ls)

    datastack.load_bkg_rmf([], rmf1)
    datastack.load_bkg_rmf([], rmf2)

    datastack.load_bkg_arf([], arf1)
    datastack.load_bkg_arf([], arf2)

    # Define background models
    bkg_arfs = datastack.get_bkg_arf([])
    bkg_scales = datastack.get_bkg_scale([])
    bkg_models = [
        ui.const1d.c1 * acis_bkg_model('acis7s'),
        ui.const1d.c2 * acis_bkg_model('acis7s')
    ]
    bkg_rsps = datastack.get_response([], bkg_id=1)
    for i in range(2):
        id_ = i + 1
        # Make the ARF spectral response flat.  This is required for using
        # the acis_bkg_model.
        bkg_arfs[i].specresp = bkg_arfs[i].specresp * 0 + 1.
        datastack.set_bkg_full_model(id_, bkg_rsps[i](bkg_models[i]))

    # Fit background
    datastack.notice(0.5, 8.)
    datastack.set_method("neldermead")
    datastack.set_stat("cash")

    datastack.thaw(c1.c0)
    datastack.thaw(c2.c0)
    datastack.fit_bkg()
    datastack.freeze(c1.c0)
    datastack.freeze(c2.c0)

    # Define source models
    rsps = datastack.get_response([])
    src_model = ui.powlaw1d.pow1
    src_models = [src_model, src_model * ui.const1d.ratio_12]
    for i in range(2):
        id_ = i + 1
        datastack.set_full_model(id_,
                                 (rsps[i](src_models[i]) +
                                  bkg_scales[i] * bkg_rsps[i](bkg_models[i])))

    datastack.fit()
Пример #2
0
    def test_case_6(self):
        datadir = '/'.join((self._this_dir, 'data'))
        ls = '@'+'/'.join((datadir, 'pha.lis'))
        rmf1 = '/'.join((datadir, "acisf04938_000N002_r0043_rmf3.fits"))
        rmf2 = '/'.join((datadir, "acisf07867_000N001_r0002_rmf3.fits"))
        arf1 = '/'.join((datadir, "acisf04938_000N002_r0043_arf3.fits"))
        arf2 = '/'.join((datadir, "acisf07867_000N001_r0002_arf3.fits"))
        datastack.load_pha(ls)

        datastack.load_bkg_rmf([], rmf1)
        datastack.load_bkg_rmf([], rmf2)

        datastack.load_bkg_arf([], arf1)
        datastack.load_bkg_arf([], arf2)

        # Define background models
        bkg_arfs = datastack.get_bkg_arf([])
        bkg_scales = datastack.get_bkg_scale([])
        bkg_models = [ui.const1d.c1 * acis_bkg_model('acis7s'),
                      ui.const1d.c2 * acis_bkg_model('acis7s')]
        bkg_rsps = datastack.get_response([], bkg_id=1)
        for i in range(2):
            id_ = i + 1
            # Make the ARF spectral response flat.  This is required for using
            # the acis_bkg_model.
            bkg_arfs[i].specresp = bkg_arfs[i].specresp * 0 + 1.
            datastack.set_bkg_full_model(id_, bkg_rsps[i](bkg_models[i]))

        # Fit background
        datastack.notice(0.5, 8.)
        datastack.set_method("neldermead")
        datastack.set_stat("cash")

        datastack.thaw(c1.c0)
        datastack.thaw(c2.c0)
        datastack.fit_bkg()
        datastack.freeze(c1.c0)
        datastack.freeze(c2.c0)

        # Define source models
        rsps = datastack.get_response([])
        src_model = ui.powlaw1d.pow1
        src_models = [src_model,
                      src_model * ui.const1d.ratio_12]
        for i in range(2):
            id_ = i + 1
            datastack.set_full_model(id_, (rsps[i](src_models[i]) +
                                           bkg_scales[i] *
                                           bkg_rsps[i](bkg_models[i])))

        datastack.fit()