model.py 文件源码

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

项目:snake 作者: rhinech 项目源码 文件源码
def __init__(
            self,
            name,
            grid_size,
            x_label,
            y_label,
            x_lim,
            y_lim,
            file_name,
            order_parameter
    ):
        self.name = name
        self.grid_size = grid_size
        self.x_lim = x_lim
        self.y_lim = y_lim
        self.x_label = x_label
        self.y_label = y_label
        self.file_name = file_name
        self.order_parameter = order_parameter
        # load data file
        data = np.load(file_name)
        shape = (grid_size, grid_size)
        # for background plotting
        xx = np.reshape(data[:, 0], shape)
        yy = np.reshape(data[:, 1], shape)
        # color plot
        zz = [
            order_parameter(entry)
            for entry in data[:, 2:]
        ]
        zz = np.reshape(zz, shape)
        self.plot_data = xx, yy, zz
        # interpolation
        # rescale parameter space to (0,1)
        data[:, 0] -= np.min(data[:, 0])
        data[:, 0] /= np.max(data[:, 0])
        data[:, 1] -= np.min(data[:, 1])
        data[:, 1] /= np.max(data[:, 1])
        self._interp = LinearNDInterpolator(data[:, 0:2], data[:, 2:], fill_value=np.nan)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号