小编Adr*_*uau的帖子

Bash 尾部命令和多个管道

我目前正面临命令问题

while sleep 0.3; do echo "1"; done | tail -n +3 | grep --line-buffered "1"
Run Code Online (Sandbox Code Playgroud)

我想要一个看起来像这样的输出:

[nothing during 0.6s]
1
1
...
Run Code Online (Sandbox Code Playgroud)

但有:

[nothing forever]
Run Code Online (Sandbox Code Playgroud)

我发现了这个问题并阅读了这篇博客文章,但由于该--line-buffered选项设置为grep,我认为这不是缓冲问题。我的研究并没有让我找到其他解决方案,我希望我没有遗漏一些明显的东西。

zsh 5.7.1 (x86_64-pc-linux-gnu)如果重要,我正在使用。

bash pipe

5
推荐指数
1
解决办法
1481
查看次数

在 3D 球体上插入非均匀分布的点

我在单位球面上有几个点,它们根据https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf 中描述的算法分布(并在下面的代码中实现)。在这些点中的每一个上,我都有一个值,在我的特定情况下,它表示 1 减去一个小错误。[0, 0.1]如果这很重要,则错误在,所以我的值在[0.9, 1].

可悲的是,计算错误是一个代价高昂的过程,我无法根据需要计算尽可能多的点。不过,我希望我的情节看起来像我在绘制“连续”的东西。所以我想为我的数据拟合一个插值函数,以便能够根据需要采样尽可能多的点。

经过一点研究,我发现scipy.interpolate.SmoothSphereBivariateSpline似乎完全符合我的要求。但我不能让它正常工作。

问题:我可以用什么来插值(样条、线性插值,目前什么都可以)我在单位球体上的数据?答案可以是“您误用了scipy.interpolation,这是执行此操作的正确方法”或“此其他功能更适合您的问题”。

应该可以执行numpyscipy安装的示例代码:

import typing as ty

import numpy
import scipy.interpolate


def get_equidistant_points(N: int) -> ty.List[numpy.ndarray]:
    """Generate approximately n points evenly distributed accros the 3-d sphere.

    This function tries to find approximately n points (might be a little less
    or more) that are evenly distributed accros the 3-dimensional unit sphere.

    The algorithm used is described in
    https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf.
    """ …
Run Code Online (Sandbox Code Playgroud)

python interpolation scipy spherical-coordinate

5
推荐指数
1
解决办法
96
查看次数

标签 统计

bash ×1

interpolation ×1

pipe ×1

python ×1

scipy ×1

spherical-coordinate ×1