def test_multiproc_large_data(self) -> None: self.pipeline.set_attribute('config', 'MEMORY', 1000, static=True) self.pipeline.set_attribute('config', 'CPU', 1, static=True) module = LineSubtractionModule(name_in='subtract_single', image_in_tag='large_data', image_out_tag='im_sub_single', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract_single') self.pipeline.set_attribute('config', 'CPU', 4, static=True) module = LineSubtractionModule(name_in='subtract_multi', image_in_tag='large_data', image_out_tag='im_sub_multi', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract_multi') data_single = self.pipeline.get_data('im_sub_single') data_multi = self.pipeline.get_data('im_sub_multi') assert np.allclose(data_single, data_multi, rtol=limit, atol=0.) assert data_single.shape == data_multi.shape
def test_apply_function(self) -> None: self.pipeline.set_attribute('config', 'MEMORY', 20, static=True) self.pipeline.set_attribute('config', 'CPU', 4, static=True) module = LineSubtractionModule(name_in='subtract', image_in_tag='images', image_out_tag='im_subtract', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract') data = self.pipeline.get_data('images') assert np.allclose(np.mean(data), 1.9545313398209947e-06, rtol=limit, atol=0.) assert data.shape == (100, 10, 10) data = self.pipeline.get_data('im_subtract') assert np.allclose(np.mean(data), 5.529431079676073e-22, rtol=limit, atol=0.) assert data.shape == (100, 10, 10)
def test_apply_function(self) -> None: self.pipeline.set_attribute('config', 'MEMORY', 20, static=True) self.pipeline.set_attribute('config', 'CPU', 4, static=True) module = LineSubtractionModule(name_in='subtract', image_in_tag='images', image_out_tag='im_subtract', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract') data = self.pipeline.get_data('images') assert np.mean(data) == pytest.approx(1.1824138000882435e-05, rel=self.limit, abs=0.) assert data.shape == (5, 11, 11) data = self.pipeline.get_data('im_subtract') assert np.mean(data) == pytest.approx(-1.2544487946113274e-21, rel=self.limit, abs=0.) assert data.shape == (5, 11, 11)
def test_line_background_median(self) -> None: module = LineSubtractionModule(name_in='line2', image_in_tag='science', image_out_tag='science_line2', combine='median', mask=0.1) self.pipeline.add_module(module) self.pipeline.run_module('line2') data = self.pipeline.get_data('science_line2') assert np.sum(data) == pytest.approx(106.09825573198366, rel=self.limit, abs=0.) assert data.shape == (10, 11, 11)
def test_apply_function_same_port(self) -> None: module = LineSubtractionModule(name_in='subtract_same', image_in_tag='im_subtract', image_out_tag='im_subtract', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract_same') data = self.pipeline.get_data('im_subtract') assert np.mean(data) == pytest.approx(-1.4336557652700885e-21, rel=self.limit, abs=0.) assert data.shape == (5, 11, 11)
def test_apply_function_same_port(self) -> None: module = LineSubtractionModule(name_in='subtract_same', image_in_tag='im_subtract', image_out_tag='im_subtract', combine='mean', mask=None) self.pipeline.add_module(module) self.pipeline.run_module('subtract_same') data = self.pipeline.get_data('im_subtract') assert np.allclose(np.mean(data), 7.318364664277155e-22, rtol=limit, atol=0.) assert data.shape == (100, 10, 10)
def test_line_background_median(self): module = LineSubtractionModule(name_in='line2', image_in_tag='line', image_out_tag='line_median', combine='median', mask=0.1) self.pipeline.add_module(module) self.pipeline.run_module('line2') data = self.pipeline.get_data('line_median') assert np.allclose(data[0, 10, 10], 0.09782789699611127, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.0024723022374338196, rtol=limit, atol=0.) assert data.shape == (16, 20, 20)
def test_line_background_mean(self): module = LineSubtractionModule(name_in='line1', image_in_tag='line', image_out_tag='line_mean', combine='mean', mask=0.1) self.pipeline.add_module(module) self.pipeline.run_module('line1') data = self.pipeline.get_data('line_mean') assert np.allclose(data[0, 10, 10], 0.09792388324443534, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.0024245904637616735, rtol=limit, atol=0.) assert data.shape == (16, 20, 20)