我正在尝试检测图片上的恒星/天文物体。 这是我擅长的图片,如下所示:
按照建议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)
工作正常,这是输出:
如果我将第10行修改为threshold = median + (30. * std)
,那么我得到的输出将像预期的那样少标记了星星。这是输出:
现在,我想将其用于此文件:
为此,我运行以下代码,从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行中给出多小的阈值,它都会只找到一颗星,而不是两颗。
这是为什么,我该如何解决?