IterativelySubtractedPSFPhotometry()使用DiscretePRF返回None

时间:2018-08-05 01:56:39

标签: python astropy

我正在尝试在图像上进行PSF摄影。第一步,我使用标准photutil运行IterativelySubtractedPSFPhotometry()的{​​{1}}。这很好用,我得到了一个包含适当通量和位置的IntegratedGaussianPRF()。在第二步中,我想生成图像的PSF。因此,我向Table输入了坐标和通量,这对PSF产生了很好的估计。现在使用最后一步生成的psf模型重新运行DiscretePRF.generate_from_image()会返回IterativelySubtractedPSFPhotometry()。发生什么事了?

我遵循了:Astropy Docs用于寻星算法,而该example用于psf模型。

这是MWE:

None

这是PSF,不是很好,但是还可以! enter image description here

现在用测得的psf重做找到的图像失败:

from photutils.detection import IRAFStarFinder
from photutils.psf import IntegratedGaussianPRF, DAOGroup
from photutils.background import MMMBackground, MADStdBackgroundRMS
from astropy.modeling.fitting import LevMarLSQFitter
from astropy.stats import gaussian_sigma_to_fwhm
from photutils.psf import IterativelySubtractedPSFPhotometry, prepare_psf_model
from photutils.psf.sandbox import DiscretePRF
from astropy.utils.data import download_file
from astropy.io import fits
import numpy as np

def run():
    image_file = download_file('http://data.astropy.org/tutorials/FITS-images/HorseHead.fits', cache=True )
    hdu_list = fits.open(image_file)
    image_data = hdu_list[0].data
    sigma_psf       = 6
    bkgrms          = MADStdBackgroundRMS()
    std             = bkgrms(image)
    iraffind        = IRAFStarFinder(threshold=3.5*std, fwhm=sigma_psf*gaussian_sigma_to_fwhm,
                                     minsep_fwhm=0.01,  roundhi=5.0, 
                                     roundlo=-5.0, sharplo=0.0, sharphi=2.0)

    daogroup        = DAOGroup(2.0*sigma_psf*gaussian_sigma_to_fwhm)
    mmm_bkg         = MMMBackground()
    fitter          = LevMarLSQFitter()
    psf_model       = IntegratedGaussianPRF(sigma=sigma_psf)

    photometry      = IterativelySubtractedPSFPhotometry(finder             = iraffind,
                                                         group_maker        = daogroup,
                                                         bkg_estimator      = mmm_bkg,
                                                         psf_model          = psf_model,
                                                         fitter             = LevMarLSQFitter(),
                                                         niters             = 1, 
                                                         fitshape           = (33,33))


    result_tab      = photometry(image=image)

    psf             = DiscretePRF.create_from_image(image, result_tab, 15, fluxes= result_tab['flux_0'], mode='median', subsampling=1)

    y, x            = np.mgrid[-11:11,-11:11]

    psf_i           = psf(x,y)

    import matplotlib.pyplot as plt

    plt.imshow(psf_i, origin='lower')
    plt.show()

photometry = IterativelySubtractedPSFPhotometry(finder = iraffind, group_maker = daogroup, bkg_estimator = mmm_bkg, psf_model = psf, fitter = LevMarLSQFitter(), niters = 1, fitshape = (27,27)) print(photometry.get_residual_image()) 现在为photometry

0 个答案:

没有答案