import os import shutil import tempfile from soxs.spectra import Spectrum from soxs.spatial import PointSourceModel from soxs.simput import SimputCatalog, SimputPhotonList from soxs.instrument_registry import \ make_simple_instrument from soxs.instrument import instrument_simulator from soxs.events import write_spectrum from numpy.random import RandomState from soxs.tests.utils import spectrum_answer_testing, \ file_answer_testing make_simple_instrument("lynx_hdxi", "new_hdxi", 20.0, 1024) prng = RandomState(69) def test_power_law(answer_store, answer_dir): plaw_fit(1.1, answer_store, answer_dir) plaw_fit(0.8, answer_store, answer_dir) plaw_fit(1.0, answer_store, answer_dir) def plaw_fit(alpha_sim, answer_store, answer_dir): tmpdir = tempfile.mkdtemp() curdir = os.getcwd() os.chdir(tmpdir)
load_pha, ignore, fit, set_model, set_stat, set_method, \ get_fit_results from soxs.instrument import RedistributionMatrixFile, \ AuxiliaryResponseFile, instrument_simulator from soxs.events import write_spectrum from soxs.instrument_registry import get_instrument_from_registry, \ make_simple_instrument def setup(): from yt.config import ytcfg ytcfg["yt", "__withintesting"] = "True" try: make_simple_instrument("acisi_cy19", "sq_acisi_cy19", 20.0, 2400) except KeyError: pass acis_spec = get_instrument_from_registry("sq_acisi_cy19") rmf = RedistributionMatrixFile(acis_spec["rmf"]) arf = AuxiliaryResponseFile(acis_spec['arf']) def mymodel(pars, x, xhi=None): dx = x[1] - x[0] xmid = x + 0.5 * dx wm = WabsModel(pars[0]) wabs = wm.get_absorb(xmid) plaw = pars[1] * dx * (xmid * (1.0 + pars[2]))**(-pars[3])
load_pha, ignore, fit, set_model, set_stat, set_method, \ get_fit_results from soxs.instrument import RedistributionMatrixFile, \ AuxiliaryResponseFile, instrument_simulator from soxs.events import write_spectrum from soxs.instrument_registry import get_instrument_from_registry, \ make_simple_instrument def setup(): from yt.config import ytcfg ytcfg["yt", "__withintesting"] = "True" try: make_simple_instrument("chandra_acisi_cy20", "sq_acisi_cy20", 20.0, 2400) except KeyError: pass acis_spec = get_instrument_from_registry("sq_acisi_cy20") rmf = RedistributionMatrixFile(acis_spec["rmf"]) arf = AuxiliaryResponseFile(acis_spec['arf']) def mymodel(pars, x, xhi=None): dx = x[1] - x[0] xmid = x + 0.5 * dx wm = WabsModel(pars[0]) wabs = wm.get_absorb(xmid) plaw = pars[1] * dx * (xmid * (1.0 + pars[2]))**(-pars[3])
import shutil import numpy as np from sherpa.astro.ui import load_user_model, add_user_pars, \ load_pha, ignore, fit, set_model, set_stat, set_method, \ get_fit_results from soxs.spectra import Spectrum from soxs.events import write_spectrum from soxs.instrument_registry import get_instrument_from_registry, \ make_simple_instrument from soxs.instrument import RedistributionMatrixFile, \ AuxiliaryResponseFile, instrument_simulator prng = 49 try: make_simple_instrument("aciss_cy19", "sq_aciss_cy19", 20.0, 2400) except KeyError: pass acis_spec = get_instrument_from_registry("sq_aciss_cy19") rmf = RedistributionMatrixFile(acis_spec["rmf"]) arf = AuxiliaryResponseFile(acis_spec['arf']) def setup(): from yt.config import ytcfg ytcfg["yt", "__withintesting"] = "True" def mymodel(pars, x, xhi=None): tm = TBabsModel(pars[0])
import os import shutil import tempfile from soxs.spectra import Spectrum, get_tbabs_absorb from soxs.spatial import PointSourceModel from soxs.simput import SimputCatalog from soxs.instrument_registry import \ make_simple_instrument from soxs.instrument import instrument_simulator from soxs.events import write_spectrum from numpy.random import RandomState from soxs.tests.utils import spectrum_answer_testing, \ file_answer_testing make_simple_instrument("lynx_hdxi", "new_hdxi", 20.0, 1024) prng = RandomState(69) def test_power_law(answer_store, answer_dir): plaw_fit(1.1, answer_store, answer_dir) plaw_fit(0.8, answer_store, answer_dir) plaw_fit(1.0, answer_store, answer_dir) def plaw_fit(alpha_sim, answer_store, answer_dir): tmpdir = tempfile.mkdtemp() curdir = os.getcwd() os.chdir(tmpdir)