def _1d_histogram_tester(binlowhighs, x, weights=1): h = Histogram(binlowhighs) h.fill(x, weights=weights) if np.isscalar(weights): ynp = np.histogram(x, h.edges[0])[0] else: ynp = np.histogram(x, h.edges[0], weights=weights)[0] assert_array_almost_equal(ynp, h.values) h.reset() h._always_use_fillnd = True h.fill(x, weights=weights) assert_array_almost_equal(ynp, h.values)
def _2d_histogram_tester(binlowhighs, x, y, weights=1): h = Histogram(*binlowhighs) h.fill(x, y, weights=weights) if np.isscalar(weights): if np.isscalar(x): assert np.isscalar(y), 'If x is a scalar, y must be also' ynp = np.histogram2d([x], [y], bins=h.edges)[0] else: ynp = np.histogram2d(x, y, bins=h.edges)[0] else: ynp = np.histogram2d(x, y, bins=h.edges, weights=weights)[0] assert_array_almost_equal(ynp, h.values) h.reset() h._always_use_fillnd = True h.fill(x, y, weights=weights) assert_array_almost_equal(ynp, h.values)
# uncomment bellow for two pulse two color jitter correction only !!!! #bot = 0 # first edge of the first energy peak #top = 700 # second edge of the first energy peak #mu,sig = moments(opal_thresh_xproj[bot:top]) #shift = 250 - int(mu) - bot #index = int(mu/10) else: shift = 0 index = 0 #print shift # Hit Histogram hithist.reset() hitjitter.reset() hitseeded.reset() delayhist2d.reset() for hit in c: hithist.fill(float(hit[1] + shift)) hitjitter.fill(float(hit[1])) ############################################################################### ############################ MINI TOF ANALYSIS ################################ # find yield of waveform over certain interval wf_yield = np.sum(minitof_volts[1:401] - minitof_volts[5300:5700]) #choose proper window later # get maximum value of x-ray beam