Photutils Source Detection 不适用于小图片,适用于大图片,为什么?
Photutils Source Detection doesnt work for small pic, works for large, why?
我正在尝试检测图片上的 stars/astronomical 个对象。
这是我能做好的图,如下图:
按照建议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 行中给出的阈值有多小,它 只找到一颗星,而不是所希望的两颗 。
为什么会这样,我该如何解决?
box_size=4 我有这个结果:
我必须在 运行 你在 jupyter notebook 中的脚本之前安装这些模块:
pip3 install jupyter lightkurve photutils
– 并使用此命令也可以查看图像结果:
plt.interactive(True)
%matplotlib
我正在尝试检测图片上的 stars/astronomical 个对象。 这是我能做好的图,如下图:
按照建议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 行中给出的阈值有多小,它 只找到一颗星,而不是所希望的两颗 。
为什么会这样,我该如何解决?
box_size=4 我有这个结果:
我必须在 运行 你在 jupyter notebook 中的脚本之前安装这些模块:
pip3 install jupyter lightkurve photutils
– 并使用此命令也可以查看图像结果:
plt.interactive(True)
%matplotlib