def test_process_event_stream(self): x_bins = np.array([60.5, -60.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) frames = event.framebins_to_frames(np.linspace(0, 24000, 7)) detector, fbins = event.process_event_stream(self.event_list, frames, t_bins, y_bins, x_bins) assert_equal(detector[0, 382, 97, 0], 70) assert_equal(detector[1, 383, 97, 0], 64) assert_equal(detector[4, 377, 98, 0], 57) x_bins = np.array([210.5, -210.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) frames = [[6, 10]] detector, fbins = event.process_event_stream(self.event_list, frames, t_bins, y_bins, x_bins) assert_equal(np.sum(detector.ravel()), 167)
def test_monobloc_events(self, event_setup): # the event file changed when the ILL monobloc detector was installed pth = pjoin(event_setup.data_directory, "reduce") event_file_path = pjoin(pth, "DAQ_2019-11-25T12-25-07", "DATASET_0", "EOS.bin") data = event.events(event_file_path) f, t, y, x = data[0] assert len(t) == 71223 x_bins = np.array([2.5, 28.5]) y_bins = np.linspace(-0.5, 1023.5, 1025) t_bins = np.linspace(0, 40000, 1001) frames = [np.arange(0, 57599, 1)] detector, fbins = event.process_event_stream(data[0], frames, t_bins, y_bins, x_bins) detector = np.squeeze(detector) with h5py.File(pjoin(pth, "PLP0046853.nx.hdf"), "r") as g: det = np.copy(g["entry1/data/hmm"]) det = np.squeeze(det) assert det.shape == (1000, 1024) assert_equal(np.sum(detector, 1), np.sum(det, 1))
def test_process_event_stream(self): x_bins = np.array([60.5, -60.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) frames = event.framebins_to_frames(np.linspace(0, 24000, 7)) detector, fbins = event.process_event_stream(self.event_list, frames, t_bins, y_bins, x_bins) assert_equal(detector[0, 300, 97, 0], 7) assert_equal(detector[1, 402, 93, 0], 1) assert_equal(detector[4, 509, 97, 0], 5) x_bins = np.array([210.5, -210.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) frames = [[6, 10, 12, 1000, 1001, 1002, 1003]] detector, fbins = event.process_event_stream(self.event_list, frames, t_bins, y_bins, x_bins) assert_equal(np.sum(detector.ravel()), 11)
def test_process_event_stream(self): x_bins = np.array([60.5, -60.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) f_bins = np.linspace(0, 24000, 7) detector, fbins = event.process_event_stream(self.event_list, f_bins, t_bins, y_bins, x_bins) assert_equal(detector[0, 382, 97, 0], 70) assert_equal(detector[1, 383, 97, 0], 64) assert_equal(detector[4, 377, 98, 0], 57) # now see what happens if we go too far with the frame_bins f_bins = [0, 24000, 30000] detector, fbins = event.process_event_stream(self.event_list, f_bins, t_bins, y_bins, x_bins) assert_equal(np.size(detector, 0), 1)
def test_process_event_stream(self): x_bins = np.array([60.5, -60.5]) y_bins = np.linspace(110.5, -110.5, 222) t_bins = np.linspace(0, 50000, 1001) f_bins = np.linspace(0, 24000, 7) detector, fbins = event.process_event_stream(self.event_list, f_bins, t_bins, y_bins, x_bins) assert_equal(detector[0, 382, 97, 0], 70) assert_equal(detector[1, 383, 97, 0], 64) assert_equal(detector[4, 377, 98, 0], 57)
def test_event_same_as_detector(self): # the detector file should be the same as the event file orig_file = PlatypusNexus(os.path.join(self.path, 'PLP0011613.nx.hdf')) orig_det = orig_file.cat.detector event_det, fb = event.process_event_stream(self.event_list, [0, 23998], orig_file.cat.t_bins, orig_file.cat.y_bins, orig_file.cat.x_bins) assert_equal(event_det, orig_det) # PlatypusNexus.process_event_stream should be the same as well fb, det, bm = orig_file.process_event_stream(frame_bins=[]) assert_equal(event_det, orig_det)
def test_event_same_as_detector(self): # the detector file should be the same as the event file orig_file = PlatypusNexus(os.path.join(self.path, 'PLP0011613.nx.hdf')) orig_det = orig_file.cat.detector frames = [np.arange(0, 23999)] event_det, fb = event.process_event_stream(self.event_list, frames, orig_file.cat.t_bins, orig_file.cat.y_bins, orig_file.cat.x_bins) assert_equal(event_det, orig_det) # PlatypusNexus.process_event_stream should be the same as well det, fc, bm = orig_file.process_event_stream(frame_bins=[]) assert_equal(det, orig_det)
def test_event_same_as_detector(self): # the detector file should be the same as the event file # warnings filter for pixel size with warnings.catch_warnings(): warnings.simplefilter('ignore', RuntimeWarning) orig_file = PlatypusNexus( os.path.join(self.path, 'PLP0011641.nx.hdf')) orig_det = orig_file.cat.detector frames = [np.arange(0, 501744)] event_det, fb = event.process_event_stream(self.event_list, frames, orig_file.cat.t_bins, orig_file.cat.y_bins, orig_file.cat.x_bins) assert_equal(event_det, orig_det) # PlatypusNexus.process_event_stream should be the same as well det, fc, bm = orig_file.process_event_stream(frame_bins=[]) assert_equal(det, orig_det)
def test_event_same_as_detector(self, event_setup): # the detector file should be the same as the event file # warnings filter for pixel size pth = pjoin(event_setup.data_directory, "reduce") with warnings.catch_warnings(): warnings.simplefilter("ignore", RuntimeWarning) orig_file = PlatypusNexus(pjoin(pth, "PLP0011641.nx.hdf")) orig_det = orig_file.cat.detector frames = [np.arange(0, 501744)] event_det, fb = event.process_event_stream( event_setup.event_list, frames, orig_file.cat.t_bins, orig_file.cat.y_bins, orig_file.cat.x_bins, ) assert_equal(event_det, orig_det) # PlatypusNexus.process_event_stream should be the same as well det, fc, bm = orig_file.process_event_stream(frame_bins=[]) assert_equal(det, orig_det)