Skip to content

Commit 19394bd

Browse files
authored
Merge pull request #1 from nabu-hep/supplementary-plots
Add plotting scripts
2 parents 520f1c4 + cfc6a95 commit 19394bd

File tree

5 files changed

+109
-1
lines changed

5 files changed

+109
-1
lines changed

ATLAS.png

171 KB
Loading

LHCb.png

62.8 KB
Loading

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ The WET model used in this paper is included in `WET/wet-model.nabu`, which cont
3737
```bash
3838
nabu-fit-to-data -dp WET/wet-dataset.npz -e 600 -w 64 -l 2 -d 3 -lr 0.001 -mlr 0.0001
3939
```
40-
4140
The datafile contains standardised version of ${\rm Re}[C_{V_R}^{\bar{u}b\bar{e}\nu_e}]$, ${\rm Re}[C_{V_L}^{\bar{u}b\bar{e}\nu_e}]$, ${\rm Re}[C_{S_R}^{\bar{u}b\bar{e}\nu_e}]$, ${\rm Re}[C_{S_L}^{\bar{u}b\bar{e}\nu_e}]$ and ${\rm Re}[C_{T}^{\bar{u}b\bar{e}\nu_e}]$, respectively.
4241

42+
# Sample illustrations
43+
The complexity of the different samples can be illustrated using
44+
```bash
45+
python visualisation.py {ATLAS,LHCb,WET}
46+
```
47+
48+
Please note that in addition to the packages required in the main repo ([see here](https://github.com/nabu-hep/nabu-hep/blob/main/requirements.txt)), the script uses `pandas`, `mplhep`, and `hist` which are available with `pip` and `conda`.
49+
50+
<table>
51+
<tr>
52+
<th>Figure</th>
53+
<th>Caption</th>
54+
</tr>
55+
<tr>
56+
<td><img src="/ATLAS.png?raw=true" width="1000px" height="auto"></a></td>
57+
<td>One- and two-dimensional projections of the ATLAS example data set.</td>
58+
</tr>
59+
<tr>
60+
<td><img src="/LHCb.png?raw=true" width="1000px" height="auto"></a></td>
61+
<td>One- and two-dimensional projections of the LHCb example data set.</td>
62+
</tr>
63+
<tr>
64+
<td><img src="/WET.png?raw=true" width="1000px" height="auto"></a></td>
65+
<td>One- and two-dimensional projections of the WET example data set.</td>
66+
</tr>
67+
</table>
68+

WET.png

226 KB
Loading

visualisation.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import argparse
2+
import pandas as pd
3+
import hist
4+
import numpy as np
5+
6+
import matplotlib.pyplot as plt
7+
import mplhep
8+
mplhep.style.use("CMS")
9+
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument('data', type=str)
12+
args = parser.parse_args()
13+
14+
assert(args.data in ['LHCb', 'ATLAS', 'WET'])
15+
16+
if args.data == 'LHCb':
17+
fname = 'LHCb/lhcb-dataset.npz'
18+
columns = ["mKD", "mDD"]
19+
labels = [r"$m'(K^+D^-)$", r"$m'(D^+D^-)$"]
20+
ranges = [[-0.05,1.05]]*2
21+
elif args.data == 'ATLAS':
22+
fname = 'ATLAS/atlas-dataset.npz'
23+
columns = ["pT", "y", "pT1", "eta", "phi"]
24+
labels = [r"$p_T^{\mu\mu}$",r"$y^{\mu\mu}$",r"$p_T^{\mu_1}$",r"$\Delta \eta_{12}^2$",r"$\Delta \phi_{12}^2$"]
25+
ranges = [[-0.05,1.05]]*5
26+
elif args.data == 'WET':
27+
fname = 'WET/wet-dataset.npz'
28+
columns = ["VL", "VR", "SL", "SR", "T"]
29+
labels = [ r"${\rm Re}{\cal C}_{V_R}^{\bar{u}b\bar{e}\nu_e}$",
30+
r"${\rm Re}{\cal C}_{V_L}^{\bar{u}b\bar{e}\nu_e}$",
31+
r"${\rm Re}{\cal C}_{S_R}^{\bar{u}b\bar{e}\nu_e}$",
32+
r"${\rm Re}{\cal C}_{S_L}^{\bar{u}b\bar{e}\nu_e}$",
33+
r"${\rm Re}{\cal C}_{T}^{\bar{u}b\bar{e}\nu_e}$"]
34+
ranges = [[-1.8, 1.8], [-1.8, 1.8], [-2.8, 2.8], [-2.8, 2.8], [-2.8, 2.8]]
35+
36+
data = np.load(fname)
37+
X_train = pd.DataFrame(data['X_train'], columns=columns)
38+
X_test = pd.DataFrame(data['X_test'], columns=columns)
39+
data = pd.concat([X_train, X_test], ignore_index=True)
40+
41+
f = plt.figure()
42+
fig, ax = plt.subplots(len(columns),len(columns),figsize=(f.get_size_inches()[0]*len(columns)/2,f.get_size_inches()[1]*len(columns)/2),gridspec_kw={'hspace': 0, 'wspace': 0})
43+
44+
for i in range(0,len(columns)):
45+
ymin, ymax = ranges[i][0], ranges[i][1]
46+
for j in range(0,i):
47+
print(i,j)
48+
xmin, xmax = ranges[j][0], ranges[j][1]
49+
50+
h, xedges, yedges = np.histogram2d(data[columns[j]],data[columns[i]],bins=50,range=((xmin,xmax),(ymin,ymax)))
51+
datac = ax[i,j].contourf(h.T, extent=[xedges.min(),xedges.max(),yedges.min(),yedges.max()], cmap="YlOrRd", levels=10)
52+
# add contour lines
53+
# ax[i,j].contour(datac,colors="k",linewidths=1,alpha=0.5)
54+
55+
# set limits
56+
ax[i,j].set_xlim(xmin, xmax)
57+
ax[i,j].set_ylim(xmin, xmax)
58+
59+
# make upper right invisible
60+
ax[j,i].set_visible(False)
61+
62+
# plot histograms in diagonal
63+
H = hist.Hist(hist.axis.Regular(50, ymin, ymax))
64+
H.fill(data[columns[i]])
65+
mplhep.histplot(H, ax=ax[i,i], color="black", histtype="errorbar", density=True, xerr=True, yerr=True)
66+
67+
# set limits
68+
ax[i,i].set_xlim(ymin, ymax)
69+
ax[i,i].set_ylim(0,)
70+
71+
ax[i,i].set_yticks([]) # remove yticks from diagonal
72+
ax[len(columns)-1,i].set_xlabel(labels[i]) # set bottom row xlabels
73+
# set left column ylabels with fixed offset from edge
74+
ax[i,0].yaxis.set_label_coords(-0.15,0.5)
75+
ax[i,0].set_ylabel(labels[i]) # set left column ylabels
76+
# # remove yticklabels from all but the left column
77+
if i!=0:
78+
for j in range(0,len(columns)):
79+
ax[j,i].set_yticklabels([])
80+
plt.tight_layout()
81+
plt.savefig(f"{args.data}.png")
82+
plt.close()

0 commit comments

Comments
 (0)