2014-10-31 42 views
0

我想繪製連接FITS圖上兩點的線段。 (200,250)&(300,400)。這些點的座標(x,y)是(200,250)&(300,400)。如何使用APLpy或python 2.7在FITS圖上繪製線段?

我正在爲此使用APLpy。

我的代碼是:

import matplotlib.pyplot as plt 
import aplpy 
import numpy as np 

fig = aplpy.FITSFigure('test.fits') 
fig.show_grayscale() 

a=np.ndarray(shape=(2,2)) 
a[0][0]=200 
a[0][1]=250 
a[1][0]=300 
a[1][1]=400 

fig.show_lines(a) 

plt.show() 

我使用 「fig.show_lines()」 APLpy的功能以下網頁上描述: http://aplpy.readthedocs.org/en/latest/quick_reference.html#shapes

它說 'numpy的陣列的使用清單'作爲show_lines()的參數。

但我得到以下錯誤消息:

Traceback (most recent call last): 
File "draw.py", line 16, in <module> 
fig.show_lines(a) 
File "<string>", line 2, in show_lines 
File "/home/swapnil/anaconda/lib/python2.7/site-packages/aplpy/decorators.py", line 25, in _auto_refresh 
return f(*args, **kwargs) 
File "/home/swapnil/anaconda/lib/python2.7/site-packages/aplpy/aplpy.py", line 1275, in show_lines 
xp, yp = wcs_util.world2pix(self._wcs, line[0, :], line[1, :]) 
IndexError: too many indices 

任何幫助將不勝感激。

謝謝。

回答

0

我的理解,它應該是2xN numpy的陣列的列表:

x = np.array([[200], [300]]) 
y = np.array([[250], [400]]) 

fig.show_lines([x, y]) 

HTH,

德語。

+0

其實,我做了一個測試,它沒有畫出線。我想看看@astrofrog能說些什麼。 – skytux 2014-12-03 14:30:37

0

你需要做這樣的事情:

iline = np.array([[x1, x2],[y1,y2]]) 
fig.show_lines([iline], color = 'r') 

x1x2y1y2是正確的單位(對我來說,這是度)

相關問題