I am trying to plot a contour plot but when I use the griddata method in scipy.interpolatem, I getting this error: A Qhull internal error has occurred
Here is my code:
import numpy as np
from scipy.interpolate import griddata
import matplotlib.pyplot as plt
from read_db import setup_data, get_lat, get_lon, get_param
setup_data()
param = get_param()
lat = get_lat()
lon = get_lon()
x = np.array(lon)
y = np.array(lat)
z = np.array(param)
xi = np.linspace(min(x), max(x), 100)
yi = np.linspace(min(y), max(y), 100)
X,Y = np.meshgrid(xi,yi)
Z = griddata((x, y), z, (X, Y), method='cubic')
plt.contour(X,Y,Z)
plt.show()
When I executing the code I get the following an error:
File "C:\Users\mypc\Desktop\GUI\venv\lib\site-packages\scipy\interpolate\ndgriddata.py", line 264, in griddata
ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value,
File "interpnd.pyx", line 908, in scipy.interpolate.interpnd.CloughTocher2DInterpolator.__init__
File "qhull.pyx", line 1841, in scipy.spatial.qhull.Delaunay.__init__
File "qhull.pyx", line 357, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6421 qhull internal error (qh_maxsimplex): qh.MAXwidth required for qh_maxsimplex. Used to estimate determinate
While executing: | qhull d Qt Q12 Qc Qz Qbb
Options selected for Qhull 2019.1.r 2019/06/21:
run-id 1767753654 delaunay Qtriangulate Q12-allow-wide Qcoplanar-keep
Qz-infinity-point Qbbound-last _pre-merge _zero-centrum Qinterior-keep
Pgood _max-width 0 Error-roundoff 1.1e-13 _one-merge 7.6e-13
Visible-distance 2.2e-13 U-max-coplanar 2.2e-13 Width-outside 4.3e-13
_wide-facet 1.3e-12 _maxoutside 8.7e-13
A Qhull internal error has occurred. Please send the input and output to
qhull_bug@qhull.org. If you can duplicate the error with logging ('T4z'), please
include the log file.
Here is my values for lat, lon, param
param = [212.51, 212.46, 212.48, 212.87, 212.76, 212.73, 212.6, 212.61, 212.72, 212.62, 212.38, 212.29, 212.17, 212.19, 212.13, 212.29, 212.31, 212.4, 212.39, 212.43, 212.55, 212.59, 212.72, 212.58, 212.58, 212.33, 212.24, 212.4, 212.45, 212.57, 212.42]
lat = [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0]
lon = [78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0, 78.0]
I am new to this kind of stuff and don't really understand what's happening to cause the error.