本文整理汇总了Python中sherpa.astro.ui.get_fit_results函数的典型用法代码示例。如果您正苦于以下问题:Python get_fit_results函数的具体用法?Python get_fit_results怎么用?Python get_fit_results使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_fit_results函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_radpro_psf
def test_radpro_psf(self):
self.run_thread('radpro_psf')
self.assertEqualWithinTol(ui.get_fit_results().statval, 200.949, 1e-4)
self.assertEqualWithinTol(self.locals['src'].r0.val, 83.0997, 1e-4)
self.assertEqualWithinTol(self.locals['src'].beta.val, 2.97737, 1e-4)
self.assertEqualWithinTol(self.locals['src'].ampl.val, 5.27604, 1e-4)
self.assertEqual(ui.get_fit_results().nfev,48)
self.assertEqual(ui.get_fit_results().numpoints,38)
self.assertEqual(ui.get_fit_results().dof,35)
开发者ID:valkenar,项目名称:sherpa,代码行数:9,代码来源:test_astro.py
示例2: test_kernel
def test_kernel(self):
self.run_thread('kernel')
self.assertEqualWithinTol(ui.get_fit_results().statval, 98.5793, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].r0.val, 19.2278, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].beta.val, 0.555464, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].ampl.val, 1.93706, 1e-4)
self.assertEqual(ui.get_fit_results().nfev,21)
self.assertEqual(ui.get_fit_results().numpoints,75)
self.assertEqual(ui.get_fit_results().dof,72)
开发者ID:valkenar,项目名称:sherpa,代码行数:9,代码来源:test_astro.py
示例3: test_linepro
def test_linepro(self):
self.run_thread('linepro')
self.assertEqualWithinTol(ui.get_fit_results().statval, 203.34, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].r0.val, 4.25557, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].beta.val, 0.492232, 1e-4)
self.assertEqualWithinTol(self.locals['b1'].ampl.val, 11.8129, 1e-4)
self.assertEqual(ui.get_fit_results().nfev,17)
self.assertEqual(ui.get_fit_results().numpoints,75)
self.assertEqual(ui.get_fit_results().dof,72)
开发者ID:valkenar,项目名称:sherpa,代码行数:9,代码来源:test_astro.py
示例4: test_histo
def test_histo(self):
self.run_thread('histo')
self.assertEqualWithinTol(ui.get_fit_results().statval, 14.7264, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].fwhm.val, 0.0232473, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].pos.val, 1.26713, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].ampl.val, 40.4503, 1e-4)
#self.assertEqual(ui.get_fit_results().nfev,19)
self.assertEqual(ui.get_fit_results().numpoints,50)
self.assertEqual(ui.get_fit_results().dof,47)
开发者ID:valkenar,项目名称:sherpa,代码行数:9,代码来源:test_astro.py
示例5: test_xmm
def test_xmm(self):
self.run_thread('xmm')
self.assertEqualWithinTol(ui.get_fit_results().statval, 118.085, 1e-4)
self.assertEqualWithinTol(self.locals['intrin'].nh.val, 11.0769, 1e-2)
self.assertEqualWithinTol(self.locals['phard'].phoindex.val, 1.49055, 1e-2)
self.assertEqualWithinTol(self.locals['phard'].norm.val, 0.00140301, 1e-2)
self.assertEqual(ui.get_fit_results().nfev,95)
self.assertEqual(ui.get_fit_results().numpoints,162)
self.assertEqual(ui.get_fit_results().dof,159)
开发者ID:valkenar,项目名称:sherpa,代码行数:9,代码来源:test_astro.py
示例6: test_spectrum
def test_spectrum(self):
self.run_thread('spectrum')
self.assertEqualWithinTol(ui.get_fit_results().statval, 0.0496819, 1e-4)
self.assertEqualWithinTol(self.locals['abs2'].nh.val, 1.1015, 1e-4)
self.assertEqualWithinTol(self.locals['mek1'].kt.val, 0.841025, 1e-4)
self.assertEqualWithinTol(self.locals['mek1'].norm.val, 0.699761, 1e-4)
self.assertEqualWithinTol(self.locals['mek2'].kt.val, 2.35845, 1e-4)
self.assertEqualWithinTol(self.locals['mek2'].norm.val, 1.03724, 1e-4)
self.assertEqual(ui.get_fit_results().numpoints,446)
self.assertEqual(ui.get_fit_results().dof,441)
开发者ID:valkenar,项目名称:sherpa,代码行数:10,代码来源:test_astro.py
示例7: test_psf2d
def test_psf2d(self):
self.run_thread('psf')
self.assertEqualWithinTol(ui.get_fit_results().statval, 4066.78, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].fwhm.val, 2.80117, 1e-2)
self.assertEqualWithinTol(self.locals['g1'].ypos.val, 77.2271, 1e-2)
self.assertEqualWithinTol(self.locals['g1'].xpos.val, 88.661, 1e-2)
self.assertEqualWithinTol(self.locals['g1'].ampl.val, 166.649, 1e-2)
#self.assertEqual(ui.get_fit_results().nfev,342)
self.assertEqual(ui.get_fit_results().numpoints,4899)
self.assertEqual(ui.get_fit_results().dof,4895)
开发者ID:valkenar,项目名称:sherpa,代码行数:10,代码来源:test_astro.py
示例8: test_simultaneous
def test_simultaneous(self):
self.run_thread('simultaneous')
self.assertEqualWithinTol(ui.get_fit_results().statval, 7.4429, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().rstat, 0.531636, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().qval, 0.916288, 1e-4)
self.assertEqualWithinTol(self.locals['abs1'].nh.val, 0.898162, 1e-2)
self.assertEqualWithinTol(self.locals['pl1'].gamma.val, 1.645, 1e-4)
self.assertEqualWithinTol(self.locals['pl1'].ampl.val, 2.28323e-05, 1e-3)
self.assertEqualWithinTol(self.locals['pl2'].ampl.val, 2.44585e-05, 1e-3)
self.assertEqual(ui.get_fit_results().numpoints,18)
self.assertEqual(ui.get_fit_results().dof,14)
开发者ID:valkenar,项目名称:sherpa,代码行数:11,代码来源:test_astro.py
示例9: test_lev3fft
def test_lev3fft(self):
self.run_thread('lev3fft', scriptname='bar.py')
self.assertEqualWithinTol(self.locals['src'].fwhm.val, 0.04418584, 1e-4)
self.assertEqualWithinTol(self.locals['src'].xpos.val, 150.016, 1e-4)
self.assertEqualWithinTol(self.locals['src'].ypos.val, 2.66493839, 1e-4)
self.assertEqualWithinTol(self.locals['src'].ampl.val, 1.56090546, 1e-4)
self.assertEqualWithinTol(self.locals['bkg'].c0.val, -1.513700715, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().istatval, 19496.3, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().statval, 592.32647, 1e-4)
self.assertEqual(ui.get_fit_results().numpoints, 3307)
self.assertEqual(ui.get_fit_results().dof, 3302)
开发者ID:valkenar,项目名称:sherpa,代码行数:11,代码来源:test_astro.py
示例10: test_pileup
def test_pileup(self):
self.run_thread('pileup')
self.assertEqualWithinTol(ui.get_fit_results().statval, 53.6112, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().rstat, 1.44895, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().qval, 0.0379417, 1e-4)
self.assertEqualWithinTol(self.locals['jdp'].alpha.val, 0.522593, 1e-1)
self.assertEqualWithinTol(self.locals['jdp'].f.val, 0.913458, 1e-2)
self.assertEqualWithinTol(self.locals['abs1'].nh.val, 6.12101, 1e-2)
self.assertEqualWithinTol(self.locals['power'].gamma.val, 1.41887, 1e-2)
self.assertEqualWithinTol(self.locals['power'].ampl.val, 0.00199457, 1e-2)
self.assertEqual(ui.get_fit_results().numpoints,42)
self.assertEqual(ui.get_fit_results().dof,37)
开发者ID:valkenar,项目名称:sherpa,代码行数:12,代码来源:test_astro.py
示例11: test_sourceandbg
def test_sourceandbg(self):
self.run_thread('sourceandbg')
self.assertEqualWithinTol(ui.get_fit_results().statval, 947.5, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().rstat, 0.715094, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().qval, 1, 1e-4)
self.assertEqualWithinTol(self.locals['a1'].nh.val, 0.0342266, 1e-2)
self.assertEqualWithinTol(self.locals['b1'].kt.val, 20, 1e-2)
self.assertEqualWithinTol(self.locals['b1'].norm.val, 0.00953809, 1e-2)
self.assertEqualWithinTol(self.locals['b2'].kt.val, 0.563109, 1e-2)
self.assertEqualWithinTol(self.locals['b2'].norm.val, 1.16118e-05, 1e-2)
self.assertEqual(ui.get_fit_results().numpoints,1330)
self.assertEqual(ui.get_fit_results().dof,1325)
开发者ID:valkenar,项目名称:sherpa,代码行数:12,代码来源:test_astro.py
示例12: test_spatial
def test_spatial(self):
self.run_thread('spatial')
self.assertEqualWithinTol(ui.get_fit_results().statval, -59229.749441, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].fwhm.val, 61.5615, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].xpos.val, 4070.45, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].ypos.val, 4251.35, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].ampl.val, 22.1269, 1e-4)
self.assertEqualWithinTol(self.locals['g2'].fwhm.val, 6.20409, 1e-4)
self.assertEqualWithinTol(self.locals['g2'].xpos.val, 4070.78, 1e-4)
self.assertEqualWithinTol(self.locals['g2'].ypos.val, 4249.33, 1e-4)
self.assertEqualWithinTol(self.locals['g2'].ampl.val, 226.563, 1e-4)
#self.assertEqual(ui.get_fit_results().nfev,371)
self.assertEqual(ui.get_fit_results().numpoints,4881)
self.assertEqual(ui.get_fit_results().dof,4877)
开发者ID:valkenar,项目名称:sherpa,代码行数:14,代码来源:test_astro.py
示例13: test_fpsf2d
def test_fpsf2d(self):
self.run_thread('fpsf')
self.assertEqualWithinTol(ui.get_fit_results().statval, -4053.6635, 1e-4)
# self.assertEqualWithinTol(self.locals['b1'].xlow.val, -4.70832, 1e-4)
# self.assertEqualWithinTol(self.locals['b1'].xhi.val, 164.687, 1e-4)
# self.assertEqualWithinTol(self.locals['b1'].ylow.val, 0.83626, 1e-4)
# self.assertEqualWithinTol(self.locals['b1'].yhi.val, 142.603, 1e-4)
# self.assertEqualWithinTol(self.locals['b1'].ampl.val, 0.956766, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].fwhm.val, 6.420237, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].xpos.val, 88.940712, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].ypos.val, 76.577265, 1e-4)
self.assertEqualWithinTol(self.locals['g1'].ampl.val, 36344.48324, 1e-4)
#self.assertEqual(ui.get_fit_results().nfev,978)
self.assertEqual(ui.get_fit_results().numpoints,4899)
self.assertEqual(ui.get_fit_results().dof,4895)
开发者ID:valkenar,项目名称:sherpa,代码行数:15,代码来源:test_astro.py
示例14: test_eqwith_err1
def test_eqwith_err1(make_data_path, restore_xspec_settings):
def check1(e0, e1, e2):
assert e0 == approx(0.028335201547206704, rel=1.0e-3)
assert e1 == approx(-0.00744118799274448756, rel=1.0e-3)
assert e2 == approx(0.0706249544851336, rel=1.0e-3)
ui.set_xsabund('angr')
ui.set_xsxsect('bcmc')
ui.load_pha(make_data_path('3c273.pi'))
ui.notice(0.5, 7.0)
ui.set_stat("chi2datavar")
ui.set_method("simplex")
ui.set_model('powlaw1d.p1+gauss1d.g1')
g1.fwhm = 0.1
g1.pos = 2.0
ui.freeze(g1.pos, g1.fwhm)
ui.fit()
numpy.random.seed(2345)
e = ui.eqwidth(p1, p1 + g1, error=True, niter=100)
check1(e[0], e[1], e[2])
params = e[3]
numpy.random.seed(2345)
e = ui.eqwidth(p1, p1 + g1, error=True, params=params, niter=100)
check1(e[0], e[1], e[2])
parvals = ui.get_fit_results().parvals
assert parvals[0] == approx(1.9055272902160334, rel=1.0e-3)
assert parvals[1] == approx(0.00017387966749772638, rel=1.0e-3)
assert parvals[2] == approx(1.279415076070516e-05, rel=1.0e-3)
开发者ID:DougBurke,项目名称:sherpa,代码行数:33,代码来源:test_eqwidth_err.py
示例15: test_user_stat_unit
def test_user_stat_unit():
given_stat_error = [1.1, 2.2, 3.3]
given_sys_error = [10.1, 10.2, 10.3]
def calc_stat(data, _model, staterror, syserror=None, weight=None):
# Make sure values are being injected correctly
np.testing.assert_array_equal(given_stat_error, staterror)
np.testing.assert_array_equal(given_sys_error, syserror)
return 3.235, np.ones_like(data)
xdata = [1, 2, 3]
ydata = xdata
ui.load_arrays(1, xdata, ydata, None, given_sys_error, Data1D)
ui.set_model(1, 'polynom1d.p')
ui.load_user_stat('customstat', calc_stat, lambda x: given_stat_error)
ui.set_stat(eval('customstat'))
try:
ui.fit(1)
except StatErr:
pytest.fail("Call should not be throwing any exception (bug #341)")
# Test the result is what we made the user stat return
assert 3.235 == ui.get_fit_results().statval
开发者ID:DougBurke,项目名称:sherpa,代码行数:27,代码来源:test_user_stat.py
示例16: fit
def fit(self, conf = False):
ui.ignore(None, None)
ui.notice(self.start, self.stop)
self.set_source()
ui.fit(1)
if conf:
ui.conf()
res = ui.get_fit_results()
for line in (self.H2lines + self.nonH2lines):
sourcename = line['source'].split('.')[1]
print sourcename
for p in ['pos', 'fwhm', 'ampl']:
n = '{0}.{1}'.format(sourcename, p)
_place_val(line, p, ui.get_par(n).val)
self.const = ui.get_par('c1.c0').val
self.redchi2 = res.rstat
if conf:
res = ui.get_conf_results()
for line in (self.H2lines + self.nonH2lines):
sourcename = line['source'].split('.')[1]
for p in ['pos', 'fwhm', 'ampl']:
n = '{0}.{1}'.format(sourcename, p)
parmin, parmax = _parminmax(res, n)
line[p+'_max'] = parmax
line[p+'_min'] = parmin
# deal with error on const
parmin, parmax = _parminmax(res, 'c1.c0')
self.const_min = parmin
self.const_max = parmax
开发者ID:hamogu,项目名称:TWHya,代码行数:35,代码来源:sherpacode.py
示例17: test_background
def test_background():
tmpdir = tempfile.mkdtemp()
curdir = os.getcwd()
os.chdir(tmpdir)
kT_sim = 1.0
Z_sim = 0.0
norm_sim = 4.0e-2
nH_sim = 0.04
redshift = 0.01
exp_time = (200., "ks")
area = (1000., "cm**2")
fov = (10.0, "arcmin")
prng = 24
agen = ApecGenerator(0.05, 12.0, 5000, broadening=False)
spec = agen.get_spectrum(kT_sim, Z_sim, redshift, norm_sim)
spec.apply_foreground_absorption(norm_sim)
events = make_background(area, exp_time, fov, (30.0, 45.0), spec, prng=prng)
events.write_simput_file("bkgnd", overwrite=True)
instrument_simulator("bkgnd_simput.fits", "bkgnd_evt.fits",
exp_time, "sq_acisi_cy19", [30.0, 45.0],
overwrite=True, foreground=False, ptsrc_bkgnd=False,
instr_bkgnd=False,
prng=prng)
write_spectrum("bkgnd_evt.fits", "background_evt.pi", overwrite=True)
os.system("cp %s %s ." % (arf.filename, rmf.filename))
load_user_model(mymodel, "wapec")
add_user_pars("wapec", ["nH", "kT", "metallicity", "redshift", "norm"],
[0.01, 4.0, 0.2, redshift, norm_sim*0.8],
parmins=[0.0, 0.1, 0.0, -20.0, 0.0],
parmaxs=[10.0, 20.0, 10.0, 20.0, 1.0e9],
parfrozen=[False, False, False, True, False])
load_pha("background_evt.pi")
set_stat("cstat")
set_method("simplex")
ignore(":0.5, 8.0:")
set_model("wapec")
fit()
res = get_fit_results()
assert np.abs(res.parvals[0]-nH_sim)/nH_sim < 0.1
assert np.abs(res.parvals[1]-kT_sim)/kT_sim < 0.05
assert np.abs(res.parvals[2]-Z_sim) < 0.05
assert np.abs(res.parvals[3]-norm_sim)/norm_sim < 0.05
os.chdir(curdir)
shutil.rmtree(tmpdir)
开发者ID:jzuhone,项目名称:pyxsim,代码行数:57,代码来源:test_background.py
示例18: test_point_source
def test_point_source():
tmpdir = tempfile.mkdtemp()
curdir = os.getcwd()
os.chdir(tmpdir)
nH_sim = 0.02
norm_sim = 1.0e-4
alpha_sim = 0.95
redshift = 0.02
exp_time = (100., "ks")
area = (3000., "cm**2")
spec = Spectrum.from_powerlaw(alpha_sim, redshift, norm_sim,
emin=0.1, emax=11.5, nbins=2000)
spec.apply_foreground_absorption(nH_sim, model="tbabs")
positions = [(30.01, 45.0)]
events = make_point_sources(area, exp_time, positions, (30.0, 45.0),
spec, prng=prng)
events.write_simput_file("ptsrc", overwrite=True)
instrument_simulator("ptsrc_simput.fits", "ptsrc_evt.fits",
exp_time, "sq_aciss_cy19", [30.0, 45.0],
overwrite=True, foreground=False, ptsrc_bkgnd=False,
instr_bkgnd=False,
prng=prng)
write_spectrum("ptsrc_evt.fits", "point_source_evt.pi", overwrite=True)
os.system("cp %s %s ." % (arf.filename, rmf.filename))
load_user_model(mymodel, "tplaw")
add_user_pars("tplaw", ["nH", "norm", "redshift", "alpha"],
[0.02, norm_sim*0.8, redshift, 0.9],
parmins=[0.0, 0.0, 0.0, 0.1],
parmaxs=[10.0, 1.0e9, 10.0, 10.0],
parfrozen=[True, False, True, False])
load_pha("point_source_evt.pi")
set_stat("cstat")
set_method("simplex")
ignore(":0.4, 9.0:")
set_model("tplaw")
fit()
res = get_fit_results()
assert np.abs(res.parvals[0]-norm_sim)/norm_sim < 0.05
assert np.abs(res.parvals[1]-alpha_sim)/alpha_sim < 0.05
os.chdir(curdir)
shutil.rmtree(tmpdir)
开发者ID:jzuhone,项目名称:pyxsim,代码行数:56,代码来源:test_point_source.py
示例19: test_lev3fft
def test_lev3fft(self):
self.run_thread("lev3fft", scriptname="bar.py")
# self.assertEqualWithinTol(ui.get_source().lhs.fwhm.val, 0.0034705, 1e-4)
# self.assertEqualWithinTol(ui.get_source().lhs.xpos.val, 150.016, 1e-4)
# self.assertEqualWithinTol(ui.get_source().lhs.ypos.val, 2.66587, 1e-4)
# self.assertEqualWithinTol(ui.get_source().lhs.ampl.val, 0.0117411, 1e-4)
# self.assertEqualWithinTol(ui.get_source().rhs.c0.val, 0.0190897, 1e-4)
self.assertEqualWithinTol(self.locals["src"].fwhm.val, 0.0034705, 1e-4)
self.assertEqualWithinTol(self.locals["src"].xpos.val, 150.016, 1e-4)
self.assertEqualWithinTol(self.locals["src"].ypos.val, 2.66587, 1e-4)
self.assertEqualWithinTol(self.locals["src"].ampl.val, 0.0117411, 1e-4)
self.assertEqualWithinTol(self.locals["bkg"].c0.val, 0.0190897, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().istatval, 19496.3, 1e-4)
self.assertEqualWithinTol(ui.get_fit_results().statval, 607.09, 1e-4)
self.assertEqual(ui.get_fit_results().numpoints, 3307)
self.assertEqual(ui.get_fit_results().dof, 3302)
开发者ID:linearregression,项目名称:sherpa,代码行数:19,代码来源:test_astro.py
示例20: print_fit
def print_fit():
res = sau.get_fit_results()
print("Fit success : \t", res.succeeded)
print("Fit results:")
print("Numpoints :\t", res.numpoints)
print("dof :\t\t", res.dof)
print("Final statistic value : \t", res.statval)
print("Fitted parameters:")
for index, parn in enumerate(res.parnames):
print(parn, "\t\t{0:.3e}".format(res.parvals[index]))
开发者ID:astrofrog,项目名称:gammapy,代码行数:10,代码来源:specsource.py
注:本文中的sherpa.astro.ui.get_fit_results函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论