psf.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:prysm 作者: brandondube 项目源码 文件源码
def __init__(self, psfs, weights=None):
        ''' Creates a new :class:`MultispectralPSF` instance.

        Args:
            psfs (iterable): iterable of PSFs.

            weights (iterable): iterable of weights associated with each PSF.

        Returns:
            MultispectralPSF.  A new `MultispectralPSF`.

        '''
        if weights is None:
            weights = [1] * len(psfs)

        # find the most densely sampled PSF
        min_spacing = 1e99
        ref_idx = None
        ref_unit_x = None
        ref_unit_y = None
        ref_samples_x = None
        ref_samples_y = None
        for idx, psf in enumerate(psfs):
            if psf.sample_spacing < min_spacing:
                min_spacing = psf.sample_spacing
                ref_idx = idx
                ref_unit_x = psf.unit_x
                ref_unit_y = psf.unit_y
                ref_samples_x = psf.samples_x
                ref_samples_y = psf.samples_y

        merge_data = np.zeros((ref_samples_x, ref_samples_y, len(psfs)))
        for idx, psf in enumerate(psfs):
            # don't do anything to our reference PSF
            if idx is ref_idx:
                merge_data[:, :, idx] = psf.data * weights[idx]
            else:
                xv, yv = np.meshgrid(ref_unit_x, ref_unit_y)
                interpf = interpolate.RegularGridInterpolator((psf.unit_x, psf.unit_y), psf.data)
                merge_data[:, :, idx] = interpf((xv, yv), method='linear') * weights[idx]

        self.weights = weights
        super().__init__(merge_data.sum(axis=2), min_spacing)
        self._renorm()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号