在 python 中将 1D 数组插值到 3d

Interpolation of 1D array into a 3d in python

我正在尝试将深度相关的 1d(长度 96)垂直剖面插入 3d 测深 (50,599,3)。但是,我尝试了很多插值方法,例如 scipy 的 interp1d 和其他方法,但没有成功。因此,我来​​这里寻求帮助。

提前致谢

盐度

array([ 34.20546627,  34.19093594,  34.17489749,  34.15761666,
    34.13954375,  34.12091659,  34.10169857,  34.08129895,
    34.06037314,  34.03972929,  34.01991099,  34.00071959,
    33.98180477,  33.96223023,  33.94118924,  33.9194568 ,
    33.89682248,  33.87488351,  33.85366114,  33.83329624,
    33.81350586,  33.79426549,  33.77546619,  33.75719221,
    33.73950517,  33.72237644,  33.70607063,  33.69028835,
    33.67553891,  33.66126547,  33.64859302,  33.63642087,
    33.62563477,  33.61546976,  33.60635081,  33.59807812,
    33.59061813,  33.58489841,  33.57936385,  33.57534882,
    33.57163308,  33.56965947,  33.56987072,  33.570075  ,
    33.57204836,  33.57417012,  33.5767776 ,  33.58076889,
    33.58462513,  33.58781314,  33.5904936 ,  33.59308157,
    33.59504497,  33.59679745,  33.59848802,  33.5999925 ,
    33.60143253,  33.6028202 ,  33.60323055,  33.60360562,
    33.60396657,  33.60418794,  33.60439494,  33.60459381,
    33.60469671,  33.60478075,  33.60486133,  33.60488729,
    33.60488854,  33.60488974,  33.60489304,  33.60489891,
    33.6049045 ,  33.60491051,  33.60492098,  33.6049309 ,
    33.60494028,  33.60495118,  33.60496209,  33.60497234,
    33.60497982,  33.60498266,  33.6049853 ,  33.60498774,
    33.60498807,  33.60498807,  33.60498807,  33.60498807,
    33.60498807,  33.60498807,  33.60498807,  33.60498807,
    33.60498807,  33.60498807,  33.60498807,  33.60498807])

深度剖面

([7.86297974e+01,   7.59531162e+01,   7.33592304e+01,
     7.08456069e+01,   6.84097906e+01,   6.60494027e+01,
     6.37621378e+01,   6.15457623e+01,   5.93981114e+01,
     5.73170877e+01,   5.53006587e+01,   5.33468552e+01,
     5.14537689e+01,   4.96195510e+01,   4.78424101e+01,
     4.61206107e+01,   4.44524710e+01,   4.28363620e+01,
     4.12707052e+01,   3.97539716e+01,   3.82846799e+01,
     3.68613951e+01,   3.54827272e+01,   3.41473297e+01,
     3.28538984e+01,   3.16011701e+01,   3.03879212e+01,
     2.92129670e+01,   2.80751599e+01,   2.69733886e+01,
     2.59065772e+01,   2.48736837e+01,   2.38736993e+01,
     2.29056475e+01,   2.19685829e+01,   2.10615901e+01,
     2.01837834e+01,   1.93343056e+01,   1.85123269e+01,
     1.77170446e+01,   1.69476821e+01,   1.62034878e+01,
     1.54837350e+01,   1.47877208e+01,   1.41147653e+01,
     1.34642114e+01,   1.28354238e+01,   1.22277882e+01,
     1.16407112e+01,   1.10736196e+01,   1.05259594e+01,
     9.99719575e+00,   9.48681229e+00,   8.99431053e+00,
     8.51920948e+00,   8.06104512e+00,   7.61937001e+00,
     7.19375277e+00,   6.78377774e+00,   6.38904452e+00,
     6.00916758e+00,   5.64377594e+00,   5.29251272e+00,
     4.95503488e+00,   4.63101282e+00,   4.32013009e+00,
     4.02208305e+00,   3.73658064e+00,   3.46334401e+00,
     3.20210631e+00,   2.95261240e+00,   2.71461863e+00,
     2.48789255e+00,   2.27221273e+00,   2.06736853e+00,
     1.87315989e+00,   1.68939715e+00,   1.51590082e+00,
     1.35250147e+00,   1.19903952e+00,   1.05536507e+00,
     9.21337830e-01,   7.96826886e-01,   6.81710640e-01,
     5.75876665e-01,   4.79221598e-01,   3.91651042e-01,
     3.13079472e-01,   2.43430153e-01,   1.82635060e-01,
     1.30634820e-01,   8.73786472e-02,   5.28242949e-02,
     2.69380163e-02,   9.69452980e-03,   1.07699467e-03])

3D - 测深

array([[[  4.62869101e-02,   4.62869101e-02,   4.62869101e-02],
    [  9.65587111e-01,   9.65587111e-01,   9.65587111e-01],
    [  9.65587111e-01,   9.65587111e-01,   9.65587111e-01],
    ..., 
    [  7.48619236e+01,   7.48619236e+01,   7.48619236e+01],
    [  7.48619236e+01,   7.48619236e+01,   7.48619236e+01],
    [  7.48619236e+01,   7.48619236e+01,   7.48619236e+01]],

   [[  4.60148333e-02,   4.60148333e-02,   4.60148333e-02],
    [  9.59911341e-01,   9.59911341e-01,   9.59911341e-01],
    [  9.59911341e-01,   9.59911341e-01,   9.59911341e-01],
    ..., ]]])

我认为 numpy.interp 可以工作 - 但我是否正确理解你的问题。

我只是尝试用一个假人"bathymetry"(今天学了一个新词:-D):

print interp([[1,2],[3,4]], depth, salinity)

输出:

[[ 33.60498807  33.60498807]
 [ 33.60498807  33.60498807]]

请用您的数据集试试这个,然后告诉我们。