kernel.py 文件源码

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

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def get_maximum_aniano(self):

        """
        This function ...
        :return:
        """

        rad_to_mean = 5

        data_copy = self._data.copy()

        #
        mean_im = data_copy * 0.0

        i_range = range(-int(rad_to_mean), int(rad_to_mean)+1)
        #print("irange", i_range)

        for i in i_range:
           j_range = range(-int(math.sqrt(rad_to_mean ** 2 - i ** 2)), int(math.sqrt(rad_to_mean ** 2 - i ** 2))+1)
           #print("jrange", j_range)
           for j in j_range:
              mean_im += shift(data_copy, [i, j])

        mean_im_sum = np.sum(mean_im)

        #mx    = max(mean_im, location)
        #index = ARRAY_INDICES(mean_im, location)
        #x_max = index[0]
        #y_max = index[1]

        # Get x and y max
        max_index = np.argmax(mean_im)
        c = (max_index // len(mean_im[0]), max_index % len(mean_im[0]))
        x_max = c[1]
        y_max = c[0]

        max_value = mean_im[y_max, x_max]
        where = np.abs(mean_im - max_value) < (5e-4 * mean_im_sum)
        count = np.sum(where)

        if count > 1:

            log.debug("WARNING: The PSF has " + str(count) + "pixels with values similar to its maximum... we will take their centroid...")

            xsize = data_copy.shape[1]
            ysize = data_copy.shape[0]

            xv, yv = np.meshgrid(np.arange(xsize), np.arange(ysize))

            # Average x max
            x_max = np.sum(xv[where]) / float(count)

            # Average y max
            y_max = np.sum(xv[where]) / float(count)

        # Return xmax and ymax position
        return x_max, y_max

    # -----------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号