2016-10-15 4 views
0

です。私はMilky Way地域の地図を作成する必要があります。 (ラジオテレスコープで収集したデータ)。天の川の地域の地図(Ra、Dec)温度は

私はファイルがcooordinates 12月RA、および特派温度が観察して.txtでいる:.TXT内のすべてのファイルは、標高(23,24,25、に対応

244.785416667;-13.5105555556;-2.96409416136 
246.039166667;-13.5086111111;4.7494842185 
247.292083333;-13.5066666667;4.85067698715 

26,27,30)。

私はこのような何かしたい:

enter image description here

を、私はそれをプロットするために、Pythonで、方法を見つけるcant't。私はhisto2Dのようなものを使うべきだと思いますが、温度のデータをどのように/どのように設定するかは分かりません。 私は(多分も論理的に)、このコードをしようと試みますが、間違っていました:

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月におけるビンの固定セットでの温度値が含まれます:

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