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()
(a1/a2).plot()
plt.semilogx()
(a1/a2 - 1.0).plot()
plt.semilogx()
Units are handled properly, so this also works:
(a1 + 0.5 * u.deg).plot()
plt.semilogx()
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)
Can also compare multiple metrics:
a2.plot_compare_1d([a1, a1/1.1], yerr=0)
Edited by Karl Kosack