field.py 文件源码

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

项目:pytrip 作者: pytrip 项目源码 文件源码
def get_lateral(self, resolution=0.5):
        if hasattr(self, "lateral") and resolution == resolution:
            return self.lateral
        max_dist = self.get_max_dist()
        dim = np.ceil(np.absolute(max_dist / resolution))
        max_dist = dim * resolution
        self.resolution = resolution
        a = np.meshgrid(np.linspace(0, max_dist, dim), np.linspace(0, max_dist, dim))
        r = (a[0]**2 + a[1]**2)**0.5
        sigma = self.sigma / ((8 * log(2))**0.5)
        lateral = 1 / ((2 * pi * sigma**2)**0.5) * np.exp(-(r**2) / (2 * sigma**2))
        tot_lat = np.zeros((2 * dim - 1, 2 * dim - 1))

        tot_lat[dim - 1:2 * dim - 1, dim - 1:2 * dim - 1] = lateral
        tot_lat[dim - 1:2 * dim - 1, 0:dim - 1] = np.rot90(lateral, 3)[:, 0:dim - 1]
        tot_lat[0:dim - 1, 0:dim - 1] = np.rot90(lateral, 2)[0:dim - 1, 0:dim - 1]
        tot_lat[0:dim - 1, dim - 1:2 * dim - 1] = np.rot90(lateral)[0:dim - 1, :]

        self.lateral = tot_lat
        return self.lateral
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号