-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_bg.py
More file actions
45 lines (39 loc) · 1.42 KB
/
plot_bg.py
File metadata and controls
45 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np
import matplotlib.pyplot as plt
import glob
from pathlib import Path
fp = "/Users/soham/Documents/Quick Access/LBNL_BellaExp_6_2025/REPPS_analysis/Background_analysis/"
files = list(Path(fp).glob("*.npz"))
print([f.name for f in files]) # just filenames
bg = []
for i in range(len(files)):
bg.append(np.load(files[i]))
m_sig = []
m_bg = []
buff = bg[0]["msig"]
data = [[bg[i]["msig"][0,:], bg[i]["msig"][1,:], bg[i]["mbg"][0,:], bg[i]["mbg"][1,:]] for i in range(len(bg))]
avg_data = np.array([ [np.mean(p[0]), np.mean(p[1]), np.mean(p[2]), np.mean(p[3])] for p in data])
idx = np.argsort(avg_data[:,0])
sort_data = avg_data[idx]
fig, ax = plt.subplots()
ax.plot(avg_data[:,0], label = "lanex on shot")
ax.plot(avg_data[:,1], label = "lanex on test")
ax.plot(avg_data[:,2], label = "groove on shot")
ax.plot(avg_data[:,3], label = "groove on test")
plt.xlabel("Shots(arb)")
plt.ylabel("Mean pix value(arb)")
plt.legend()
plt.title('Background for 07/01')
plt.savefig(Path(fp)/"plots/unsorted_bg.png")
plt.show(block=False)
fig1, ax1 = plt.subplots()
ax1.plot(sort_data[:,0], label = "lanex on shot")
ax1.plot(sort_data[:,1], label = "lanex on test")
ax1.plot(sort_data[:,2], label = "groove on shot")
ax1.plot(sort_data[:,3], label = "groove on test")
plt.xlabel("Shots(arb)")
plt.ylabel("Mean pix value(arb)")
plt.legend()
plt.title('Sorted Background for 07/01')
plt.savefig(Path(fp)/"plots/sorted_bg.png")
plt.show()