Calculate position-dependent diffusion coefficients in one and two dimensions from collective variables trajectories.