Skip to content

Draft: Implement Metric math operations

This is to help improve and simplify the plotting code for things like ratios. Mostly this just wraps the internal Hist operations, but gets units right and sets the labels accordingly. It's not meant to be feature complete, just enough for use with the poster plots.

TODO:

  • handle case where bins don't match... should this be done implicitly? Right now there is separate code for ratio interpolation

E.g.:

a1.plot(yerr=0)
a2.plot(yerr=0)
plt.semilogx()

image

(a1/a2).plot()
plt.semilogx()

image

(a1/a2 - 1.0).plot()
plt.semilogx()

image

Units are handled properly, so this also works:

(a1 + 0.5 * u.deg).plot()
plt.semilogx()

image

Now that this works, I use it to implement metric comparison plots:

m1 = Metric(label="Counts", axis_list=[hist.axis.Regular(100, -1, 1, name="x_reco")])
m1.name="Exp1"
m1.fill(np.random.normal(size=(10_0000)))
m2 = Metric(label="Counts", axis_list=[hist.axis.Regular(100, -1, 1, name="x_reco")])
m2.name="Exp2"
m2.fill(np.random.normal(size=(10_0000)))

m1.plot_compare_1d(m2)

image

Can also compare multiple metrics:

a2.plot_compare_1d([a1, a1/1.1], yerr=0)

image

Edited by Karl Kosack

Merge request reports

Loading