added other stuff
This commit is contained in:
954
dioderata/live data analysis.ipynb
Normal file
954
dioderata/live data analysis.ipynb
Normal file
File diff suppressed because one or more lines are too long
47
dioderata/old/main.py
Executable file
47
dioderata/old/main.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from time import sleep
|
||||
from collections import deque
|
||||
import numpy as np
|
||||
import scipy.signal
|
||||
|
||||
from zoetrope import aniplot as plt
|
||||
from bstrd import BS, bsstream
|
||||
plt.blit = False
|
||||
|
||||
# config
|
||||
diode_PV = "SLAAR11-LSCP1-FNS:CH4:VAL_GET"
|
||||
events_PV = "SAR-CVME-TIFALL4:EvtSet"
|
||||
length = 1000
|
||||
|
||||
# create channel
|
||||
diode = BS(diode_PV)
|
||||
events = BS(events_PV)
|
||||
|
||||
# create a buffer for the plotting
|
||||
values = deque(maxlen=length)
|
||||
|
||||
# create the empty plot
|
||||
pd = plt.plot([0])
|
||||
|
||||
# some plot settings
|
||||
plt.suptitle(diode_PV)
|
||||
#plt.fig.set_figheight(12)
|
||||
#plt.fig.set_figwidth(9)
|
||||
plt.tight_layout()
|
||||
|
||||
for counter, data in zip(plt.show(), bsstream):
|
||||
print(counter)
|
||||
|
||||
pp_sig = diode.get()
|
||||
evt_codes = events.get()
|
||||
values.append(pp_sig)
|
||||
|
||||
xs = np.arange(len(values))
|
||||
pd.set(xs, values)
|
||||
|
||||
# this, I need to move into the library
|
||||
pd.ax.relim()
|
||||
pd.ax.autoscale_view()
|
||||
|
||||
bsstream.close()
|
72
dioderata/old/pp_sig.py
Executable file
72
dioderata/old/pp_sig.py
Executable file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from time import sleep
|
||||
from collections import deque
|
||||
import numpy as np
|
||||
import scipy.signal
|
||||
|
||||
from zoetrope import aniplot as plt
|
||||
from bstrd import BS, bsstream
|
||||
plt.blit = False
|
||||
|
||||
def unpumpedXrays(events, *arrays):
|
||||
laser = events[:, 18]
|
||||
darkShot = events[:, 21]
|
||||
background_shots = np.logical_and.reduce((laser, darkShot))
|
||||
return [a[background_shots] for a in arrays]
|
||||
|
||||
def pumpedXrays(events, *arrays):
|
||||
fel = events[:, 13]
|
||||
laser = events[:, 18]
|
||||
darkShot = events[:, 21]
|
||||
pumped_shots = np.logical_and.reduce((laser, np.logical_not(darkShot)))
|
||||
return [a[pumped_shots] for a in arrays]
|
||||
|
||||
|
||||
# config
|
||||
diode_PV = "SLAAR11-LSCP1-FNS:CH4:VAL_GET"
|
||||
events_PV = "SAR-CVME-TIFALL4:EvtSet"
|
||||
length = 1000
|
||||
|
||||
# create channel
|
||||
diode = BS(diode_PV)
|
||||
events = BS(events_PV)
|
||||
sigs = np.empty(10)
|
||||
events = np.empty((10,256))
|
||||
|
||||
# create a buffer for the plotting
|
||||
|
||||
pp_sig = deque(maxlen=length)
|
||||
|
||||
# create the empty plot
|
||||
pd = plt.plot([0])
|
||||
|
||||
# some plot settings
|
||||
plt.suptitle(diode_PV)
|
||||
#plt.fig.set_figheight(12)
|
||||
#plt.fig.set_figwidth(9)
|
||||
plt.tight_layout()
|
||||
|
||||
for counter, data in zip(plt.show(), bsstream):
|
||||
print(counter)
|
||||
|
||||
for i in range(10):
|
||||
diode_sig = diode.get()
|
||||
evt_codes = events.get()
|
||||
sigs.append(pp_sig)
|
||||
evts.append(evt_codes)
|
||||
i += 1
|
||||
|
||||
sig_p = np.mean(pumpedXrays(events, signals))
|
||||
sig_un = np.mean(unpumpedXrays(events, signals))
|
||||
|
||||
pp_sig.append(-np.log10(sig_p/sig_un))
|
||||
|
||||
xs = np.arange(len(pp_sig))
|
||||
pd.set(xs, pp_sig)
|
||||
|
||||
# this, I need to move into the library
|
||||
pd.ax.relim()
|
||||
pd.ax.autoscale_view()
|
||||
|
||||
bsstream.close()
|
77
dioderata/old/pp_sig2.py
Executable file
77
dioderata/old/pp_sig2.py
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from time import sleep
|
||||
from collections import deque
|
||||
import numpy as np
|
||||
import scipy.signal
|
||||
|
||||
from zoetrope import aniplot as plt
|
||||
from bstrd import BS, bsstream
|
||||
plt.blit = False
|
||||
|
||||
|
||||
def unpumpedXrays(events, *arrays):
|
||||
laser = events[:, 18]
|
||||
darkShot = events[:, 21]
|
||||
background_shots = np.logical_and.reduce((laser, darkShot))
|
||||
return [a[background_shots] for a in arrays]
|
||||
|
||||
def pumpedXrays(events, *arrays):
|
||||
fel = events[:, 13]
|
||||
laser = events[:, 18]
|
||||
darkShot = events[:, 21]
|
||||
pumped_shots = np.logical_and.reduce((laser, np.logical_not(darkShot)))
|
||||
return [a[pumped_shots] for a in arrays]
|
||||
|
||||
|
||||
# config
|
||||
chname_diode = "SLAAR11-LSCP1-FNS:CH0:VAL_GET"
|
||||
chname_events = "SAR-CVME-TIFALL4:EvtSet"
|
||||
length = 1000
|
||||
|
||||
# create channel
|
||||
ch_diode = BS(chname_diode)
|
||||
ch_events = BS(chname_events)
|
||||
|
||||
n = 10
|
||||
sigs = np.empty(n)
|
||||
evts = np.empty((n, 256))
|
||||
|
||||
# create a buffer for the plotting
|
||||
pp_sigs = deque(maxlen=length)
|
||||
|
||||
# create the empty plot
|
||||
pd = plt.plot([0])
|
||||
|
||||
# some plot settings
|
||||
plt.suptitle(chname_diode)
|
||||
#plt.fig.set_figheight(12)
|
||||
#plt.fig.set_figwidth(9)
|
||||
plt.tight_layout()
|
||||
|
||||
for counter, data in zip(plt.show(), bsstream):
|
||||
print(counter)
|
||||
|
||||
for i in range(n):
|
||||
evts[i] = ch_events.get()
|
||||
sigs[i] = ch_diode.get()
|
||||
next(bsstream) # this gets the next set of data
|
||||
|
||||
sigs_p = pumpedXrays(evts, sigs)
|
||||
sigs_u = unpumpedXrays(evts, sigs)
|
||||
|
||||
sig_p = np.mean(sigs_p)
|
||||
sig_u = np.mean(sigs_u)
|
||||
|
||||
sig = -np.log10(sig_p/sig_u)
|
||||
|
||||
pp_sigs.append(sig)
|
||||
|
||||
xs = np.arange(len(pp_sigs))
|
||||
pd.set(xs, pp_sigs)
|
||||
|
||||
# this, I need to move into the library
|
||||
pd.ax.relim()
|
||||
pd.ax.autoscale_view()
|
||||
|
||||
bsstream.close()
|
Reference in New Issue
Block a user