2016-10-15 4 views
0

나는 은하수 지역의지도를 만들어야합니다. (radiotelescope로 수집 된 데이터).온도가있는 은하수 (Ra, Dec) 지역의지도

내가 파일을 cooordinates 12월으로 .txt로 가지고 있고, 기자 온도 관찰 :

244.785416667;-13.5105555556;-2.96409416136 
246.039166667;-13.5086111111;4.7494842185 
247.292083333;-13.5066666667;4.85067698715 
.txt 인 모든 파일이 고도 (23,24,25에 해당

, 26,27,30).

나는 이런 식으로 뭔가 싶어 :

enter image description here

을하지만 난 그것을 플롯, 파이썬에서, 방법을 찾아 cant't. 나는 histo2D와 같은 것을 사용해야한다고 생각합니다. 그러나 온도의 데이터를 설정하는 방법과 장소를 이해할 수는 없습니다. 나는 (아마도 또한 논리적으로),이 코드를 tryed하지만, 잘못했습니다

pp.figure(1) 
pp.hist2d(ra,dec,bins=(20,5),range=((250,320),(-24,-16)), weights=temp) 
pp.colorbar() 
pp.show() 

당신이 히스 또는 내가이 경우에 사용해야 그래픽도 또한 유형을 알고 있으면 알려 주시기 바랍니다.

답변

0

히트 맵 그림의 경우 matplotlib의 imshow을 사용하고 싶습니다.

다음과 같이 할 수 이것을 사용하여 일부 코드의 예 : 여기

import matplotlib.pyplot as plt 
from mpl_toolkits.axes_grid1 import make_axes_locatable 

fig = plt.figure() 
ax = plt.add_subplot(111) 

heat = ax.imshow(tempmat, 
       cmap=plt.cm.viridis, 
       interpolation='none') 

# include a colorbar to show the temperature corresponding to each colour 
curax = make_axes_locatable(plt..agca()) 
cbax = curax.append_axes('right', '5%', pad='3%') 
fig.colorbar(heat, cax=cbax) 

fig.savefig("temperature_heatmap.pdf") 
# or instead of saving, just use fig.show() 

, 우리는 imshow 함수에 2 차원 배열 tempmat를 통과했다. 귀하의 경우에는, 주어진 .txt 파일, 이것은이 사용 NumPy와의 histogram2d 기능을 할 수있는 RA 12 월 당신의 빈 (bin)의 고정 세트에서 온도 값을 포함합니다 :

import numpy as np 

# since your example shows semicomma-separated values 
dat = np.loadtxt("filename.txt", delimiter=';') 

# bin the data in a space of RA and Dec bins, with 
# - RAbins = number of bins you want in RA 
# - Decbins = number of bins you want in Dec 
# (alternatively, supply arrays of bin edges for uneven bin widths) 
# - [0, 360] and [-90, 90] or your preferred range 
# of RA and Dec to plot temperature bins for 
# - weight counts by the temperature of each data point 
tsums = np.histogram2d(dat[:, 1], dat[:, 0], 
         bins=[RAbins, Decbins], 
         range=[[0, 360], [-90, 90]], 
         weights=dat[:, 2]) 

# here we repeat as above without the weighting, 
# so that we can find the average temperature in each bin 
bincounts = np.histogram2d(dat[:, 1], dat[:, 0], 
          bins=[RAbins, Decbins], 
          range=[[0, 360], [-90, 90]], 
          weights=dat[:, 2]) 

# divide the resulting 2d arrays to get bin temperatures 
tempmat = tsums[0]/bincounts[0] 

여기에 내가 만든 예입니다 임의의 데이터 :

enter image description here