示例#1
0
def test_beta_model(answer_store, answer_dir):
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    prng = 32

    r_c = 20.0
    beta = 1.0

    exp_time = Quantity(500.0, "ks")

    beta_src_pos = BetaModel(ra0, dec0, r_c, beta)
    beta_src = SimputPhotonList.from_models("beta", spec, beta_src_pos,
                                            exp_time, area, prng=prng)
    sim_cat = SimputCatalog.from_source("beta_simput.fits", beta_src,
                                        overwrite=True)

    instrument_simulator("beta_simput.fits", "beta_evt.fits", exp_time,
                         "chandra_acisi_cy0", [ra0, dec0], ptsrc_bkgnd=False,
                         instr_bkgnd=False, foreground=False, prng=prng)

    write_radial_profile("beta_evt.fits", "beta_evt_profile.fits", [ra0, dec0],
                         0.0, 100.0, 200, ctr_type="celestial", emin=0.5,
                         emax=7.0, overwrite=True)

    file_answer_testing("EVENTS", "beta_evt.fits", answer_store, 
                        answer_dir)
    file_answer_testing("PROFILE", "beta_evt_profile.fits", answer_store,
                        answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#2
0
def test_annulus(answer_store, answer_dir):

    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_in = 10.0
    r_out = 30.0

    ann_pos = AnnulusModel(ra0, dec0, r_in, r_out)

    ann_src = SimputPhotonList.from_models("ann", spec, ann_pos,
                                           exp_time, area, prng=prng)
    sim_cat = SimputCatalog.from_source("ann_simput.fits", ann_src,
                                        overwrite=True)

    instrument_simulator("ann_simput.fits", "ann_evt.fits", exp_time,
                         "lynx_hdxi", [ra0, dec0], ptsrc_bkgnd=False,
                         instr_bkgnd=False, foreground=False, prng=prng)

    write_radial_profile("ann_evt.fits", "ann_evt_profile.fits", [ra0, dec0],
                         1.1*r_in, 0.9*r_out, 100, ctr_type="celestial",
                         emin=0.5, emax=7.0, overwrite=True)

    file_answer_testing("EVENTS", "ann_evt.fits", answer_store, answer_dir)
    file_answer_testing("PROFILE", "ann_evt_profile.fits", answer_store, 
                        answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#3
0
def test_annulus(answer_store, answer_dir):

    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_in = 10.0
    r_out = 30.0

    ann_pos = AnnulusModel(ra0, dec0, r_in, r_out)

    sim_cat = SimputCatalog.from_models("ann", "ann", spec, ann_pos,
                                        exp_time, area, prng=prng)
    sim_cat.write_catalog(overwrite=True)

    instrument_simulator("ann_simput.fits", "ann_evt.fits", exp_time,
                         "hdxi", [ra0, dec0], ptsrc_bkgnd=False, 
                         instr_bkgnd=False, foreground=False, prng=prng)

    write_radial_profile("ann_evt.fits", "ann_evt_profile.fits", [ra0, dec0],
                         1.1*r_in, 0.9*r_out, 100, ctr_type="celestial",
                         emin=0.5, emax=7.0, overwrite=True)

    file_answer_testing("EVENTS", "ann_evt.fits", answer_store, answer_dir)
    file_answer_testing("PROFILE", "ann_evt_profile.fits", answer_store, answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#4
0
def test_beta_model_flux(answer_store, answer_dir):
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_c = 20.0
    beta = 1.0

    prng = 34

    beta_src_pos = BetaModel(ra0, dec0, r_c, beta)
    sim_cat = SimputCatalog.from_models("beta", "beta", spec, beta_src_pos,
                                        exp_time, area, prng=prng)
    sim_cat.write_catalog(overwrite=True)

    instrument_simulator("beta_simput.fits", "beta_flux_evt.fits", exp_time,
                         "acisi_cy0", [ra0, dec0], ptsrc_bkgnd=False,
                         instr_bkgnd=False, foreground=False, 
                         roll_angle=37.0, prng=prng)

    wspec = spec.new_spec_from_band(0.5, 7.0)

    make_exposure_map("beta_flux_evt.fits", "beta_expmap.fits", wspec.emid.value,
                      weights=wspec.flux.value, overwrite=True)

    write_radial_profile("beta_flux_evt.fits", "beta_flux_evt_profile.fits",
                         [ra0, dec0], 0.0, 100.0, 200, ctr_type="celestial",
                         emin=0.5, emax=7.0, expmap_file="beta_expmap.fits",
                         overwrite=True)

    file_answer_testing("EVENTS", "beta_flux_evt.fits", answer_store, answer_dir)
    file_answer_testing("PROFILE", "beta_flux_evt_profile.fits", answer_store, answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#5
0
def test_beta_model(answer_store, answer_dir):
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    prng = 32

    r_c = 20.0
    beta = 1.0

    exp_time = Quantity(500.0, "ks")

    beta_src_pos = BetaModel(ra0, dec0, r_c, beta)
    sim_cat = SimputCatalog.from_models("beta", "beta", spec, beta_src_pos,
                                        exp_time, area, prng=prng)
    sim_cat.write_catalog(overwrite=True)

    instrument_simulator("beta_simput.fits", "beta_evt.fits", exp_time,
                         "acisi_cy0", [ra0, dec0], ptsrc_bkgnd=False,
                         instr_bkgnd=False, foreground=False, prng=prng)

    write_radial_profile("beta_evt.fits", "beta_evt_profile.fits", [ra0, dec0],
                         0.0, 100.0, 200, ctr_type="celestial", emin=0.5,
                         emax=7.0, overwrite=True)

    file_answer_testing("EVENTS", "beta_evt.fits", answer_store, answer_dir)
    file_answer_testing("PROFILE", "beta_evt_profile.fits", answer_store, answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#6
0
def test_beta_model_flux(answer_store, answer_dir):
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_c = 20.0
    beta = 1.0

    prng = 34

    beta_src_pos = BetaModel(ra0, dec0, r_c, beta)
    sim_cat = SimputCatalog.from_models("beta",
                                        "beta",
                                        spec,
                                        beta_src_pos,
                                        exp_time,
                                        area,
                                        prng=prng)
    sim_cat.write_catalog(overwrite=True)

    instrument_simulator("beta_simput.fits",
                         "beta_flux_evt.fits",
                         exp_time,
                         "acisi_cy0", [ra0, dec0],
                         ptsrc_bkgnd=False,
                         instr_bkgnd=False,
                         foreground=False,
                         roll_angle=37.0,
                         prng=prng)

    wspec = spec.new_spec_from_band(0.5, 7.0)

    make_exposure_map("beta_flux_evt.fits",
                      "beta_expmap.fits",
                      wspec.emid.value,
                      weights=wspec.flux.value,
                      overwrite=True)

    write_radial_profile("beta_flux_evt.fits",
                         "beta_flux_evt_profile.fits", [ra0, dec0],
                         0.0,
                         100.0,
                         200,
                         ctr_type="celestial",
                         emin=0.5,
                         emax=7.0,
                         expmap_file="beta_expmap.fits",
                         overwrite=True)

    file_answer_testing("EVENTS", "beta_flux_evt.fits", answer_store,
                        answer_dir)
    file_answer_testing("PROFILE", "beta_flux_evt_profile.fits", answer_store,
                        answer_dir)

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#7
0
def test_annulus():

    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_in = 10.0
    r_out = 30.0

    e = spec.generate_energies(exp_time, area, prng=prng)

    ann_src = AnnulusModel(ra0, dec0, r_in, r_out, e.size, prng=prng)

    write_photon_list("ann",
                      "ann",
                      e.flux,
                      ann_src.ra,
                      ann_src.dec,
                      e,
                      overwrite=True)

    instrument_simulator("ann_simput.fits",
                         "ann_evt.fits",
                         exp_time,
                         "hdxi", [ra0, dec0],
                         ptsrc_bkgnd=False,
                         instr_bkgnd=False,
                         foreground=False,
                         prng=prng)

    inst = get_instrument_from_registry("hdxi")
    arf = AuxiliaryResponseFile(inst["arf"])
    cspec = ConvolvedSpectrum(spec, arf)
    ph_flux = cspec.get_flux_in_band(0.5, 7.0)[0].value
    S0 = ph_flux / (np.pi * (r_out**2 - r_in**2))

    write_radial_profile("ann_evt.fits",
                         "ann_evt_profile.fits", [ra0, dec0],
                         1.1 * r_in,
                         0.9 * r_out,
                         100,
                         ctr_type="celestial",
                         emin=0.5,
                         emax=7.0,
                         overwrite=True)

    load_data(1, "ann_evt_profile.fits", 3, ["RMID", "SUR_BRI", "SUR_BRI_ERR"])
    set_stat("chi2")
    set_method("levmar")
    set_source("const1d.src")
    src.c0 = 0.8 * S0

    fit()
    set_covar_opt("sigma", 1.645)
    covar()
    res = get_covar_results()

    assert np.abs(res.parvals[0] - S0) < res.parmaxes[0]

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#8
0
def test_beta_model_flux():
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_c = 20.0
    beta = 1.0

    prng = 34

    e = spec.generate_energies(exp_time, area, prng=prng)

    beta_src = BetaModel(ra0, dec0, r_c, beta, e.size, prng=prng)

    write_photon_list("beta",
                      "beta",
                      e.flux,
                      beta_src.ra,
                      beta_src.dec,
                      e,
                      overwrite=True)

    instrument_simulator("beta_simput.fits",
                         "beta_evt.fits",
                         exp_time,
                         "acisi_cy0", [ra0, dec0],
                         ptsrc_bkgnd=False,
                         instr_bkgnd=False,
                         foreground=False,
                         roll_angle=37.0,
                         prng=prng)

    ph_flux = spec.get_flux_in_band(0.5, 7.0)[0].value
    S0 = 3.0 * ph_flux / (2.0 * np.pi * r_c * r_c)

    wspec = spec.new_spec_from_band(0.5, 7.0)

    make_exposure_map("beta_evt.fits",
                      "beta_expmap.fits",
                      wspec.emid.value,
                      weights=wspec.flux.value,
                      overwrite=True)

    write_radial_profile("beta_evt.fits",
                         "beta_evt_profile.fits", [ra0, dec0],
                         0.0,
                         100.0,
                         200,
                         ctr_type="celestial",
                         emin=0.5,
                         emax=7.0,
                         expmap_file="beta_expmap.fits",
                         overwrite=True)

    load_data(1, "beta_evt_profile.fits", 3,
              ["RMID", "SUR_FLUX", "SUR_FLUX_ERR"])
    set_stat("chi2")
    set_method("levmar")
    set_source("beta1d.src")
    src.beta = 1.0
    src.r0 = 10.0
    src.ampl = 0.8 * S0
    freeze(src.xpos)

    fit()
    set_covar_opt("sigma", 1.645)
    covar()
    res = get_covar_results()

    assert np.abs(res.parvals[0] - r_c) < res.parmaxes[0]
    assert np.abs(res.parvals[1] - beta) < res.parmaxes[1]
    assert np.abs(res.parvals[2] - S0) < res.parmaxes[2]

    os.chdir(curdir)
    shutil.rmtree(tmpdir)
示例#9
0
def test_beta_model():
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    r_c = 20.0
    beta = 1.0

    exp_time = Quantity(500.0, "ks")

    e = spec.generate_energies(exp_time, area, prng=prng)

    beta_src = BetaModel(ra0, dec0, r_c, beta, e.size, prng=prng)

    write_photon_list("beta",
                      "beta",
                      e.flux,
                      beta_src.ra,
                      beta_src.dec,
                      e,
                      overwrite=True)

    instrument_simulator("beta_simput.fits",
                         "beta_evt.fits",
                         exp_time,
                         "hdxi", [ra0, dec0],
                         ptsrc_bkgnd=False,
                         instr_bkgnd=False,
                         foreground=False,
                         prng=prng)

    inst = get_instrument_from_registry("hdxi")
    arf = AuxiliaryResponseFile(inst["arf"])
    cspec = ConvolvedSpectrum(spec, arf)
    ph_flux = cspec.get_flux_in_band(0.5, 7.0)[0].value
    S0 = 3.0 * ph_flux / (2.0 * np.pi * r_c * r_c)

    write_radial_profile("beta_evt.fits",
                         "beta_evt_profile.fits", [ra0, dec0],
                         0.0,
                         100.0,
                         200,
                         ctr_type="celestial",
                         emin=0.5,
                         emax=7.0,
                         overwrite=True)

    load_data(1, "beta_evt_profile.fits", 3,
              ["RMID", "SUR_BRI", "SUR_BRI_ERR"])
    set_stat("chi2")
    set_method("levmar")
    set_source("beta1d.src")
    src.beta = 1.0
    src.r0 = 10.0
    src.ampl = 0.8 * S0
    freeze(src.xpos)

    fit()
    set_covar_opt("sigma", 1.645)
    covar()
    res = get_covar_results()

    assert np.abs(res.parvals[0] - r_c) < res.parmaxes[0]
    assert np.abs(res.parvals[1] - beta) < res.parmaxes[1]
    assert np.abs(res.parvals[2] - S0) < res.parmaxes[2]

    os.chdir(curdir)
    shutil.rmtree(tmpdir)