def __init__(self, trainStep=1): self.t_start = time.time() self.t_start_loop = self.t_start self.for_loop_step_dur = 0 self.n = -1 self.freq_avg = 0 self.dt_avg = 0 self.trainId = 0 self.trainId_old = -1 self.skip_count = 0 self.trainStep = trainStep self.dt_buffer = online.DataBuffer(20)
#TOF_dmap_opt = rasterize(TOF_dmap) TOF_dmap_opt = TOF_dmap_opt.opts(width=width, height=height, ylim=ylim, xlim=xlim, logz=logz, title=title, colorbar=True, cmap='Plasma') #TOF_dmap_opt = datashade(TOF_dmap, streams=[PlotSize, RangeXY], dynamic=True) return hv_to_bokeh_obj(TOF_dmap_opt), TOF_dmap_opt # Data buffers for live stream buffer_length = 300 _SQSbuffer__TOF_integral = online.DataBuffer(buffer_length) _SQSbuffer__TOF_height = online.DataBuffer(buffer_length) _SQSbuffer__GMD_history = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_integral = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_hits = online.DataBuffer(5) _SQSbuffer__pnCCD_mean_helper = online.DataBuffer(100) _SQSbuffer__pnCCD_mean_helper_2 = online.DataBuffer(20) _SQSbuffer__pnCCD_hits_tids = online.DataBuffer(5) _SQSbuffer__pnCCD_hitrate_helper = online.DataBuffer(300) _SQSbuffer__pnCCD_hitrate = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_hitrate_helper_2 = online.DataBuffer(300) _SQSbuffer__pnCCD_hitrate_2 = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_hits__last_hit = online.DataBuffer(1) _SQSbuffer__TOF_hits__last_hit = online.DataBuffer(1) _SQSbuffer__trainId__last_hit = online.DataBuffer(1) _SQSbuffer__pnCCD_hits__pnccdDetect__last_hit = online.DataBuffer(5)
title=title, colorbar=True)) def start_stop_dataThread(): global makeBigData_stop if not makeBigData_stop: makeBigData_stop = True else: thread.start() # Data buffers for live stream buffer_len = 1500 _SQSbuffer__TOF_integral = online.DataBuffer(buffer_len) _SQSbuffer__TOF_integral_1 = online.DataBuffer(buffer_len) _SQSbuffer__TOF_integral_2 = online.DataBuffer(buffer_len) _SQSbuffer__TOF_integral_3 = online.DataBuffer(buffer_len) _SQSbuffer__TOF_avg = online.DataBuffer(100) _SQSbuffer__TOF_hit_trace = online.DataBuffer(1) _SQSbuffer__TOF_hits = online.DataBuffer(1000) _SQSbuffer__GMD_history = online.DataBuffer(buffer_len) _SQSbuffer__TOF_hits = online.DataBuffer(10) _SQSbuffer__counter = online.DataBuffer(buffer_len) print("...2") # Data pipes and buffers for plots ## pipes provide a full update of data to the underlying object eg. plot ## buffers add only a single value to the plot and may kick one out when number of elements in the buffer has reached the length/size of the buffer _pipe__TOF_single = Pipe(data=[])
if (-np.min(d['tof']) > tof_hit_threshold): bestTof(d['tof']) bestTofFig.plotTofBuffer(bestTof) tofIntPlot.setData(np.asarray(tofInt)) # plot tof trace integral buffer tofHeightPlot.setData(np.asarray(tofHeight)) # plot tof trace height buffer hitBufPlot.setData(np.asarray(hitBuf)) # plot tof hitrate buffer ## Process Events pg.QtGui.QApplication.processEvents() # make sure it displays return d # Setup plots and Buffers ## Hit rate tofBuffer = tools.DataBuffer(100) # a buffer to store tof traces for hitrate determination hitBuf = online.DataBuffer(10000) # a buffer to store the actual hitrates hitWin = win = pg.GraphicsWindow() # a window for the hitrates hitBufPlot = hitWin.addPlot(title='Hitrate in % - hit threshold (height): {}'.format(tof_hit_threshold)).plot() # a plot for the hitrates ## Trace of the last found Hit bestTof = tools.DataBuffer(1) #a buffer to store the brightest bestTofFig = online.TofBufferPlotter(1, title='Last hit ToF - hit threshold (height): {}'.format(tof_hit_threshold)) ## a histogram for tof heights lowestTof = online.HistogramPlotter(0, 4000, 100, title='ToF heights - Histogram') # from 0 to 4000 with 100 bins ## most recent full integrals of tof data tofInt = online.DataBuffer(1000) intWin = win = pg.GraphicsWindow() tofIntPlot = intWin.addPlot(title='Recent ToF Integrals').plot()
def pnCCDData_plot(pipe_or_buffer, width=500, height=500,ylim=(-0.5,0.5),xlim=(-0.5,0.5), title=None): TOF_dmap = hv.DynamicMap(hv.Image, streams=[pipe_or_buffer]) #TOF_dmap_opt = rasterize(TOF_dmap) TOF_dmap_opt = datashade(TOF_dmap, streams=[PlotSize, RangeXY], dynamic=True) return hv_to_bokeh_obj( TOF_dmap_opt.opts(width=width,height=height,ylim=ylim,xlim=xlim, title = title) ) def start_stop_dataThread(): global makeBigData_stop if not makeBigData_stop: makeBigData_stop = True else: thread.start() # Data buffers for live stream _SQSbuffer__TOF_integral = online.DataBuffer(100) _SQSbuffer__GMD_history = online.DataBuffer(100) _SQSbuffer__pnCCD_integral = online.DataBuffer(100) _SQSbuffer__pnCCD_hits = online.DataBuffer(10) for k in range(5): _SQSbuffer__pnCCD_hits(np.zeros(shape=(1024,1024))) _SQSbuffer__counter = online.DataBuffer(100) print("...2") # Data pipes and buffers for plots ## pipes provide a full update of data to the underlying object eg. plot ## buffers add only a single value to the plot and may kick one out when number of elements in the buffer has reached the length/size of the buffer _pipe__TOF_single = Pipe(data=[]) #_buffer__TOF_integral = Buffer(pd.DataFrame({'x':[],'y':[]}, columns=['x','y']), length=100, index=False) _pipe__TOF_integral = Pipe(data=[]) _pipe__pnCCD_single = Pipe(data=[])
def start_stop_dataThread(): #print("~~~~~~~~~~~~~~~~ ATTEMPT STOPPING THREAD") #~ thread.end() print("Attempt Clear PNCCD MEAN BUFFER") _SQSbuffer__pnCCD_mean_helper = online.DataBuffer(100) print(_SQSbuffer__pnCCD_mean_helper.length)
return hv_to_bokeh_obj(TOF_dmap_opt), TOF_dmap_opt def start_stop_dataThread(): #print("~~~~~~~~~~~~~~~~ ATTEMPT STOPPING THREAD") #~ thread.end() print("Attempt Clear PNCCD MEAN BUFFER") _SQSbuffer__pnCCD_mean_helper = online.DataBuffer(100) print(_SQSbuffer__pnCCD_mean_helper.length) # Data buffers for live stream buffer_length = 1500 mean_1_length = 10 mean_2_length = 20 _SQSbuffer__GMD_history = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_integral = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_1_integral = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_2_integral = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_integral_proc = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_1_integral_proc = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_1_integral_proc_top = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_1_integral_proc_bottom = online.DataBuffer( buffer_length) _SQSbuffer__pnCCD_mean_1_integral_proc_right = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_1_integral_proc_left = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_2_integral_proc = online.DataBuffer(buffer_length) _SQSbuffer__pnCCD_mean_helper_1 = online.DataBuffer(mean_1_length) _SQSbuffer__pnCCD_mean_helper_2 = online.DataBuffer(mean_2_length) _SQSbuffer__xgm_mean_helper_1 = online.DataBuffer(mean_1_length) _SQSbuffer__xgm_mean_helper_2 = online.DataBuffer(mean_2_length)