Differences between revisions 2 and 3
Revision 2 as of 2020-06-28 21:50:26
Size: 1174
Comment:
Revision 3 as of 2020-06-28 21:54:30
Size: 1349
Comment:
Deletions are marked like this. Additions are marked like this.
Line 30: Line 30:

[[http://scikit-hep.org/root_numpy/|root_numpy]]を使えばもっと効率よく書けるかもしれないが、これはインストールの敷居が高いので保留

pyROOT

高エネルギー宇宙物理学のためのROOT入門 ‒第6回‒

KamonoWiki

QumaWiki

gwpyのFrequencySeriesをROOTのTH1にする

   1 mean  = FrequencySeries(...)
   2 error = FrequencySeries(...)
   3 
   4 nbin = mean.size
   5 value = mean.value
   6 freqs = mean.frequencies.value
   7 df = mean.df.value
   8 fmin = freqs[0] - df*0.5
   9 fmax = freqs[-1]+ df*0.5
  10 
  11 h = TH1F('h', ';Frequency [Hz]', nbin, fmin, fmax)
  12 h.Sumw2()
  13 h.SetContent(array('d', np.insert(      value, 0,0).tolist() ) )
  14 h.SetError(  array('d', np.insert(error.value, 0,0).tolist() ) )

SetContent()SetError()はゼロbin目(アンダーフロー)から詰めるため、ndarrayの先頭にゼロを追加しておく必要がある。

root_numpyを使えばもっと効率よく書けるかもしれないが、これはインストールの敷居が高いので保留

KAGRA/Subgroups/PEM/PythonMemoJP/pyROOT (last edited 2020-06-28 22:23:38 by tatsuki.washimi)