cuiastro
from astropy.io import fits
hdu_list = fits.open(image_file)
hdu_list.info()
image_data = hdu_list[0].data

print(type(image_data))

print(image_data.shape)
hdu_list.close()  # 关闭,否则占用内存
# 如果你不需要查看fits头文件,可以用fits.getdata代替前面的步骤
image_data = fits.getdata(image_file)
print(type(image_data))
print(image_data.shape)
plt.imshow(image_data, cmap=\'gray\') # 不指定颜色,默认为彩色
plt.colorbar()
#打印最大值最小值平均值和标准差
print(\'Min:\', np.min(image_data))
print(\'Max:\', np.max(image_data))
print(\'Mean:\', np.mean(image_data))
print(\'Stdev:\', np.std(image_data))
# 绘出柱状图
NBINS = 1000
histogram = plt.hist(image_data.flatten(), NBINS)
 ===========================================================================
hdu=header data unit
hdul.info()
hdul[0].header
hdul[0].header[\'DATE\']
hdul[0].header.comments[\'fitsver\']   #显示关键字的注释
list(hdul[0].header)   # 显示所有关键字
data = hdul[1].data
data.shape
data[0]  # 第一行的数据
data.field(0) # 第一列的数据
data.field(\'utobs\')
data.field(\'freq\')
data.field(\'CHAN_BW\')
hdul[1].header
data[2][3]  # 访问第二行第三列数据

data.names  # 查看字段,即field
data.field(\'DATA\')

hdr[\'targname\'= (\'NGC121-a\'\'the observation target\')  为头文件添加关键字,内容和注释

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2022-01-08
  • 2021-09-17
  • 2021-11-23
  • 2021-09-17
  • 2021-12-27
猜你喜欢
  • 2021-09-17
  • 2021-09-17
  • 2021-12-30
  • 2021-09-17
  • 2021-09-17
  • 2021-09-17
  • 2021-08-29
相关资源
相似解决方案