def test_reshape(self): FRAMES = 60 SHAPE = (5, 4, 3) # Generate a single file with 100 2048x1536 frames print("Creating raw files...") generate_raw_files("raw", FRAMES, 1, 1, 2048, 1536) print("Creating VDS...") gen = ReshapeVDSGenerator(shape=SHAPE, path="./", files=["raw_0.h5"], output="reshaped.h5", log_level=1) gen.generate_vds() self._validate_reshape(FRAMES)
def test_interleave(self): FRAMES = 95 WIDTH = 2048 HEIGHT = 1536 # Generate 4 raw files with interspersed frames # 95 2048x1536 frames, between 4 files in blocks of 10 print("Creating raw files...") generate_raw_files("OD", FRAMES, 4, 10, WIDTH, HEIGHT, "test_data") print("Creating VDS...") gen = InterleaveVDSGenerator("./", prefix="OD_", block_size=10, log_level=1, source_node="test_data") gen.generate_vds() self._validate_interleave(FRAMES, HEIGHT, WIDTH)
def test_sub_frames(self): FRAMES = 1 WIDTH = 2048 HEIGHT = 256 FEMS = 6 CHIPS = 8 # Generate 6 raw files each with 1/6th of a single 2048x1536 frame print("Creating raw files...") generate_raw_files("stripe", FEMS * FRAMES, FEMS, 1, WIDTH, HEIGHT) print("Creating VDS...") gen = SubFrameVDSGenerator("./", prefix="stripe_", stripe_spacing=3, module_spacing=123, log_level=1) gen.generate_vds() self._validate_sub_frames(FRAMES, WIDTH, FEMS, CHIPS)
def test_interleave_empty(self): FRAMES = 95 WIDTH = 2048 HEIGHT = 1536 print("Creating VDS...") gen = InterleaveVDSGenerator( "./", files=["OD_0.h5", "OD_1.h5", "OD_2.h5", "OD_3.h5"], source=dict(shape=((30, 25, 20, 20), HEIGHT, WIDTH), dtype="float32"), block_size=10, log_level=1) gen.generate_vds() # Generate 4 raw files with interspersed frames # 95 2048x1536 frames, between 4 files in blocks of 10 print("Creating raw files...") generate_raw_files("OD", FRAMES, 4, 10, WIDTH, HEIGHT) self._validate_interleave(FRAMES, HEIGHT, WIDTH)
def test_reshape_empty(self): FRAMES = 60 SHAPE = (5, 4, 3) WIDTH = 2048 HEIGHT = 1536 print("Creating VDS...") gen = ReshapeVDSGenerator(shape=SHAPE, path="./", files=["raw_0.h5"], source=dict(shape=(FRAMES, HEIGHT, WIDTH), dtype="float32"), output="reshaped.h5", log_level=1) gen.generate_vds() # Generate a single file with 100 2048x1536 frames print("Creating raw files...") generate_raw_files("raw", FRAMES, 1, 1, 2048, 1536) self._validate_reshape(FRAMES)
def test_gap_fill(self): FEMS = 6 CHIPS = 8 FRAMES = 100 HEIGHT = 1536 WIDTH = 2048 # Generate a single file with 100 2048x1536 frames print("Creating raw files...") generate_raw_files("raw", FRAMES, 1, 1, WIDTH, HEIGHT) print("Creating VDS...") gen = ExcaliburGapFillVDSGenerator("./", files=["raw_0.h5"], chip_spacing=3, module_spacing=123, modules=3, output="gaps.h5", log_level=1) gen.generate_vds() self._validate_gap_fill(FEMS, CHIPS)
def test_reshape_alternate(self): FRAMES = 12 SHAPE = (4, 3) # Generate a single file with 100 2048x1536 frames print("Creating raw files...") generate_raw_files("raw", FRAMES, 1, 1, 2048, 1536) print("Creating VDS...") gen = ReshapeVDSGenerator(shape=SHAPE, path="./", files=["raw_0.h5"], output="reshaped.h5", log_level=1, alternate=(False, True)) gen.generate_vds() test_dataset = np.array( [0., 1., 2., 5., 4., 3., 6., 7., 8., 11., 10., 9.]) with h5.File("reshaped.h5", mode="r") as h5_file: vds_dataset = h5_file["data"] print("Verifying dataset...") np.testing.assert_array_equal(test_dataset, vds_dataset[:, :, 0, 0].flatten())
def test_sub_frames_empty(self): FRAMES = 1 WIDTH = 2048 HEIGHT = 256 FEMS = 6 CHIPS = 8 print("Creating VDS...") gen = SubFrameVDSGenerator("./", files=[ "stripe_0.h5", "stripe_1.h5", "stripe_2.h5", "stripe_3.h5", "stripe_4.h5", "stripe_5.h5" ], source=dict(shape=(FRAMES, HEIGHT, WIDTH), dtype="float32"), stripe_spacing=3, module_spacing=123, log_level=1) gen.generate_vds() # Generate 6 raw files each with 1/6th of a single 2048x1536 frame print("Creating raw files...") generate_raw_files("stripe", FEMS * FRAMES, FEMS, 1, WIDTH, HEIGHT) self._validate_sub_frames(FRAMES, WIDTH, FEMS, CHIPS)