回答編集履歴
1
edit
test
CHANGED
@@ -3,3 +3,55 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
点が重なっているので、補間する際に行列のランクが落ちて計算できなくなっています。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```python
|
14
|
+
|
15
|
+
import numpy as np
|
16
|
+
|
17
|
+
import matplotlib.pyplot as plt
|
18
|
+
|
19
|
+
import scipy.interpolate
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
x = np.array([0., 0.0197, 0.0399, 0.0602, 0.0402, 0.0202])
|
24
|
+
|
25
|
+
y = np.array([150., 150., 150., 1000., 1000., 1000.])
|
26
|
+
|
27
|
+
z = np.array([0.0038828, 0.0016416, 0.0033378, 0.23935, 0.2409, 0.23913])
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# Set up a regular grid of interpolation points
|
32
|
+
|
33
|
+
xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
|
34
|
+
|
35
|
+
xi, yi = np.meshgrid(xi, yi)
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# Interpolate
|
40
|
+
|
41
|
+
rbf = scipy.interpolate.Rbf(x, y, z, function='linear')
|
42
|
+
|
43
|
+
zi = rbf(xi, yi)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
plt.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower',
|
48
|
+
|
49
|
+
extent=[x.min(), x.max(), y.min(), y.max()])
|
50
|
+
|
51
|
+
plt.scatter(x, y, c=z)
|
52
|
+
|
53
|
+
plt.colorbar()
|
54
|
+
|
55
|
+
plt.show()
|
56
|
+
|
57
|
+
```
|