-1

在 Fits 文件中,我有名为 J、H 和 K 的三列,我想分别用 PYFITS 在 x 和 y 轴上绘制 JH 和 HK 之间的关系。我怎样才能做到这一点?

4

1 回答 1

1

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

首先你需要打开你的 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()
于 2014-08-24T20:30:38.717 回答