无法使用PYFIT打印.fit文件

2024-04-23 07:08:43 发布

您现在位置:Python中文网/ 问答频道 /正文

在Fits文件中,我有三个列,分别称为J、H和K,我想用PYFITS分别在x和y轴上绘制J-H和H-K之间的关系。 我怎么做这个?


Tags: 文件关系绘制fitspyfits
1条回答
网友
1楼 · 发布于 2024-04-23 07:08:43

这是一个非常普遍和基本的问题。在

首先需要打开FITS文件并打印,下面是一个示例程序:

import pyfits
import matplotlib.pyplot as plt

# Load the FITS file into the program
hdulist = pyfits.open('Your FITS file name here')

# Load table data as tbdata
tbdata = hdulist[1].data

fields = ['J','H','K'] #This contains your column names
var = dict((f, tbdata.field(f)) for f in fields) #Creating a dictionary that contains
                                                 #variable names J,H,K

#Now to call column J,H and K just use
J = var['J']   
H = var['H']
K = var['K']

#To plot J Vs H and H Vs K and so on
plt.plot(J,H,'r')
plt.title('Your plot title here')
plt.show()

相关问题 更多 >