def test_multiband_psf_matching(self): """Test matching two PSFs with a spectral dimension """ gaussian = partial(scarlet.psf.generate_psf_image, func=scarlet.psf.gaussian, shape=(41, 41)) # Single band target PSF psf1 = gaussian(sigma=.9)[None, :, :] # Multiband observation PSF observation = np.array( [gaussian(sigma=1 + .3 * n).image for n in range(5)]) psf2 = fft.Fourier(observation) # Nawrrow to wide kernel_1to2 = fft.match_psfs(psf2, psf1) image = fft.convolve(kernel_1to2, psf1) assert_almost_equal(psf2.image, image.image) # Wide to narrow kernel_2to1 = fft.match_psfs(psf1, psf2) image = fft.convolve(kernel_2to1, psf2).image for img in image: assert_almost_equal(img, psf1.image[0])
def test_2D_psf_matching(self): """Test matching two 2D psfs """ # Narrow PSF psf1 = scarlet.fft.Fourier(self.get_psfs(1)) # Wide PSF psf2 = scarlet.fft.Fourier(self.get_psfs(2)) # Test narrow to wide kernel_1to2 = fft.match_psfs(psf2, psf1) img2 = fft.convolve(psf1, kernel_1to2) assert_almost_equal(img2.image, psf2.image) # Test wide to narrow kernel_2to1 = fft.match_psfs(psf1, psf2) img1 = fft.convolve(psf2, kernel_2to1) assert_almost_equal(img1.image, psf1.image)
def test_2D_psf_matching(self): """Test matching two 2D psfs """ # Narrow PSF psf1 = scarlet.psf.generate_psf_image(scarlet.psf.gaussian, (41, 41), sigma=1) # Wide PSF psf2 = scarlet.psf.generate_psf_image(scarlet.psf.gaussian, (41, 41), sigma=2) # Test narrow to wide kernel_1to2 = fft.match_psfs(psf2, psf1) img2 = fft.convolve(psf1, kernel_1to2) assert_almost_equal(img2.image, psf2.image) # Test wide to narrow kernel_2to1 = fft.match_psfs(psf1, psf2) img1 = fft.convolve(psf2, kernel_2to1) assert_almost_equal(img1.image, psf1.image)
def test_multiband_psf_matching(self): """Test matching two PSFs with a spectral dimension """ # Narrow PSF psf1 = scarlet.fft.Fourier(self.get_psfs(1)) # Wide PSF psf2 = scarlet.fft.Fourier(self.get_psfs((1, 2, 3))) # Nawrrow to wide kernel_1to2 = fft.match_psfs(psf2, psf1) image = fft.convolve(kernel_1to2, psf1) assert_almost_equal(psf2.image, image.image) # Wide to narrow kernel_2to1 = fft.match_psfs(psf1, psf2) image = fft.convolve(kernel_2to1, psf2).image for img in image: assert_almost_equal(img, psf1.image[0])