photutils基本光度法PSF光度测定中的拟合优度

2024-04-29 04:38:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用photutils.psf中的BasicSPFPhotometry来获得光源的光度

这里是我的代码示例(遗憾的是,这不是一个工作示例,但可以帮助理解我正在做什么和我需要什么)。其中大部分是从https://photutils.readthedocs.io/en/stable/psf.html复制的,并根据我的需要进行了调整

fitter=LevMarLSQFitter()
psf_model = photutils.psf.FittableImageModel(psfdata,normalize=True)
pos = Table(names=['id','x_0', 'y_0','flux_0'], data=[[1],[xycen[0]],[xycen[1]],[flux]])

photometrypsf = BasicPSFPhotometry(group_maker=daogroup,
                                    bkg_estimator=None,
                                    psf_model=psf_model,
                                    fitter=fitter,
                                    fitshape=target.shape,
                                    aperture_radius=fwhm)

psf_photometry = photometrypsf(image=target.copy(),init_guesses=pos)

我需要估计我的源的PSF拟合的卡方,但我不知道怎么做

我在下面的帖子(In Scipy how and why does curve_fit calculate the covariance of the parameter estimates)中解释了如何得到简化的卡方:

s_sq = (infodict['fvec']**2).sum()/ (N-n)

我能够将我的代码翻译成:

s_sq = (fitter.fit_info['fvec']**2).sum()/(len(fitter.fit_info['fvec'])-n)

问题是我不知道如何计算“n”。在这个例子中,他们说n(自由参数的数量)是scipy.optimize.leastsq(第一个输出)的输出x的长度,但是LevMarLSQFitter明确指出:

Note that the x return value is not included (as it is instead the parameter values of the returned model).

因此,问题是,使用LevMarLSQFitter基本CPSFphotometry结合使用,估计拟合卡方(或任何其他参数可以让我了解拟合优度)的最实用方法是什么?此外,如何访问从LevMarLSQFitter执行的拟合参数


Tags: the代码pos示例参数modelfitfitter