Scipy GridData QhullError:中心点与小平面共面,或者顶点与相邻小平面共面 [英] Scipy GridData QhullError: center point is coplanar with a facet, or a vertex is coplanar with a neighboring facet

查看:107
本文介绍了Scipy GridData QhullError:中心点与小平面共面,或者顶点与相邻小平面共面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 scipy.interpolate.griddata 时遇到了一个奇怪的问题.这是一个 QhullError .它说中心点与小平面共面,或者顶点与相邻小平面共面..这个错误是什么意思?如何克服?

I'm having a strange issue using scipy.interpolate.griddata. It's a QhullError. It says center point is coplanar with a facet, or a vertex is coplanar with a neighboring facet.. What does this error mean? How can it be overcome?

from scipy.interpolate import griddata
import numpy as np
def f(x, y): return (1 - x) ** 2 * 10 * (y - x**2) ** 2
X = np.linspace(-3, 3)
Y = np.linspace(-3, 3)
Z = f(X, Y)
xi = np.linspace(X.min(), X.max(), 1000)
yi = np.linspace(Y.min(), Y.max(), 1000)
zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='cubic')





QhullError                                Traceback (most recent call last)
~/Documents/SAStatement/sss.py in <module>
      7 xi = np.linspace(X.min(), X.max(), 1000)
      8 yi = np.linspace(Y.min(), Y.max(), 1000)
----> 9 zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='cubic')

/anaconda3/lib/python3.7/site-packages/scipy/interpolate/ndgriddata.py in griddata(points, values, xi, method, fill_value, rescale)
    224     elif method == 'cubic' and ndim == 2:
    225         ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value,
--> 226                                         rescale=rescale)
    227         return ip(xi)
    228     else:

interpnd.pyx in scipy.interpolate.interpnd.CloughTocher2DInterpolator.__init__()

qhull.pyx in scipy.spatial.qhull.Delaunay.__init__()

qhull.pyx in scipy.spatial.qhull._Qhull.__init__()

QhullError: QH6154 Qhull precision error: Initial simplex is flat (facet 1 is coplanar with the interior point)

While executing:  | qhull d Qz Qt Qc Q12 Qbb
Options selected for Qhull 2015.2.r 2016/01/18:
  run-id 62852831  delaunay  Qz-infinity-point  Qtriangulate  Qcoplanar-keep
  Q12-no-wide-dup  Qbbound-last  _pre-merge  _zero-centrum  Qinterior-keep
  Pgood  _max-width  6  Error-roundoff 8.3e-15  _one-merge 5.8e-14
  Visible-distance 1.7e-14  U-coplanar-distance 1.7e-14  Width-outside 3.3e-14
  _wide-facet 1e-13

precision problems (corrected unless 'Q0' or an error)
      2 flipped facets

The input to qhull appears to be less than 3 dimensional, or a
computation has overflowed.

Qhull could not construct a clearly convex simplex from points:
- p38(v3):   1.7   1.7   1.7
- p50(v2): 8.9e-17 8.9e-17     6
- p49(v1):     3     3   5.5
- p0(v0):    -3    -3   5.5

The center point is coplanar with a facet, or a vertex is coplanar
with a neighboring facet.  The maximum round off error for
computing distances is 8.3e-15.  The center point, facets and distances
to the center point are as follows:

center point   0.4133   0.4133    4.641

facet p50 p49 p0 distance=    0
facet p38 p49 p0 distance=    0
facet p38 p50 p0 distance=    0
facet p38 p50 p49 distance=    0

These points either have a maximum or minimum x-coordinate, or
they maximize the determinant for k coordinates.  Trial points
are first selected from points that maximize a coordinate.

The min and max coordinates for each dimension are:
  0:        -3         3  difference=    6
  1:        -3         3  difference=    6
  2:  -4.337e-19         6  difference=    6

If the input should be full dimensional, you have several options that
may determine an initial simplex:
  - use 'QJ'  to joggle the input and make it full dimensional
  - use 'QbB' to scale the points to the unit cube
  - use 'QR0' to randomly rotate the input for different maximum points
  - use 'Qs'  to search all points for the initial simplex
  - use 'En'  to specify a maximum roundoff error less than 8.3e-15.
  - trace execution with 'T3' to see the determinant for each point.

If the input is lower dimensional:
  - use 'QJ' to joggle the input and make it full dimensional
  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should
    pick the coordinate with the least range.  The hull will have the
    correct topology.
  - determine the flat containing the points, rotate the points
    into a coordinate plane, and delete the other coordinates.
  - add one or more points to make the input full dimensional.

推荐答案

因为您的 X Y 是相同的,这意味着您提供的所有要插值的点都是在飞机上 x = y .

Because your X and Y are identical, wich means all the points you provided to interpolate are the on the plane x=y.

X = np.linspace(-3, 3)
Y = (np.random.random(50)-0.5)*6 # Just make sure X and Y are non-linear.
Z = f(X, Y)
xi = np.linspace(X.min(), X.max(), 1000)
yi = np.linspace(Y.min(), Y.max(), 1000)
zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='cubic')

这篇关于Scipy GridData QhullError:中心点与小平面共面,或者顶点与相邻小平面共面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆