Photutils源检测不适用于小型图片,适用于大型图片,为什么?

时间:2018-08-27 10:39:39

标签: python image-processing physics astronomy astropy

我正在尝试检测图片上的恒星/天文物体。 这是我擅长的图片,如下所示:

pic like Hubble Deep Field

按照建议given on this site,我有以下代码:

from astropy.stats import sigma_clipped_stats
from photutils.datasets import make_100gaussians_image
from photutils import find_peaks
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
from astropy.visualization.mpl_normalize import ImageNormalize
from photutils import CircularAperture
data = make_100gaussians_image()
mean, median, std = sigma_clipped_stats(data, sigma=3.0)
threshold = median + (5. * std)
tbl = find_peaks(data, threshold, box_size=11)
positions = (tbl['x_peak'], tbl['y_peak'])
apertures = CircularAperture(positions, r=5.)
norm = simple_norm(data, 'sqrt', percent=99.9)
plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm)
apertures.plot(color='#0547f9', lw=1.5)
plt.xlim(0, data.shape[1]-1)
plt.ylim(0, data.shape[0]-1)

工作正常,这是输出:

lots of stars with some marked

如果我将第10行修改为threshold = median + (30. * std),那么我得到的输出将像预期的那样少标记了星星。这是输出:

enter image description here

现在,我想将其用于此文件:

pic with two stars

为此,我运行以下代码,从FITS文件中加载源:

import lightkurve
tpf=lightkurve.targetpixelfile.KeplerTargetPixelFile('ktwo201103700-c102_lpd-targ.fits')
from astropy.stats import sigma_clipped_stats
from photutils.datasets import make_100gaussians_image
from photutils import find_peaks
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
from astropy.visualization.mpl_normalize import ImageNormalize
from photutils import CircularAperture
#data = make_100gaussians_image()
data = tpf.flux[100]
mean, median, std = sigma_clipped_stats(data, sigma=3.0)
threshold = median + (0.1 * std)
tbl = find_peaks(data, threshold, box_size=11)
#tbl['peak_value'].info.format = '%.8g'  # for consistent table output
#print(tbl[:10])    # print only the first 10 peaks
positions = (tbl['x_peak'], tbl['y_peak'])
apertures = CircularAperture(positions, r=1.)
norm = simple_norm(data, 'sqrt', percent=99.9)
plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm)
apertures.plot(color='#0547f9', lw=1.5)
plt.xlim(0, data.shape[1]-1)
plt.ylim(0, data.shape[0]-1)

输出如下。无论我在第13行中给出多小的阈值,它都会只找到一颗星,而不是两颗

two stars, one is circled

这是为什么,我该如何解决?

1 个答案:

答案 0 :(得分:1)

使用 box_size = 4 ,我得到以下结果:3stars

jupyter笔记本中运行脚本之前,我必须安装这些模块:

pip3 install jupyter lightkurve photutils

–并使用此命令还可以查看图像结果:

plt.interactive(True)
%matplotlib