71 lines
1.8 KiB
Python
Executable File
71 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from time import sleep
|
|
from collections import deque
|
|
import numpy as np
|
|
from zoetrope import aniplot as plt
|
|
from scipy.stats.stats import pearsonr
|
|
from bstrd import BS, bsstream
|
|
plt.blit = False
|
|
plt.style.use('ggplot')
|
|
|
|
wav = np.linspace(409.914, 672.792, num=2048)
|
|
|
|
def unpumpedshots(pulseids, *arrays):
|
|
unpumped_shots = (pulseids%2 == 0)
|
|
return [a[unpumped_shots] for a in arrays]
|
|
|
|
|
|
def pumpedshots(pulseids, *arrays):
|
|
pumped_shots = (pulseids%2 == 1)
|
|
return [a[pumped_shots] for a in arrays]
|
|
|
|
chname_specsig = "SARES11-SPEC125-M2.projection_signal"
|
|
chname_specback = "SARES11-SPEC125-M2.projection_background"
|
|
chname_i0 = "SLAAR11-LSCP1-FNS:CH5:VAL_GET"
|
|
#chname_events = "SAR-CVME-TIFALL4:EvtSet"
|
|
chname_pids = "SATCB01-RLLE-STA:MASTER-EVRPULSEID"
|
|
|
|
# create channel
|
|
ch_spec1 = BS(chname_specsig)
|
|
ch_back1 = BS(chname_specback)
|
|
ch_i0 = BS(chname_i0)
|
|
ch_pids = BS(chname_pids)
|
|
|
|
n = 200
|
|
sigs1 = np.empty((n, 2048))
|
|
backs1 = np.empty((n, 2048))
|
|
i0s = np.empty(n)
|
|
pids = np.empty(n)
|
|
|
|
# create the empty plot
|
|
pd = plt.plot([0])
|
|
|
|
# some plot settings
|
|
plt.fig.set_figheight(6)
|
|
plt.fig.set_figwidth(7)
|
|
|
|
for counter, data in zip(plt.show(), bsstream):
|
|
print(counter)
|
|
|
|
for i in range(n):
|
|
sigs1[i] = ch_spec1.get()
|
|
backs1[i] = ch_back1.get()
|
|
i0s[i] = ch_i0.get()
|
|
pids[i] = int(ch_pids.get())
|
|
next(bsstream) # this gets the next set of data
|
|
|
|
pumpi0s, pumpsigs, pumpbacks = pumpedshots(pids, i0s, sigs1, backs1)
|
|
unpumpi0s, unpumpsigs, unpumpbacks = unpumpedshots(pids, i0s, sigs1, backs1)
|
|
|
|
diffa = np.mean((pumpsigs - pumpbacks), axis=0) / np.mean((unpumpsigs - unpumpbacks), axis=0)
|
|
|
|
plt.tight_layout()
|
|
plt.clf()
|
|
plt.xlim(450, 650)
|
|
plt.ylim(-0.05, 0.05)
|
|
plt.plot(wav, -np.log10(diffa))
|
|
plt.show()
|
|
|
|
bsstream.close()
|