8 Modify histogram so that it is rescaled in a "bilog" manner. 9 Negative values are -log10(-z). An offset in log10 is returned 12 nx,ny = hist.GetNbinsX(), hist.GetNbinsY()
13 zmax =
max(
abs(hist.GetMinimum()),
abs(hist.GetMaximum()))
16 zmin = sum([
abs(hist.GetBinContent(99,iy))
for iy
in range(ny)]) / ny
17 lmin =
int(log10(zmin))
19 lmax = 1+
int(log10(zmax))
21 for ix
in range(hist.GetNbinsX()):
22 for iy
in range(hist.GetNbinsY()):
23 val = hist.GetBinContent(ix, iy)
25 hist.SetBinContent(ix, iy, 0.0)
31 lval = log10(
abs(val))
37 hist.SetBinContent(ix, iy, lval)
43 hist.SetMaximum(lhmax)
44 hist.SetMinimum(-lhmax)
48 from array
import array
49 stops =
array(
'd',[ 0.00, 0.45, 0.50, 0.55, 1.00 ])
50 reds =
array(
'd',[ 0.00, 0.00, 1.00, 1.00, 0.51 ])
51 greens =
array(
'd',[ 0.00, 0.81, 1.00, 0.20, 0.00 ])
52 blues =
array(
'd',[ 0.51, 1.00, 1.00, 0.00, 0.00 ])
56 ROOT.gStyle.SetNumberContours(100)
59 if not which
or which ==
"custom":
60 ROOT.TColor.CreateGradientColorTable(len(stops), stops, reds, greens, blues, 100)
62 ROOT.gStyle.SetPalette(which)
64 fp = ROOT.TFile.Open(
"build/gen/test_impactzipper-uvw.root")
65 hists = {u:fp.Get(
"h%d"%n)
for n,u
in enumerate(
"uvw")}
69 pdffile=
"plot_impactzipper.pdf" 72 c.SetRightMargin(0.15)
73 c.Print(pdffile+
"[",
"pdf")
77 for (p,h),lim,lmin
in zip(sorted(hists.items()), limits, lmins):
82 h.SetTitle(h.GetTitle() +
" point source")
83 h.GetXaxis().SetRangeUser(3900, 4000)
84 h.GetYaxis().SetRangeUser(989, 1012)
85 h.GetZaxis().SetRangeUser(-lim, lim)
86 c.Print(pdffile,
"pdf")
91 title +=
" [sign(z)(log10(abs(z)) %d)]" % lminout
95 c.Print(pdffile,
"pdf")
98 c.Print(pdffile+
"]",
"pdf")
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def bilogify(hist, lmin=None)
def set_palette(which="custom")
static int max(int a, int b)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.