Array must not contain infs or NaNs

I got an error like this.

Traceback (most recent call last):
File “plot_bootstrap1.py”, line 51, in
lambda_, v = np.linalg.eig(cov)
File “<array_function internals>”, line 200, in eig
File “/home/haigun/.local/lib/python3.8/site-packages/numpy/linalg/linalg.py”, line 1298, in eig
_assert_finite(a)
File “/home/haigun/.local/lib/python3.8/site-packages/numpy/linalg/linalg.py”, line 195, in _assert_finite
raise LinAlgError(“Array must not contain infs or NaNs”)
numpy.linalg.LinAlgError: Array must not contain infs or NaNs

This is the script.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from mpl_toolkits.basemap import Basemap

N = 100
M = 567
hypo = np.loadtxt(‘hypoDD/hypoDD.reloc’, usecols=(0,1,2,3))
id = np.array([int(l)-1 for l in hypo[:,0]])
hx = hypo[:,2]
hy = hypo[:,1]
hz = hypo[:,3]

initialize matrix

X = np.zeros((M,N))
Y = np.zeros((M,N))
Z = np.zeros((M,N))

for i in range(N):
data = np.genfromtxt(‘hypoDD/bootstrap/hypoDD’+str(i)+‘.reloc’, usecols=(0,1,2,3))
idx = np.array([int(l)-1 for l in data[:,0]])
X[idx,i] = data[:,2]
Y[idx,i] = data[:,1]
Z[idx,i] = data[:,3]

X[X==0]=9999
Y[Y==0]=9999
Z[Z==0]=9999

MapView

fig = plt.figure()
ax = fig.add_subplot(111, aspect=‘equal’)
relative_error = open(‘relative_error.txt’, ‘w+’)
relative_error.write(‘x_err’+‘\t’+‘y_err’+‘\t’+‘z_err’+‘\n’)
ll = 0
for mm in id:
x = X[mm,:]
y = Y[mm,:]
z = Z[mm,:]

x = np.delete(x, np.where(x==9999))
y = np.delete(y, np.where(y==9999))
z = np.delete(z, np.where(z==9999))


cov = np.cov(x,y)
lambda_, v = np.linalg.eig(cov)
lambda2 = np.sqrt(lambda_)

cov = np.cov(x,z)
lambda_, v = np.linalg.eig(cov)
lambdaz1 = np.sqrt(lambda_)

cov = np.cov(y,z)
lambda_, v = np.linalg.eig(cov)
lambdaz2 = np.sqrt(lambda_)

tempx = lambda2[0] * 111.11
tempy = lambda2[1] * 111.11
tempz = (lambdaz1[1] + lambdaz2[1])*0.5

relative_error.write(str(tempx)+'\t'+str(tempy)+'\t'+str(tempz)+'\n')

ell = Ellipse(xy=(np.mean(x), np.mean(y)),
                  width=lambda2[0]*2*2, height=lambda2[1]*2*2,
                  angle=-np.rad2deg(np.arccos(v[0, 0])))
ell.set_facecolor('none')
ell.set_edgecolor('k')
ell.set_linewidth(0.5)
ax.add_artist(ell)
ax.scatter(np.mean(x), np.mean(y), 0.1, 'k')
# ax.scatter(x,y,2, marker='+', color='b')
ll += 1

relative_error.close()

ax.set_xlabel(‘Longitude [$^o$]’)

ax.set_ylabel(‘Latitude [$^o$]’)

ax.set_xlim([95.65, 98.30])
ax.set_ylim(1.70, 4.85)
m = Basemap(llcrnrlat=1.70,urcrnrlat=1,
llcrnrlon=95.65,urcrnrlon=98.30,lat_ts=4.85,resolution=‘h’, ax=ax)
m.drawcoastlines(linewidth=0.4)
m.fillcontinents(color=‘lightgray’,lake_color=‘white’)
m.drawmapboundary(fill_color=‘white’)
m.drawparallels(np.arange(1.70,4.85,1),labels=[1,0,0,0], linewidth=0.0)
m.drawmeridians(np.arange(95.65,98.30,1),labels=[0,0,0,1], linewidth=0.0)
fig.savefig(‘MapView_bootstrap1.png’, fmt=‘png’, dpi=500, bbox_inches=‘tight’)
plt.show()

How i can solve this issue ?