def test_remove_lines(self) -> None: module = RemoveLinesModule(lines=(2, 5, 0, 3), name_in='remove', image_in_tag='read', image_out_tag='remove') self.pipeline.add_module(module) self.pipeline.run_module('remove') data = self.pipeline.get_data('remove') assert np.sum(data) == pytest.approx(67.49726677462391, rel=self.limit, abs=0.) assert data.shape == (10, 8, 4) with h5py.File(self.test_dir + 'PynPoint_database.hdf5', 'a') as hdf_file: hdf_file['config'].attrs['CPU'] = 4 self.pipeline.run_module('remove') data_multi = self.pipeline.get_data('remove') assert data == pytest.approx(data_multi, rel=self.limit, abs=0.) assert data.shape == data_multi.shape
def test_remove_lines(self) -> None: module = RemoveLinesModule(lines=(2, 5, 0, 9), name_in='remove', image_in_tag='read', image_out_tag='remove') self.pipeline.add_module(module) self.pipeline.run_module('remove') data = self.pipeline.get_data('remove') assert np.allclose(data[0, 50, 50], 0.028455980719223083, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.00011848528804183087, rtol=limit, atol=0.) assert data.shape == (40, 91, 93) with h5py.File(self.test_dir + 'PynPoint_database.hdf5', 'a') as hdf_file: hdf_file['config'].attrs['CPU'] = 4 self.pipeline.run_module('remove') data_multi = self.pipeline.get_data('remove') assert np.allclose(data, data_multi, rtol=limit, atol=0.) assert data.shape == data_multi.shape
def test_apply_function_to_images_memory_none(self): remove = RemoveLinesModule(lines=(1, 0, 0, 0), name_in="remove4", image_in_tag="image_3d", image_out_tag="remove_3d_none") self.pipeline.add_module(remove) self.pipeline.run_module("remove4") data = self.pipeline.get_data("remove_3d_none") assert np.allclose(np.mean(data), 1.1477029889801025e-05, rtol=limit, atol=0.) assert data.shape == (4, 10, 9)
def test_remove_lines(self): cutting = RemoveLinesModule(lines=(0, 0, 0, 2), name_in="cut_lines", image_in_tag="im_arr_last", image_out_tag="im_arr_cut") self.pipeline.add_module(cutting) self.pipeline.run_module("cut_lines") data = self.pipeline.get_data("im_arr_cut") assert np.allclose(data[0, 61, 39], -0.00022889163546536875, rtol=limit, atol=0.) assert data.shape == (78, 100, 100)
def test_apply_function_to_images_same_port(self): dark = DarkCalibrationModule(name_in="dark1", image_in_tag="science", dark_in_tag="dark", image_out_tag="science") self.pipeline.add_module(dark) self.pipeline.run_module("dark1") data = self.pipeline.get_data("science") assert np.allclose(np.mean(data), -3.190113568690675e-06, rtol=limit, atol=0.) assert data.shape == (4, 10, 10) self.pipeline.set_attribute("config", "MEMORY", 0, static=True) dark = DarkCalibrationModule(name_in="dark2", image_in_tag="science", dark_in_tag="dark", image_out_tag="science") self.pipeline.add_module(dark) self.pipeline.run_module("dark2") data = self.pipeline.get_data("science") assert np.allclose(np.mean(data), -1.026073475228737e-05, rtol=limit, atol=0.) assert data.shape == (4, 10, 10) remove = RemoveLinesModule(lines=(1, 0, 0, 0), name_in="remove3", image_in_tag="remove_3d", image_out_tag="remove_3d") self.pipeline.add_module(remove) with pytest.raises(ValueError) as error: self.pipeline.run_module("remove3") assert str(error.value) == "Input and output port have the same tag while the input " \ "function is changing the image shape. This is only " \ "possible with MEMORY=None."
def test_apply_function_to_images_same_port(self): dark = DarkCalibrationModule(name_in='dark1', image_in_tag='science', dark_in_tag='dark', image_out_tag='science') self.pipeline.add_module(dark) self.pipeline.run_module('dark1') data = self.pipeline.get_data('science') assert np.allclose(np.mean(data), -3.190113568690675e-06, rtol=limit, atol=0.) assert data.shape == (4, 10, 10) self.pipeline.set_attribute('config', 'MEMORY', 0, static=True) dark = DarkCalibrationModule(name_in='dark2', image_in_tag='science', dark_in_tag='dark', image_out_tag='science') self.pipeline.add_module(dark) self.pipeline.run_module('dark2') data = self.pipeline.get_data('science') assert np.allclose(np.mean(data), -1.026073475228737e-05, rtol=limit, atol=0.) assert data.shape == (4, 10, 10) remove = RemoveLinesModule(lines=(1, 0, 0, 0), name_in='remove3', image_in_tag='remove_3d', image_out_tag='remove_3d') self.pipeline.add_module(remove) with pytest.raises(ValueError) as error: self.pipeline.run_module('remove3') assert str(error.value) == 'Input and output port have the same tag while the input ' \ 'function is changing the image shape. This is only ' \ 'possible with MEMORY=None.'
def test_apply_function_to_images_2d(self): remove = RemoveLinesModule(lines=(1, 0, 0, 0), name_in="remove2", image_in_tag="image_2d", image_out_tag="remove_2d") self.pipeline.add_module(remove) self.pipeline.run_module("remove2") data = self.pipeline.get_data("image_2d") assert np.allclose(np.mean(data), 1.2869483197883442e-05, rtol=limit, atol=0.) assert data.shape == (10, 10) data = self.pipeline.get_data("remove_2d") assert np.allclose(np.mean(data), 1.3957075246029751e-05, rtol=limit, atol=0.) assert data.shape == (10, 9)
def test_apply_function_to_images_3d(self): self.pipeline.set_attribute("config", "MEMORY", 1, static=True) remove = RemoveLinesModule(lines=(1, 0, 0, 0), name_in="remove1", image_in_tag="image_3d", image_out_tag="remove_3d") self.pipeline.add_module(remove) self.pipeline.run_module("remove1") data = self.pipeline.get_data("image_3d") assert np.allclose(np.mean(data), 1.0141852764605783e-05, rtol=limit, atol=0.) assert data.shape == (4, 10, 10) data = self.pipeline.get_data("remove_3d") assert np.allclose(np.mean(data), 1.1477029889801025e-05, rtol=limit, atol=0.) assert data.shape == (4, 10, 9)