【问题标题】:Getting data from an image with astropy?从带有 astropy 的图像中获取数据?
【发布时间】:2020-03-29 17:32:38
【问题描述】:

所以我导入了一个 FITS 文件并使用 astropy 和 matplotlib 显示了一个图像。该图像有一些亮点,但我不知道如何突出图像上感兴趣的特定明亮区域并获得亮度的平均值。谁能帮忙?

【问题讨论】:

  • 您好,对于 Stack Overflow 来说,这个问题可能有点“过于宽泛”,因为它不一定要问一个特定的编程问题,甚至开始回答您的问题也取决于域-特定(天文学)知识以及有关您的数据及其外观的更多详细信息。但是,photutils 之类的软件包可能对您有用,或者其他 Astropy affiliated packages 之一可能对您有用,例如 imexam

标签: python matplotlib astropy


【解决方案1】:

例子:

from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt

## Read
hdul = fits.open('yourfile.fits')
image = hdul[0].data
Ny, Nx = image.shape

## Mean (careful if the unit is MJy/sr)
avg = np.nanmean(image)
print('Image mean = ', avg)

## Plot (mark bright spots)
xl = []
yl = []
for x in range(Nx):
    for y in range(Ny):
        if image[y,x]>avg:
            xl.append(x)
            yl.append(y)
plt.imshow(image)
plt.scatter(xl, yl, c='r', marker='o')
plt.show()

【讨论】:

    猜你喜欢
    • 2023-03-17
    • 1970-01-01
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 2014-05-24
    相关资源
    最近更新 更多