def test_extract_position(self): module = StarExtractionModule(name_in='extract7', image_in_tag='star', image_out_tag='extract7', index_out_tag=None, image_size=0.4, fwhm_star=0.1, position=(10, 10, 0.1)) self.pipeline.add_module(module) self.pipeline.run_module('extract7') data = self.pipeline.get_data('extract7') assert np.allclose(data[0, 7, 7], 0.09834884212021108, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.004444871536643222, rtol=limit, atol=0.) assert data.shape == (40, 15, 15) attr = self.pipeline.get_attribute('extract7', 'STAR_POSITION', static=False) assert attr[10, 0] == attr[10, 1] == 10
def test_star_extract(self) -> None: module = StarExtractionModule(name_in='extract1', image_in_tag='star', image_out_tag='extract1', index_out_tag='index', image_size=0.2, fwhm_star=0.1, position=None) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract1') assert len(warning) == 3 assert warning[0].message.args[0] == 'Can not store the attribute \'INSTRUMENT\' ' \ 'because the dataset \'index\' does not exist.' data = self.pipeline.get_data('extract1') assert np.sum(data) == pytest.approx(104.93318507061295, rel=self.limit, abs=0.) assert data.shape == (10, 9, 9)
def test_extract_center_none(self): module = StarExtractionModule(name_in='extract2', image_in_tag='star', image_out_tag='extract2', index_out_tag='index', image_size=0.4, fwhm_star=0.1, position=(None, None, 1.)) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract2') assert len(warning) == 1 assert warning[0].message.args[0] == 'The new dataset that is stored under the tag name ' \ '\'index\' is empty.' data = self.pipeline.get_data('extract2') assert np.allclose(data[0, 7, 7], 0.09834884212021108, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.004444871536643222, rtol=limit, atol=0.) assert data.shape == (40, 15, 15) attr = self.pipeline.get_attribute('extract2', 'STAR_POSITION', static=False) assert attr[10, 0] == attr[10, 1] == 10
def test_star_extract(self) -> None: module = StarExtractionModule(name_in='extract1', image_in_tag='dither', image_out_tag='extract1', index_out_tag='index', image_size=1.0, fwhm_star=0.1, position=None) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract1') assert len(warning) == 1 assert warning[0].message.args[0] == 'The new dataset that is stored under the tag name ' \ '\'index\' is empty.' data = self.pipeline.get_data('extract1') assert np.allclose(data[0, 19, 19], 0.09812948027289994, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.0006578482216906739, rtol=limit, atol=0.) assert data.shape == (40, 39, 39) attr = self.pipeline.get_attribute('extract1', 'STAR_POSITION', static=False) assert attr[10, 0] == attr[10, 1] == 75
def test_star_extract(self) -> None: module = StarExtractionModule(name_in='extract1', image_in_tag='star', image_out_tag='extract1', index_out_tag='index', image_size=0.2, fwhm_star=0.1, position=None) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract1') assert len(warning) == 1 assert warning[0].message.args[0] == 'The new dataset that is stored under the tag name ' \ '\'index\' is empty.' data = self.pipeline.get_data('extract1') assert np.sum(data) == pytest.approx(104.93318507061295, rel=self.limit, abs=0.) assert data.shape == (10, 9, 9) attr = self.pipeline.get_attribute('extract1', 'STAR_POSITION', static=False) assert np.sum(attr) == pytest.approx(100, rel=self.limit, abs=0.) assert attr.shape == (10, 2)
def test_star_extract_cpu(self) -> None: with h5py.File(self.test_dir+'PynPoint_database.hdf5', 'a') as hdf_file: hdf_file['config'].attrs['CPU'] = 4 module = StarExtractionModule(name_in='extract4', image_in_tag='star', image_out_tag='extract4', index_out_tag='index', image_size=0.2, fwhm_star=0.1, position=(2, 2, 0.05)) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract4') assert len(warning) == 2 assert warning[0].message.args[0] == 'The \'index_out_port\' can only be used if ' \ 'CPU = 1. No data will be stored to this output port.' assert warning[1].message.args[0] == 'Chosen image size is too large to crop the image ' \ 'around the brightest pixel (image index = 0, ' \ 'pixel [x, y] = [2, 2]). Using the center of the ' \ 'image instead.'
def test_extract_too_large(self) -> None: module = StarExtractionModule(name_in='extract3', image_in_tag='star', image_out_tag='extract3', index_out_tag=None, image_size=0.2, fwhm_star=0.1, position=(2, 2, 0.05)) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract3') assert len(warning) == 10 assert warning[0].message.args[0] == f'Chosen image size is too large to crop the image ' \ f'around the brightest pixel (image index = 0, ' \ f'pixel [x, y] = [2, 2]). Using the center of ' \ f'the image instead.' data = self.pipeline.get_data('extract3') assert np.sum(data) == pytest.approx(104.93318507061295, rel=self.limit, abs=0.) assert data.shape == (10, 9, 9)
def test_extract_position(self) -> None: module = StarExtractionModule(name_in='extract7', image_in_tag='star', image_out_tag='extract7', index_out_tag=None, image_size=0.2, fwhm_star=0.1, position=(5, 5, 0.2)) self.pipeline.add_module(module) self.pipeline.run_module('extract7') data = self.pipeline.get_data('extract7') assert np.sum(data) == pytest.approx(104.93318507061295, rel=self.limit, abs=0.) assert data.shape == (10, 9, 9)
def test_apply_function_to_images_memory_none(self) -> None: module = StarExtractionModule(name_in='extract', image_in_tag='im_subtract', image_out_tag='extract', index_out_tag=None, image_size=0.5, fwhm_star=0.1, position=(None, None, 0.1)) self.pipeline.add_module(module) self.pipeline.run_module('extract') data = self.pipeline.get_data('extract') assert np.mean(data) == pytest.approx(1.8259937251367536e-05, rel=self.limit, abs=0.) assert data.shape == (5, 5, 5)
def test_apply_function_to_images_memory_none(self) -> None: module = StarExtractionModule(name_in='extract', image_in_tag='im_subtract', image_out_tag='extract', index_out_tag=None, image_size=0.5, fwhm_star=0.1, position=(None, None, 0.1)) self.pipeline.add_module(module) self.pipeline.run_module('extract') data = self.pipeline.get_data('extract') assert np.allclose(np.mean(data), 1.5591859111937413e-07, rtol=limit, atol=0.) assert data.shape == (100, 5, 5)
def test_extract_too_large(self): module = StarExtractionModule(name_in='extract3', image_in_tag='star', image_out_tag='extract3', index_out_tag=None, image_size=0.8, fwhm_star=0.1, position=None) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract3') assert len(warning) == 40 for i, item in enumerate(warning): assert item.message.args[0] == f'Chosen image size is too large to crop the image ' \ f'around the brightest pixel (image index = {i}, ' \ f'pixel [x, y] = [10, 10]). Using the center of ' \ f'the image instead.' data = self.pipeline.get_data('extract3') assert np.allclose(data[0, 0, 0], 0.09834884212021108, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 0.0004499242959139202, rtol=limit, atol=0.) assert data.shape == (40, 31, 31) attr = self.pipeline.get_attribute('extract3', 'STAR_POSITION', static=False) assert attr[10, 0] == attr[10, 1] == 25
def test_star_extract_cpu(self): with h5py.File(self.test_dir + 'PynPoint_database.hdf5', 'a') as hdf_file: hdf_file['config'].attrs['CPU'] = 4 module = StarExtractionModule(name_in='extract4', image_in_tag='star', image_out_tag='extract4', index_out_tag='index', image_size=0.8, fwhm_star=0.1, position=None) self.pipeline.add_module(module) with pytest.warns(UserWarning) as warning: self.pipeline.run_module('extract4') assert len(warning) == 1 assert warning[0].message.args[0] == 'Chosen image size is too large to crop the image ' \ 'around the brightest pixel. Using the center of ' \ 'the image instead.'