Exemplo n.º 1
0
    def setUp(self):
        self._old_logger_level = logger.getEffectiveLevel()
        logger.setLevel(logging.ERROR)
        from sherpa.astro.io import read_pha
        from sherpa.astro import xspec

        # Ensure we have a known set of XSPEC settings.
        # At present this is just the abundance and cross-section,
        # since the cosmology settings do not affect any of the
        # models used here.
        #
        self._xspec_settings = {
            'abund': xspec.get_xsabund(),
            'xsect': xspec.get_xsxsect()
        }

        xspec.set_xsabund('angr')
        xspec.set_xsxsect('bcmc')

        pha_fname = self.make_path("9774.pi")
        self.data = read_pha(pha_fname)
        self.data.notice(0.5, 7.0)

        bkg_fname = self.make_path("9774_bg.pi")
        self.bkg = read_pha(bkg_fname)

        abs1 = xspec.XSphabs('abs1')
        p1 = PowLaw1D('p1')
        self.model = abs1 + p1

        self.model_mult = abs1 * p1
        pi2278 = self.make_path("pi2278.fits")
        pi2286 = self.make_path("pi2286.fits")
        self.data_pi2278 = read_pha(pi2278)
        self.data_pi2286 = read_pha(pi2286)
Exemplo n.º 2
0
def test_xsect_default():
    """Check the expected default setting for the xsect setting.

    Ideally this test would be run before any other
    tests of XSPEC are made (i.e. any XSPEC code is called).
    """

    from sherpa.astro import xspec

    oval = xspec.get_xsxsect()
    assert oval in DEFAULT_XSECT
Exemplo n.º 3
0
def test_xsect_default():
    """Check the expected default setting for the xsect setting.

    Ideally this test would be run before any other
    tests of XSPEC are made (i.e. any XSPEC code is called).
    """

    from sherpa.astro import xspec

    oval = xspec.get_xsxsect()
    assert oval in DEFAULT_XSECT
Exemplo n.º 4
0
    def tearDown(self):
        from sherpa.astro import xspec

        self._xspec_settings = {
            'abund': xspec.get_xsabund(),
            'xsect': xspec.get_xsxsect()
        }

        xspec.set_xsabund(self._xspec_settings['abund'])
        xspec.set_xsxsect(self._xspec_settings['xsect'])

        if hasattr(self, "_old_logger_level"):
            logger.setLevel(self._old_logger_level)
Exemplo n.º 5
0
def reset_xspec():

    from sherpa.astro import xspec

    # Ensure we have a known set of XSPEC settings.
    # At present this is just the abundance and cross-section,
    # since the cosmology settings do not affect any of the
    # models used here.
    #
    abund = xspec.get_xsabund()
    xsect = xspec.get_xsxsect()

    xspec.set_xsabund('angr')
    xspec.set_xsxsect('bcmc')

    yield

    xspec.set_xsabund(abund)
    xspec.set_xsxsect(xsect)
Exemplo n.º 6
0
def fix_xspec(clean_astro_ui, hide_logging):
    """As of XSPEC 12.11.1 it's useful to fix abundance/cross sections
    rather than rely on reading from the user's directory

    This requires XSPEC support.
    """

    # As of XSPEC 12.10.1, it is safest to explicitly set
    # the state to a known value. For now just pick the
    # "easy" settings.
    #
    abund = xspec.get_xsabund()
    xsect = xspec.get_xsxsect()

    xspec.set_xsabund('angr')
    xspec.set_xsxsect('bcmc')

    yield

    xspec.set_xsabund(abund)
    xspec.set_xsxsect(xsect)