1 回答

TA貢獻1818條經驗 獲得超11個贊
用于scipy.ndimage.zoom平滑圖像。這是我對數字 5 使用平滑,但您可以嘗試其他數字。
import matplotlib.pyplot as plt
import pykrige.kriging_tools as kt
import scipy.ndimage
ascFileContent = kt.read_asc_grid("out.grd")
Z = ascFileContent[0]
X = ascFileContent[1]
Y = ascFileContent[2]
fig = plt.figure()
plt.rcParams['figure.figsize'] = [20, 14]
new_z = scipy.ndimage.zoom(Z, 5)
contour = plt.contourf(np.linspace(X[0], X[-1], len(X) * 5),
np.linspace(Y[0], Y[-1], len(Y) * 5),
new_z)
plt.show()
如果您放大特定區域(如此代碼片段所示),您會注意到您的數據本質上是“方格的”。所以即使平滑了,也有一些區域看起來非常像網格(見下文)。
ascFileContent = kt.read_asc_grid("out.grd")
Z = ascFileContent[0]
X = ascFileContent[1]
Y = ascFileContent[2]
fig = plt.figure()
plt.rcParams['figure.figsize'] = [20, 14]
ZOOM_FACTOR = 5
new_z = scipy.ndimage.zoom(Z, ZOOM_FACTOR)
contour = plt.contourf(np.linspace(X[0], X[-1], len(X) * ZOOM_FACTOR),
np.linspace(Y[0], Y[-1], len(Y) * ZOOM_FACTOR),
new_z)
plt.xlim((106, 107))
plt.ylim((24, 26))
plt.show()
添加回答
舉報