[英]Creating Multidimensional arrays and interpolating in Python
我有8个数组,每绘制一个数组就给出'xVs。 检测概率”。 我想组合这些数组,以便可以执行多维插值,以从每个维度中的变量中找到检测概率。
这是我的几个数组作为示例。
In [3]: mag_rec
Out[3]:
array([[ 1.35000000e+01, 0.00000000e+00],
[ 1.38333333e+01, 5.38461538e-01],
[ 1.41666667e+01, 5.84158416e-01],
[ 1.45000000e+01, 6.93771626e-01],
[ 1.48333333e+01, 7.43629344e-01],
[ 1.51666667e+01, 8.30774480e-01],
[ 1.55000000e+01, 8.74700571e-01],
[ 1.58333333e+01, 8.84866920e-01],
[ 1.61666667e+01, 8.95135908e-01],
[ 1.65000000e+01, 8.97150997e-01],
[ 1.68333333e+01, 8.90416846e-01],
[ 1.71666667e+01, 8.90911598e-01],
[ 1.75000000e+01, 8.90111460e-01],
[ 1.78333333e+01, 8.89567069e-01],
[ 1.81666667e+01, 8.82184730e-01],
[ 1.85000000e+01, 8.76020265e-01],
[ 1.88333333e+01, 8.54947843e-01],
[ 1.91666667e+01, 8.43505477e-01],
[ 1.95000000e+01, 8.24739363e-01],
[ 1.98333333e+01, 7.70070922e-01],
[ 2.01666667e+01, 6.33006993e-01],
[ 2.05000000e+01, 4.45367502e-01],
[ 2.08333333e+01, 2.65029636e-01],
[ 2.11666667e+01, 1.22023390e-01],
[ 2.15000000e+01, 4.02201524e-02],
[ 2.18333333e+01, 1.51190986e-02],
[ 2.21666667e+01, 8.75088215e-03],
[ 2.25000000e+01, 4.39466969e-03],
[ 2.28333333e+01, 3.65476525e-03]])
和
In [5]: lmt_mag
Out[5]:
array([[ 16.325 , 0.35 ],
[ 16.54166667, 0.39583333],
[ 16.75833333, 0.35555556],
[ 16.975 , 0.29666667],
[ 17.19166667, 0.42222222],
[ 17.40833333, 0.38541667],
[ 17.625 , 0.4875 ],
[ 17.84166667, 0.41956242],
[ 18.05833333, 0.45333333],
[ 18.275 , 0.45980392],
[ 18.49166667, 0.46742424],
[ 18.70833333, 0.4952381 ],
[ 18.925 , 0.49423077],
[ 19.14166667, 0.53375 ],
[ 19.35833333, 0.56239316],
[ 19.575 , 0.52217391],
[ 19.79166667, 0.55590909],
[ 20.00833333, 0.57421227],
[ 20.225 , 0.5729304 ],
[ 20.44166667, 0.61708204],
[ 20.65833333, 0.63968037],
[ 20.875 , 0.65627395],
[ 21.09166667, 0.66177885],
[ 21.30833333, 0.69375 ],
[ 21.525 , 0.67083333],
[ 21.95833333, 0.88333333],
[ 22.175 , 0.85833333]])
在Python中,我将如何将这些数组组合成多维数组? (必须包含更多的数组)
除此之外,一旦有了这个多维数组, scipy.ndimage.interpolation.map_coordinates
是最快的插值方法?
你可以用你的串联阵列numpy.concatenate((a1, a2, ...), axis=0)
和REDIMENSION numpy
有一些不同的功能, 这里 ,你可以使用它们根据您的需要!
例如演示:
>>> import numpy as np
>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.concatenate((a, b), axis=0)
array([[1, 2],
[3, 4],
[5, 6]])
>>> np.expand_dims(y, axis=0)
array([[[1, 2],
[3, 4],
[5, 6]]])
>>> np.expand_dims(y, axis=2)
array([[[1],
[2]],
[[3],
[4]],
[[5],
[6]]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.