def __init__(self, r_psf, g_psf, b_psf):
''' Creates a new `RGBPSF` instance.
Args:
r_psf (`PSF`): PSF for the red channel.
g_psf (`PSF`): PSF for the green channel.
b_psf (`PSF`): PSF for the blue channel.
Returns:
RGBPSF: A new `RGBPSF` instance.
'''
if np.array_equal(r_psf.unit_x, g_psf.unit_x) and \
np.array_equal(g_psf.unit_x, b_psf.unit_x) and \
np.array_equal(r_psf.unit_y, g_psf.unit_y) and \
np.array_equal(g_psf.unit_y, b_psf.unit_y):
# do not need to interpolate the arrays
self.R = r_psf.data
self.G = g_psf.data
self.B = b_psf.data
else:
# need to interpolate the arrays. Blue tends to be most densely
# sampled, use it to define our grid
self.B = b_psf.data
xv, yv = np.meshgrid(b_psf.unit_x, b_psf.unit_y)
interpf_r = interpolate.RegularGridInterpolator((r_psf.unit_y, r_psf.unit_x), r_psf.data)
interpf_g = interpolate.RegularGridInterpolator((g_psf.unit_y, g_psf.unit_x), g_psf.data)
self.R = interpf_r((yv, xv), method='linear')
self.G = interpf_g((yv, xv), method='linear')
self.sample_spacing = b_psf.sample_spacing
self.samples_x = b_psf.samples_x
self.samples_y = b_psf.samples_y
self.unit_x = b_psf.unit_x
self.unit_y = b_psf.unit_y
self.center_x = b_psf.center_x
self.center_y = b_psf.center_y
评论列表
文章目录