回答編集履歴
2
追記
test
CHANGED
@@ -3,3 +3,77 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
[Interpolation (scipy.interpolate)](https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#id1)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
----
|
10
|
+
|
11
|
+
上記のコードを少しだけ編集したものを置いておきます。補完アルゴリズムやパラメータは適宜調整する必要があると思います。
|
12
|
+
|
13
|
+
```Python
|
14
|
+
|
15
|
+
import numpy as np
|
16
|
+
|
17
|
+
import matplotlib.pyplot as plt
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
# 2-d tests - setup scattered data
|
22
|
+
|
23
|
+
x = np.random.rand(100)*4.0-2.0
|
24
|
+
|
25
|
+
y = np.random.rand(100)*4.0-2.0
|
26
|
+
|
27
|
+
z = x*np.exp(-x**2-y**2)
|
28
|
+
|
29
|
+
plt.scatter(x, y, c=z)
|
30
|
+
|
31
|
+
plt.colorbar()
|
32
|
+
|
33
|
+
plt.show()
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
![scatter](efb2f7920644c21e175cd3ad3eb01899.png)
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```python
|
42
|
+
|
43
|
+
# Interpolation: use RBF
|
44
|
+
|
45
|
+
from scipy.interpolate import Rbf
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
ti = np.linspace(-2.0, 2.0, 100)
|
50
|
+
|
51
|
+
XI, YI = np.meshgrid(ti, ti)
|
52
|
+
|
53
|
+
rbf = Rbf(x, y, z, epsilon=2)
|
54
|
+
|
55
|
+
ZI = rbf(XI, YI)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
# plot the result
|
60
|
+
|
61
|
+
plt.subplot(1, 1, 1)
|
62
|
+
|
63
|
+
plt.pcolor(XI, YI, ZI)
|
64
|
+
|
65
|
+
plt.scatter(x, y, 100, z)
|
66
|
+
|
67
|
+
plt.title('RBF interpolation - multiquadrics')
|
68
|
+
|
69
|
+
plt.xlim(-2, 2)
|
70
|
+
|
71
|
+
plt.ylim(-2, 2)
|
72
|
+
|
73
|
+
plt.colorbar()
|
74
|
+
|
75
|
+
plt.show()
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
![result](f14b80c4d173fc65d31cf04bd90630a4.png)
|
1
リンク修正
test
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
[Interpolation (scipy.interpolate)](https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#id1
|
5
|
+
[Interpolation (scipy.interpolate)](https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#id1)
|