我有数据框dfr
,我从中提取了我需要的值。
x = np.array(dfr.Lon)
y = np.array(dfr.Lat)
values = np.array(dfr.val)
x=
array([ 103.9007, 103.8338, 103.8271, 103.7114, 103.9826, 103.8654,
103.9412, 103.828 , 103.71 , 103.7556, 103.8657, 103.7354,
103.8878, 103.6806, 103.8106, 103.8492, 103.7768, 103.7854,
103.886 , 103.8279, 103.7042, 103.7603, 103.7363, 103.8482,
103.7953, 103.8125, 103.8907, 103.9203, 103.805 , 103.7815,
103.8372, 103.8202, 103.9092, 103.6351, 103.9444, 103.7205,
103.8519, 103.8191, 103.9489, 103.7134, 103.9619, 103.8703,
103.8697, 103.8365, 103.7013, 103.7386, 103.6184, 103.754 ,
103.6741, 103.8461, 103.8666, 103.818 , 103.7224, 103.8249,
103.8577, 103.8249, 103.8577])
y =
array([ 1.3524, 1.3417, 1.3701, 1.3858, 1.3678, 1.4166, 1.3863,
1.2745, 1.3081, 1.3329, 1.3382, 1.3262, 1.3399, 1.3455,
1.3416, 1.3764, 1.3337, 1.4439, 1.3837, 1.25 , 1.3275,
1.3824, 1.4387, 1.274 , 1.4582, 1.2937, 1.307 , 1.3277,
1.37 , 1.2923, 1.3004, 1.4252, 1.4029, 1.3247, 1.3437,
1.3302, 1.3415, 1.3191, 1.3679, 1.3505, 1.3134, 1.2799,
1.3606, 1.3106, 1.4385, 1.3819, 1.2938, 1.281 , 1.2542,
1.2994, 1.3011, 1.3087, 1.3729, 1.4173, 1.3214, 1.4173,
1.3214])
values =
array([133, 35, 53, 47, 11, 93, 26, 13, 25, 38, 74, 59, 92,
11, 44, 73, 40, 66, 104, 11, 24, 30, 24, 5, 124, 21,
48, 43, 42, 25, 13, 82, 59, 31, 61, 52, 53, 28, 48,
42, 43, 9, 100, 20, 61, 47, 72, 42, 64, 13, 11, 15,
56, 63, 38, 0, 0])
如果我这样做:
rbf = Rbf(x, y, values, function='inverse')
我收到以下错误:
---------------------------------------------------------------------------
LinAlgError Traceback (most recent call last)
<ipython-input-51-b18c56d1a712> in <module>()
----> 1 rbf = Rbf(x, y, values, function='inverse')
/usr/lib/python2.7/dist-packages/scipy/interpolate/rbf.pyc in __init__(self, *args, **kwargs)
220
221 self.A = self._init_function(r) - np.eye(self.N)*self.smooth
--> 222 self.nodes = linalg.solve(self.A, self.di)
223
224 def _call_norm(self, x1, x2):
/usr/lib/python2.7/dist-packages/scipy/linalg/basic.pyc in solve(a, b, sym_pos, lower, overwrite_a, overwrite_b, debug, check_finite)
101 return x
102 if info > 0:
--> 103 raise LinAlgError("singular matrix")
104 raise ValueError('illegal value in %d-th argument of internal gesv|posv' %
105 -info)
LinAlgError: singular matrix