%matplotlib auto
-
最近の投稿
最近のコメント
Archive
カテゴリー
メタ情報
numpy 行列(配列) array に対する操作
*行列の左右のみを反転させる.
numpy.fliplr(a)
http://docs.scipy.org/doc/numpy/reference/generated/numpy.fliplr.html
*転置行列
a.T
*行列形式のデータの表示
matplotlib.pyplot.imshow(a, interpolation=’nearest’)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import numpy as np a = np.array([[10, 8, 6], [ 9, 4, 2], [ 7, 3, 1], [ 5, 1, 0]]) np.fliplr(a) array([[ 6, 8, 10], [ 2, 4, 9], [ 1, 3, 7], [ 0, 1, 5]]) a.T array([[10, 9, 7, 5], [ 8, 4, 3, 1], [ 6, 2, 1, 0]]) import matplotlib.pyplot as plt plt.imshow(a, interpolation='nearest') plt.colorbar() |
pyROOT では TTree tree の各エントリー event のある変数 x1 , x2 を得るとき,これでできる
1 2 |
for event in tree: print event.x1, event.x2 |
参考:
https://root.cern.ch/phpBB3/viewtopic.php?t=10962
既に存在する 1 次元ヒストグラム (h1) のビンの数,ビンの最小値,ビンの最大値を得には次のようにする.
(pyRoot ではなく C のときは,メソッドを呼び出す記号は “.” ではなく “->”)
1 2 3 |
nxbins = h1.GetXaxis().GetNbins() xmin = h1.GetXaxis().GetXmin() xmax = h1.GetXaxis().GetXmax() |
第 i 番目のビンの下端,中心値,上端を得る
1 2 3 |
binlow = h1.GetXaxis().GetBinLowEdge(i) binc = h1.GetXaxis().GetBinCenter(i) binup = h1.GetXaxis().GetBinUpEdge(i) |
2 次元ヒストグラム (h2) の場合, Y 軸のビンの数や,最小のビンのを知るには,
1 2 3 |
nybins = h2.GetYaxis().GetNbins() ymin = h2.GetYaxis().GetXmin() ymax = h2.GetYaxis().GetXmax() |
Fill された値がどのビン番号 (index) に属するかを調べるには,FindBin() を使う.
1 |
wBinX = h1.GetXaxis().FindBin(value) |
ヒストグラムの最大値/最小値をもつビンの index を返すには,
1 2 |
maxBin = h1.GetMaximumBin() minBin = h1.GetMinimumBin() |