#!/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') def pumpedshots(events, *arrays): 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] #chname_diode = "SLAAR11-LSCP1-FNS:CH0:VAL_GET" #chname_diode1 = "SARES11-GES1:CH1_VAL_GET" chname_diode1 = "SARES12-GES1:PR1_CH2_VAL_GET" chname_i0 = "SAROP11-PBPS110:INTENSITY" chname_events = "SAR-CVME-TIFALL4:EvtSet" length = 500 # create channel ch_diode1 = BS(chname_diode1) ch_i0 = BS(chname_i0) ch_events = BS(chname_events) n = 200 sigs1 = np.empty(n) i0s = np.empty(n) evts = np.empty((n, 256)) # 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_diode1.get() i0s[i] = ch_i0.get() evts[i] = ch_events.get() next(bsstream) # this gets the next set of data pearscoeff1, _ = pearsonr(i0s, sigs1) pumpi0s, pumpsigs = pumpedshots(evts, i0s, sigs1) #xs = np.arange(len(pp_sigs)) plt.tight_layout() plt.clf() plt.scatter(i0s, sigs1) plt.scatter(pumpi0s, pumpsigs) plt.title("{}".format(round(pearscoeff1, 4))) plt.xlabel('sarop11-pbps110:intensity') plt.ylabel('tfy, sares11-ges1:ch1_val_get') plt.show() bsstream.close()