小编Bri*_*ian的帖子

如何快速估算Python中点与双三次样条曲面之间的距离?

如何快速估算Python中点与双三次样条曲面之间的距离?是否存在我可以在SciPy,NumPy或其他软件包中使用的现有解决方案?

我有一个双三次插值定义的表面,如下所示:

import numpy as np
import scipy.interpolate

# Define regular grid surface
xmin,xmax,ymin,ymax = 25, 125, -50, 50
x = np.linspace(xmin,xmax, 201)
y = np.linspace(ymin,ymax, 201)
xx, yy = np.meshgrid(x, y)
z_ideal = ( xx**2 + yy**2 ) / 400
z_ideal += z_ideal + np.random.uniform(-0.5, 0.5, z_ideal.shape)
s_ideal = scipy.interpolate.interp2d(x, y, z_ideal, kind='cubic')   
Run Code Online (Sandbox Code Playgroud)

而且我有一些表面的测量点:

# Fake some measured points on the surface
z_measured = z_ideal + np.random.uniform(-0.1, 0.1, z_ideal.shape)
s_measured = scipy.interpolate.interp2d(x, y, z_measured, kind='cubic')
p_x = np.random.uniform(xmin,xmax,10000)
p_y …
Run Code Online (Sandbox Code Playgroud)

python numpy spline scipy

9
推荐指数
1
解决办法
605
查看次数

QXcbConnection:XCB错误:145(未知)使用MobaXTerm Qt5启动Spyder的错误消息

通过MobaXTerm通过远程连接启动Spyder时,我看到以下错误消息:

$ spyder
QXcbConnection: XCB error: 145 (Unknown), sequence: 171, resource id: 0, major code: 139 (Unknown), minor code: 20
Run Code Online (Sandbox Code Playgroud)

Spyder似乎仍能正常工作,但每次都会弹出错误信息.对此错误的搜索归咎于Qt5并且说没有修复X11连接.我正在使用Python 3.5.4,Spyder 3.2.3和MobaXTerm Personal Edition v10.7 Build 3650连接到运行RHEL 6.6的系统.

如何避免错误消息?

spyder qt5

6
推荐指数
1
解决办法
7464
查看次数

matplotlib clabel 上的 set_clip_path 未正确剪切

我正在制作一个剪裁到多边形路径的等高线图:

import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np

fig = plt.figure()
axes = plt.subplot()
x,y = np.meshgrid( np.linspace(-10,10,51), np.linspace(-10,10,51) ) 
z = np.sin(np.sqrt(x**2+y**2))
CS =  axes.contour(x, y, z, np.linspace(-1,1,11) )
axes.set_aspect('equal')

# clip contours by polygon
radius = 8
t = np.linspace(0,2*np.pi,101)
x_bound,y_bound = radius*np.sin(t),radius*(np.cos(t)+0.1*(np.cos(7*t)))
clip_map = Polygon(list(zip(x_bound,y_bound)),fc='#EEEEEE',ec='none')
axes.add_patch(clip_map)
for collection in CS.collections:
    collection.set_clip_path(clip_map)

# label the contours    
CLB = axes.clabel(CS, colors='black')
for text_object in CLB:
    text_object.set_clip_path(clip_map) # Doesn't do anything!

plt.show()
Run Code Online (Sandbox Code Playgroud)

Text令我惊讶的是,尽管对象具有set_clip_path …

python plot matplotlib

3
推荐指数
1
解决办法
1184
查看次数

标签 统计

python ×2

matplotlib ×1

numpy ×1

plot ×1

qt5 ×1

scipy ×1

spline ×1

spyder ×1