Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_psf_subtraction_ref_no_mean_mask(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_ref_no_mean_mask',
images_in_tag='science_prep',
reference_in_tag='reference_prep',
res_mean_tag='res_mean_ref_no_mean_mask',
res_median_tag=None,
res_weighted_tag=None,
res_rot_mean_clip_tag=None,
res_arr_out_tag=None,
basis_out_tag='basis_ref_no_mean_mask',
extra_rot=0.,
subtract_mean=False)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_ref_no_mean_mask')
data = self.pipeline.get_data('res_mean_ref_no_mean_mask')
def test_psf_subtraction_no_mean(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_no_mean',
images_in_tag='science',
reference_in_tag='science',
res_mean_tag='res_mean_no_mean',
res_median_tag=None,
res_weighted_tag=None,
res_rot_mean_clip_tag=None,
res_arr_out_tag=None,
basis_out_tag='basis_no_mean',
extra_rot=0.,
subtract_mean=False)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_no_mean')
data = self.pipeline.get_data('res_mean_no_mean')
def test_psf_subtraction_pca_single_mask(self) -> None:
pca = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_single_mask',
images_in_tag='science_prep',
reference_in_tag='science_prep',
res_mean_tag='res_mean_single_mask',
res_median_tag='res_median_single_mask',
res_weighted_tag='res_weighted_single_mask',
res_rot_mean_clip_tag='res_clip_single_mask',
res_arr_out_tag='res_arr_single_mask',
basis_out_tag='basis_single_mask',
extra_rot=45.,
subtract_mean=True)
self.pipeline.add_module(pca)
self.pipeline.run_module('pca_single_mask')
data = self.pipeline.get_data('res_mean_single_mask')
def test_psf_subtraction_pca_single(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_single',
images_in_tag='science',
reference_in_tag='science',
res_mean_tag='res_mean_single',
res_median_tag='res_median_single',
res_weighted_tag='res_weighted_single',
res_rot_mean_clip_tag='res_clip_single',
res_arr_out_tag='res_arr_single',
basis_out_tag='basis_single',
extra_rot=45.,
subtract_mean=True)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_single')
data = self.pipeline.get_data('res_mean_single')
def test_psf_subtraction_ref_no_mean(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_ref_no_mean',
images_in_tag='science',
reference_in_tag='reference',
res_mean_tag='res_mean_ref_no_mean',
res_median_tag=None,
res_weighted_tag=None,
res_rot_mean_clip_tag=None,
res_arr_out_tag=None,
basis_out_tag='basis_ref_no_mean',
extra_rot=0.,
subtract_mean=False)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_ref_no_mean')
data = self.pipeline.get_data('res_mean_ref_no_mean')
def test_psf_subtraction_pca_multi_mask(self) -> None:
database = h5py.File(self.test_dir+'PynPoint_database.hdf5', 'a')
database['config'].attrs['CPU'] = 4
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_multi_mask',
images_in_tag='science_prep',
reference_in_tag='science_prep',
res_mean_tag='res_mean_multi_mask',
res_median_tag='res_median_multi_mask',
res_weighted_tag='res_weighted_multi_mask',
res_rot_mean_clip_tag='res_clip_multi_mask',
res_arr_out_tag=None,
basis_out_tag='basis_multi_mask',
extra_rot=45.,
subtract_mean=True)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_multi_mask')
data_single = self.pipeline.get_data('res_mean_single_mask')
def test_psf_subtraction_no_mean_mask(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_no_mean_mask',
images_in_tag='science_prep',
reference_in_tag='science_prep',
res_mean_tag='res_mean_no_mean_mask',
res_median_tag=None,
res_weighted_tag=None,
res_rot_mean_clip_tag=None,
res_arr_out_tag=None,
basis_out_tag='basis_no_mean_mask',
extra_rot=0.,
subtract_mean=False)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_no_mean_mask')
data = self.pipeline.get_data('res_mean_no_mean_mask')
def test_psf_subtraction_ref_mask(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=range(1, 3),
name_in='pca_ref_mask',
images_in_tag='science_prep',
reference_in_tag='reference_prep',
res_mean_tag='res_mean_ref_mask',
res_median_tag=None,
res_weighted_tag=None,
res_rot_mean_clip_tag=None,
res_arr_out_tag=None,
basis_out_tag='basis_ref_mask',
extra_rot=0.,
subtract_mean=True)
self.pipeline.add_module(module)
self.pipeline.run_module('pca_ref_mask')
data = self.pipeline.get_data('res_mean_ref_mask')
def test_psf_subtraction(self):
pca = PcaPsfSubtractionModule(pca_numbers=(5, ),
name_in="psf_subtraction",
images_in_tag="im_arr_stacked",
reference_in_tag="im_arr_stacked",
res_mean_tag="res_mean",
res_median_tag=None,
res_arr_out_tag=None,
res_rot_mean_clip_tag=None,
extra_rot=0.)
self.pipeline.add_module(pca)
self.pipeline.run_module("psf_subtraction")
data = self.pipeline.get_data("res_mean")
assert np.allclose(data[0, 38, 22], 2.073747383344391e-05, rtol=limit, atol=0.)
assert np.allclose(np.mean(data), -1.5133372249623263e-08, rtol=limit, atol=0.)
assert data.shape == (1, 46, 46)
def test_psf_subtraction(self) -> None:
module = PcaPsfSubtractionModule(pca_numbers=[1, ],
name_in='pca',
images_in_tag='fake',
reference_in_tag='fake',
res_mean_tag='res_mean',
extra_rot=0.)
self.pipeline.add_module(module)
self.pipeline.run_module('pca')
data = self.pipeline.get_data('res_mean')
assert np.sum(data) == pytest.approx(0.015843543362863227, rel=self.limit, abs=0.)
assert data.shape == (1, 21, 21)