我将ascii-Data放在一个名为'Testdata_interpolate.csv'的文件中,方式如下
x,y,z,v
val11,val12,val13,val14
val21,val22,val23,val24
...
其中x,y,z表示坐标,v表示空间中此点的标量值。 x,y,z是随机分布的。
对于进一步的计算,v应作为V插值到规则网格(X,Y,Z)上。因此我尝试在该代码中使用Phytons griddata:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.interpolate import griddata as gd
#read values
f=open('Testdata_interpolate.csv','r')
headers = ["x","y","z","v"]
data = pd.read_csv(f, delimiter = ",",header=1,names=headers)
x=data.x
y=data.y
z=data.z
v=data.v
#generate new grid
X,Y,Z=np.mgrid[0:1:10j, 0:1:10j, 0:1:10j]
#interpolate "data.v" on new grid "inter_mesh"
V = gd((x,y,z), v, (X,Y,Z), method='nearest')
#Plot values
fig = plt.figure()
ax=fig.gca(projection='3d')
sc=ax.scatter(X, Y, Z, c=V, cmap=plt.hot())
plt.colorbar(sc)
plt.show()
尝试此操作会导致错误。
ValueError: Buffer has wrong number of dimensions (expected 1, got 3)
由于失败,我试图用
生成新网格X=np.linspace(0,1,10)
Y=np.linspace(0,1,10)
Z=np.linspace(0,1,10)
使用这种表示法执行插值,但我只有一个直线(正确)插值从音量的一个角到另一个。
要插入的X,Y,Z网格的正确生成应该是什么?
EDIT1: 我找到了一个适合我的工作。使用以下代码生成新网格X,Y,Z:
xi,yi,zi=np.ogrid[0:1:10j, 0:1:10j, 0:1:20j]
X1=xi.reshape(xi.shape[0],)
Y1=yi.reshape(yi.shape[1],)
Z1=zi.reshape(zi.shape[2],)
ar_len=len(X1)*len(Y1)*len(Z1)+1
X=np.arange(ar_len,dtype=float)
Y=np.arange(ar_len,dtype=float)
Z=np.arange(ar_len,dtype=float)
l=0
for i in range(0,len(X1)):
for j in range(0,len(Y1)):
for k in range(0,len(Z1)):
l=l+1
X[l]=X1[i]
Y[l]=Y1[j]
Z[l]=Z1[k]
有人知道这是否可以简化和/或如何以良好的python风格书写?
答案 0 :(得分:1)
以下是完整的解决方案:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.interpolate import griddata as gd
import time
#read values
print("Read original data...")
start_time=time.clock()
f=open('Daten.csv','r')
headers = ["x","y","z","V"]
data = pd.read_csv(f, delimiter = ",",header=1,names=headers)
x=data.x
y=data.y
z=data.z
v=data.V
print ('time needed: ', time.clock()-start_time, ' seconds')
print("")
#generate new grid X,Y,Z
print("Generate new grid...")
start_time=time.clock()
xi,yi,zi=np.ogrid[0:1:11j, 0:1:11j, 0:1:11j]
X1=xi.reshape(xi.shape[0],)
Y1=yi.reshape(yi.shape[1],)
Z1=zi.reshape(zi.shape[2],)
ar_len=len(X1)*len(Y1)*len(Z1)
X=np.arange(ar_len,dtype=float)
Y=np.arange(ar_len,dtype=float)
Z=np.arange(ar_len,dtype=float)
l=0
for i in range(0,len(X1)):
for j in range(0,len(Y1)):
for k in range(0,len(Z1)):
X[l]=X1[i]
Y[l]=Y1[j]
Z[l]=Z1[k]
l=l+1
print ('time needed: ', time.clock()-start_time, ' seconds')
print("")
#interpolate "data.v" on new grid "X,Y,Z"
print("Interpolate...")
start_time=time.clock()
V = gd((x,y,z), v, (X,Y,Z), method='linear')
print ('time needed: ', time.clock()-start_time, ' seconds')
print("")
#Plot original values
fig1 = plt.figure()
ax1=fig1.gca(projection='3d')
sc1=ax1.scatter(x, y, z, c=v, cmap=plt.hot())
plt.colorbar(sc1)
ax1.set_xlabel('X')
ax1.set_ylabel('Y')
ax1.set_zlabel('Z')
#Plot interpolated values
fig2 = plt.figure()
ax2=fig2.gca(projection='3d')
sc2=ax2.scatter(X, Y, Z, c=V, cmap=plt.hot())
plt.colorbar(sc2)
ax2.set_xlabel('X')
ax2.set_ylabel('Y')
ax2.set_zlabel('Z')
#Show plots
plt.show()
使用随机点计算示例数据
def func(x,y,z):
return 0.5*(3)**(1/2)-((x-0.5)**2+(y-0.5)**2+(z-0.5)**2)**(1/2)
x = np.random.rand(10)
y = np.random.rand(10)
z = np.random.rand(10)
v = func(x,y,z)
产生了这个示例数据:
x,y,z,v
0.6306633776,0.5399341613,0.0223922509,0.3692590427
0.6201798089,0.713310769,0.2586306574,0.5222175648
0.0133608796,0.5962421199,0.1336130457,0.2493248448
0.625635438,0.2813785867,0.1412831986,0.4275538206
0.4478070925,0.2533920221,0.8647321435,0.4226642295
0.9496287584,0.5412782144,0.0181683893,0.2056985056
0.353725578,0.8192529518,0.9945807043,0.2594541163
0.6531066992,0.7549814415,0.8023866946,0.441885203
0.2034177743,0.7157782351,0.5439790104,0.4966266806
0.3936962193,0.5198892568,0.2851481802,0.6254897914
0.7136407618,0.6884816985,0.6673836339,0.5355938576
0.2679115187,0.1078689156,0.0960926992,0.2571141146
0.9544471861,0.304474494,0.791678864,0.2917179703
0.2513473134,0.8128617403,0.0276061489,0.2472632705
0.5621786268,0.0105501017,0.3463567749,0.3492724404
0.0236232636,0.7537357578,0.0049020726,0.1336057239
0.5544935236,0.3265725226,0.4704909401,0.6818585809
0.9169167232,0.1903847884,0.0384998546,0.1712855118
0.6509500724,0.3350786431,0.4485415479,0.6366066805
0.4892437129,0.4890809474,0.8062363257,0.5594057524
0.2930552054,0.0103116581,0.5241043581,0.3338582869
0.956388208,0.4938978335,0.6916433722,0.3709954906
0.0722823141,0.0776713405,0.0164990656,0.094613018
0.3340717987,0.1857906293,0.8615063092,0.3591264906
0.9461038462,0.4192224785,0.1804858052,0.311387711
0.6194368915,0.7870312196,0.1767282374,0.4175204154
0.2598983985,0.0137079303,0.5218954065,0.3232472126
0.1628694471,0.3909106815,0.4686704314,0.5103021533
0.405955568,0.7681639045,0.5503229067,0.5774277084
0.2701853069,0.2277688606,0.8209407311,0.3865178029
0.8193266613,0.5615418105,0.7331885243,0.4658581901
0.0428746114,0.5050042546,0.402704194,0.3986335582
0.3438295609,0.7730675675,0.9674056518,0.3026222215
0.9552899428,0.2841943004,0.072097092,0.2049944433
0.3554257909,0.4985691797,0.5750067732,0.7031458004
0.7771471706,0.9535270029,0.804036098,0.2537058423
0.6300111088,0.673049493,0.9747896229,0.344226399
0.0862787074,0.2732020325,0.2496220012,0.331898295
0.4397787892,0.8737769038,0.5699767084,0.4810156535
0.9463236536,0.1280889919,0.8617868226,0.1816188677
0.0510125536,0.8540123724,0.1709006799,0.2063127017
0.2290255208,0.4523648438,0.0913191637,0.3733629408
0.3739807131,0.5281513263,0.1555660222,0.4981828792
0.381137688,0.3792761887,0.6625859691,0.6312133829
0.45184571,0.3788999769,0.0564337434,0.4037104947
0.9339652646,0.1587308487,0.284979922,0.2735525196
0.3656675596,0.0956345971,0.5860244642,0.431333798
0.3683657888,0.1729067734,0.6504682948,0.4826740608
0.2295411313,0.4762862368,0.6254150038,0.5669614216
0.7909070767,0.3906802474,0.8597905841,0.3906024342
0.5232714652,0.4474381413,0.9464774509,0.4158627396
0.5506931653,0.0136374333,0.4617536616,0.3755347049
0.6163667089,0.4232951417,0.0508881645,0.3957847346
0.2410430499,0.2445243536,0.8316876458,0.3737417434
0.4896791476,0.4842978234,0.7950337037,0.5703939361
0.6027538624,0.6198397316,0.5598951721,0.6971842087
0.9190498489,0.3987407853,0.0112006215,0.214273122
0.3530254834,0.520464629,0.0603594208,0.4020166232
0.009953508,0.9841304369,0.5740347477,0.1731985942
0.2196149815,0.1010876149,0.9944747656,0.1715816383
0.671561366,0.6656832779,0.0124795495,0.3232911773
0.9913571495,0.4012237578,0.6751740861,0.3351068085
0.2136069964,0.2133224305,0.8533352507,0.3283909734
0.9030364749,0.3387038174,0.8082359016,0.3336118149
0.1987606561,0.4216349495,0.7621533491,0.4590725787
0.5490367836,0.5750362376,0.5902005466,0.7388594425
0.83009432,0.3577592844,0.7607350977,0.4219787031
0.6959727876,0.7086074705,0.8989627659,0.3750124723
0.3955585478,0.9522785004,0.3537629556,0.3793539211
0.1740074199,0.90613637,0.5406577303,0.3436548798
0.862232854,0.1641101963,0.0871443357,0.2222207748
0.5892735408,0.028922464,0.4544688624,0.3844063692
0.2092728323,0.5754606259,0.5228441169,0.5647971751
0.6361810902,0.0517793576,0.8129563089,0.3026528052
0.8755833265,0.0690054237,0.4029022524,0.2861572011
0.3604205895,0.7272419375,0.6232588424,0.5722328712
0.7245441675,0.8508843923,0.1043419443,0.2914949546
0.378985798,0.705913034,0.3252829289,0.5701019853
0.2450076354,0.4675920206,0.7503598065,0.5072059285
0.3954747342,0.7524948808,0.538161918,0.5900987324
0.8431238907,0.89791946,0.2850646916,0.2983361509
0.0075750139,0.2701604665,0.9613816069,0.1531568568
0.3915120547,0.5508184589,0.6184136179,0.6975797599
0.7743560073,0.7732019407,0.7936674234,0.3800716254
0.5731431141,0.0463964108,0.1102689808,0.2635335793
0.3454076014,0.7799256704,0.4952835517,0.5462138412
0.3992618618,0.039215973,0.1443308299,0.2752880251
0.7309012385,0.7477130298,0.308651145,0.4770633087
0.8798876626,0.0781818882,0.5140124665,0.2981860736
0.6337635873,0.7414852159,0.5548462313,0.5845721823
0.8779629321,0.7226434117,0.0649765363,0.2482297412
0.3596338067,0.1629595478,0.9852069955,0.2587982938
0.1470704943,0.7341692382,0.3173635881,0.4047765262
0.5495922826,0.5831609034,0.4090942864,0.7332135854
0.8372890817,0.6471977771,0.5592359801,0.4932788256
0.8986365935,0.6013925502,0.3293837716,0.4207148601
0.7529078043,0.7790015346,0.3484371136,0.4600998905
0.5088906595,0.0117897109,0.9908112199,0.1736931253
0.3322010292,0.8568216281,0.5259938139,0.4708623397
0.0764332382,0.9636281886,0.1978059367,0.1691171237
0.3475818783,0.3942058018,0.8030983983,0.5106490747
0.6377423069,0.8868203075,0.3145786878,0.4154879953
0.0045190767,0.8130553286,0.5093343537,0.2798580946
0.7140381144,0.7407960293,0.027507628,0.2941477212
0.3959185294,0.8889921485,0.7900283924,0.3697751519
0.6414700936,0.0623275826,0.3796580266,0.3905749616
0.4647447769,0.5080850862,0.2602779063,0.6235898833
0.9261314441,0.9800868873,0.2389269791,0.1730387161
0.4068127254,0.8521595996,0.0881227537,0.3161680425
0.6252986387,0.1626255445,0.8149288615,0.3877979894
0.0148919826,0.4288521749,0.5650029395,0.371437511
0.6999084446,0.5193721698,0.6204045802,0.6318546752
0.1939084605,0.4495516764,0.2238104075,0.4506728368
0.6700975735,0.5135514273,0.8026774478,0.5185625092
0.901180391,0.0469020734,0.9142602429,0.1326394304
0.0953740531,0.8537873632,0.9959291318,0.1347023842
0.4603053633,0.7629654546,0.8185415223,0.4510613138
0.657618954,0.7520074762,0.1866926524,0.4341538988
0.36567682,0.744729749,0.7568356825,0.4866839553
0.061796768,0.4784516747,0.6231214956,0.4103442592
0.0582960593,0.7570687738,0.3419325419,0.3310748949
0.56401618,0.7113661579,0.2757130117,0.5512582246
0.3284323403,0.7378651794,0.6241919629,0.5475305858
0.4275464981,0.3531682925,0.5295711182,0.6996417769
0.9765874392,0.742617911,0.4658176337,0.3301453126
0.072844224,0.7883095643,0.9160671954,0.2036838205
0.804863217,0.3942617685,0.7601831764,0.4515167308
0.007844326,0.474396331,0.7450142246,0.3156575944
0.2441903849,0.9658714967,0.1156812242,0.2101475706
0.8654428603,0.810985844,0.7199050951,0.338181743
0.4064994813,0.7387058858,0.1379702581,0.4224170394
0.9703619592,0.2396814054,0.3980043184,0.3188423792
0.72785583,0.7091076345,0.5463329126,0.5533098448
0.4026269424,0.0984237189,0.6391085789,0.4300251531
0.7936799405,0.5424635891,0.5265214701,0.5681085493
0.4642213171,0.1198021551,0.9364229437,0.2861154959
0.4620715394,0.6806879169,0.4046251749,0.6582200893
0.6011675165,0.7123237968,0.3787300339,0.6014074419
0.7100177282,0.8298857084,0.4942637179,0.474918089
0.7301135939,0.7515287406,0.5509963591,0.5213232105
0.6994698314,0.3896948785,0.3934400219,0.6144097
0.4389661969,0.690571303,0.8227801091,0.4862497522
0.4713839427,0.9078846897,0.3451963795,0.4288149742
0.6821897594,0.3855670615,0.7383466417,0.5449379897
0.1437000915,0.1926245144,0.6224994888,0.3797791301
0.6098303414,0.5698709236,0.9622570089,0.3857898448
0.2782655851,0.8486976961,0.4988174602,0.4527970984
0.2702581113,0.2774259285,0.836997639,0.4013879522
0.6564572272,0.0922870446,0.1510823881,0.3070511487
0.2726379978,0.8572610917,0.1478971792,0.3152937412
0.5602773549,0.1056130207,0.4101895268,0.4570750766
0.4259546883,0.3321364383,0.8096145661,0.5061336658
0.530420481,0.5331294727,0.3407970744,0.7005910085
0.1333708394,0.2706074738,0.9213914799,0.262197074
0.3853847516,0.7872972615,0.5643746353,0.5500816346
0.6383190772,0.3975758359,0.6680134941,0.6255022018
0.3074904762,0.1474470852,0.8589877068,0.3272994548
0.164294517,0.4569216795,0.2065183679,0.418046184
0.3177061073,0.5843665436,0.646404561,0.6174633944
0.6420002836,0.3850971295,0.7164241147,0.5828185048
0.2020011383,0.7824059389,0.6739242807,0.4201486368
0.1840347406,0.0619099449,0.1514663014,0.2231936368
0.9046038843,0.7000077552,0.715691632,0.3657951714
0.1403577243,0.1693091849,0.804109877,0.2905414345
0.3889402016,0.7763260252,0.9926312481,0.2903728197
0.3241593493,0.882831795,0.7627518547,0.3695189538
0.7666204442,0.1088284545,0.602145248,0.3817369659
0.8106734194,0.5358877461,0.3051675919,0.4975616049
0.930311342,0.4840485226,0.5832080611,0.4274528532
0.987676861,0.2516205517,0.9622990862,0.1496166405
0.21015611,0.4693912954,0.2686613362,0.4939179586
0.6057100715,0.9904309815,0.3821192914,0.3506682187
0.6056677665,0.9920663947,0.9869230643,0.1657475416
0.1820842028,0.2265129565,0.334319282,0.4151199621
0.8876163042,0.1416437103,0.8254844324,0.2458595023
0.6232990447,0.5307597364,0.7508213738,0.584848987
0.7259092082,0.3400181764,0.0396656887,0.328869158
0.112385463,0.2929171231,0.7552510665,0.3578114192
0.5559131078,0.487973381,0.5951903189,0.754975361
0.7368538344,0.03127444,0.4817180756,0.3405374228
0.8190162682,0.1239617304,0.3222973147,0.3418551987
0.97988197,0.2996560477,0.1457110446,0.2367837425
0.38865937,0.2980691287,0.5831884996,0.6208863837
0.7511422474,0.7001080603,0.5557206437,0.5401106076
0.6946423471,0.6442451245,0.6779334003,0.5654383213
0.6962270452,0.838215151,0.7650459673,0.3936443009
0.4959681755,0.183628186,0.1338019599,0.3820745954
0.1016190418,0.1526950048,0.5857433221,0.3306002785
0.5497103268,0.1446169499,0.2261669635,0.4146355935
0.5969970797,0.8211549471,0.6187163732,0.5101567331
0.8423643133,0.7705178764,0.7524700778,0.3619079724
0.1934005817,0.8919879179,0.3949489795,0.3574062457
0.1128752324,0.2121278716,0.6453188962,0.3621866106
0.984939352,0.4026293467,0.02108349,0.1775428384
0.0369142757,0.2954519021,0.9591341697,0.182583747
0.694564745,0.2295872361,0.7298591792,0.4612862963
0.9867100492,0.6877417272,0.720915026,0.2995123176
0.3844537931,0.6819663068,0.5866166998,0.6337214748
0.5320925768,0.1904548845,0.0721293763,0.3369494332
0.3250763989,0.8926740442,0.7442687657,0.3715980571
0.0884456354,0.9474986999,0.9294405386,0.121679209
0.2715253571,0.1475996259,0.3489222973,0.4196946314
0.6080823056,0.1631524074,0.5568934452,0.5077169479
0.9537259699,0.777563684,0.588825372,0.3267677648
0.6059857589,0.105086105,0.9913446577,0.2267996704
0.9239502157,0.3577242379,0.805413884,0.3244962555
0.2808765186,0.4074664948,0.6179072143,0.6005453464
0.3651996099,0.4394979137,0.4216764531,0.6987943492
0.3838798791,0.2186392358,0.1964127432,0.4361265964
0.6355936999,0.2846375207,0.3993498098,0.5923520405
0.9409695841,0.5761777789,0.8722091025,0.2839628263
0.5727240253,0.5160758496,0.6947885946,0.6574832896
0.3439960505,0.532515792,0.9814805574,0.3588587289
0.844665446,0.0352556573,0.9347137247,0.1423144144
0.2812371739,0.2012480763,0.0445996914,0.2790847534
0.8722510531,0.4501423568,0.8145664254,0.3761186095
0.5294358074,0.8459800522,0.3094731357,0.4699583017
0.9270235896,0.6212266353,0.2540890089,0.3585638203
0.3562878568,0.3831062196,0.3007920287,0.5939938765
0.9597124545,0.7427999057,0.3312525342,0.3194331954
0.5537447884,0.4097215465,0.7437895008,0.6005597334
0.7381427777,0.1960822498,0.650809103,0.4515119939
0.3400718119,0.4290469985,0.2536068172,0.5638318329
0.7990917316,0.0754560353,0.6559687782,0.3237895679
0.0624729146,0.5030904655,0.6033139733,0.4164552996
0.4639588027,0.4688854972,0.3431048342,0.7020645144
0.9235925954,0.6130429817,0.5084196649,0.4275276349
0.1875197874,0.9535069139,0.6924070234,0.2826448532
0.6484220238,0.0996337414,0.4432496125,0.4352785585
0.7373545477,0.9727624131,0.0764032472,0.1883265846
0.4487495478,0.2451071694,0.7262175529,0.5213932156
0.7541094572,0.9352042695,0.1495581423,0.252198174
0.7621058298,0.450101799,0.4171894081,0.5866566678
0.9890595462,0.102434163,0.7846070734,0.1744771259
0.8505146717,0.5804425551,0.2416315574,0.4232096499
0.698750175,0.874646647,0.775899879,0.3600782866
0.5626629528,0.4913736361,0.8220569456,0.5378155075
0.2800742853,0.2206115442,0.7681508234,0.4206827343
0.7407627309,0.863310113,0.494226838,0.4301420934
0.4423902395,0.9326594783,0.859696349,0.3004331724
0.5643581424,0.5599856473,0.2547866842,0.6055070385
0.2382607802,0.616935845,0.2136456727,0.4608338295
0.3724339716,0.5628447905,0.3013413771,0.6217145204
0.9782979445,0.352440188,0.7066606615,0.3244984416
0.9116224624,0.6685323042,0.0067169218,0.2018233378
0.4626697185,0.7594809555,0.8075250707,0.4619269191
0.6385735262,0.0212779644,0.1778529548,0.2725979624
0.3206460142,0.9822497766,0.8319778354,0.2537003411
0.6585250726,0.4610784496,0.7516457304,0.5660743088
0.8514618205,0.0135934496,0.2031696615,0.1965293296
0.6645740872,0.3285068459,0.8808723508,0.417072979
0.7205516925,0.2825607097,0.0957799255,0.3567938625
0.3957547375,0.8866808113,0.4711353827,0.4645004472
0.0271670725,0.3897163997,0.1214067018,0.2503417714
0.1681776842,0.9795156751,0.869546556,0.1756588425
0.2989788846,0.0882321439,0.436671313,0.4034534865
0.840025475,0.2751567103,0.8797768454,0.3088878257
0.4927941296,0.9276139628,0.7721402462,0.3591073243
0.0218443484,0.8739084165,0.7930522648,0.1919927926
0.7082019283,0.8781607534,0.8841319197,0.2881751376
0.4281279931,0.1301428349,0.4840983904,0.4889143205
0.0969747704,0.864892806,0.0574357833,0.1649981707
0.5002240002,0.4913999372,0.0605066316,0.4264478428
0.9010480595,0.2705834925,0.2748491089,0.3520561404
0.0521717295,0.0697361203,0.303329303,0.2145988699
0.2311421199,0.6535710409,0.3484011026,0.5212778875
0.6018243214,0.5142935712,0.461814318,0.7563411072
0.0399977568,0.5296795048,0.5360999634,0.4036552662
0.7723277332,0.5261161379,0.9881150654,0.3064713277
0.6994159547,0.8103932027,0.5725178612,0.4900340429
0.3287358341,0.1474853975,0.5576576959,0.4698911218
0.1405604806,0.7350755552,0.0638994106,0.2539461533
0.6212150408,0.0984797311,0.5947549054,0.4360369103
0.8115583443,0.9193747561,0.2263494512,0.276255609
0.8576836871,0.360387413,0.7281182796,0.4194078448
0.2520324121,0.7656230663,0.5065125659,0.5025890937
0.7081140195,0.5198283888,0.9897978333,0.3334781969
0.2835104092,0.0506739943,0.8162458521,0.2754553052
0.0245973891,0.4038492943,0.5152942104,0.3807558771
0.1753831567,0.5730637948,0.5916852657,0.5208868794
0.1361253039,0.5642410712,0.142771754,0.3520762531
0.8370623511,0.9539091442,0.9245005246,0.1590280664
0.8552911956,0.5826776285,0.2288357087,0.4114954303
0.0116507787,0.8178670548,0.5500240563,0.2811948021
0.3930195158,0.0708319199,0.6882616921,0.3853253625
0.1332551293,0.8507888781,0.4804438921,0.3581503419
0.2441977277,0.9069888443,0.9289183899,0.2217849928
0.8054478295,0.5513038328,0.0952561504,0.3563705759
0.7313680745,0.171937156,0.0195727289,0.2399529013
0.3302117368,0.6714438749,0.0725409359,0.3751666582
0.5449309083,0.5529359679,0.3449625086,0.6961500761
0.6124853263,0.1790586073,0.1321548123,0.3650599276
0.1443241257,0.8709559835,0.7982253207,0.271843604
0.7459991787,0.5998450893,0.8482665855,0.4281050316
0.8584817678,0.6925073438,0.7560070771,0.3852885955
0.2597912861,0.6662350075,0.1327351142,0.3967517093
0.3500584369,0.6450641899,0.2351119224,0.5288432791
0.7772057197,0.7863756281,0.370178006,0.4468503073
0.5231376264,0.3559675029,0.7235375114,0.5990989552
0.677049257,0.4865385675,0.234308279,0.5464636098
0.4092060379,0.3541481854,0.2136098231,0.532055901
0.6233284474,0.0708858047,0.1600539615,0.3048550129
0.6995308912,0.3063223441,0.0161737235,0.3079828635
0.0258335667,0.647618864,0.9748796014,0.178904038
0.2664170874,0.9572557646,0.5082773798,0.352496119
0.8055430382,0.1183620434,0.3749769024,0.3614118358
0.4322677506,0.2703249249,0.2001609637,0.4823044825
0.9676376693,0.9059139411,0.8382212095,0.160444293
0.8322898693,0.0185976884,0.4761012045,0.2805889039
0.2948531147,0.3478730215,0.2177719094,0.4853936168
0.0765675294,0.8864499313,0.8564301572,0.1909838765
0.0242837934,0.3447383349,0.2180677066,0.2916580023
0.3916847831,0.5498005105,0.278363295,0.6143607339
0.1209140326,0.904015694,0.8785706784,0.1950182427
0.095376816,0.9004315941,0.4104590563,0.2897590043
0.8886550217,0.9244852912,0.8212411644,0.2069075281
0.5141279931,0.7926382609,0.5584593244,0.5672709151
0.0450283497,0.1014355833,0.8525325127,0.1659311463
0.2976476999,0.3824220433,0.6514629608,0.5872565789
0.5382730589,0.3876561896,0.7850114383,0.5572901147
0.9883794178,0.6267332823,0.1704153952,0.2633631498
0.2727107098,0.4992260081,0.3652242266,0.6017801965
0.5885485657,0.6286556898,0.7184304553,0.5975016641
0.8075339779,0.6204837612,0.7815521859,0.4320148997
0.55606677,0.9956735406,0.8111887951,0.278084754
0.0738468201,0.3396072187,0.9644173832,0.2156286919
0.5701443475,0.0310006478,0.2060800641,0.3081100423
0.1462757623,0.9983125547,0.4322945414,0.2511918754
0.8209407749,0.2872603394,0.6165387833,0.4637289557
0.9700720356,0.6198606657,0.4466772395,0.3779909637
0.0672598168,0.7865218778,0.9365435464,0.1878446605
0.3451940787,0.9115880754,0.819826649,0.3222803326
0.046568463,0.8108580533,0.2672551173,0.2690303716
0.3043736313,0.1478831825,0.935546138,0.2727662971
0.4933483334,0.0429575489,0.7964345364,0.3212268345
0.9717623311,0.1613696611,0.4953735107,0.2852917231
0.944890823,0.3716735151,0.5037043622,0.4029819356
0.0074656803,0.7508402078,0.0299907815,0.140477658
0.0895123173,0.6329249935,0.277553003,0.3805855434
0.4782147665,0.5600381009,0.1571106566,0.5172385466
0.7425196474,0.280470928,0.0512009144,0.3106611881
0.6553517027,0.8474713349,0.7578740204,0.4062760258
0.8096713415,0.7807511792,0.1521645495,0.3222358627
0.6701439515,0.5897307442,0.2443192509,0.5460672562
0.1621262084,0.2350032294,0.3728480548,0.4181977532
0.397112443,0.5021985798,0.8988902758,0.4540737862
0.7518828503,0.206660689,0.9419525069,0.2788159522
0.2356205091,0.2507433102,0.4474492101,0.4988919156
0.6384330828,0.5935726465,0.2625215861,0.5756539939
0.2229873218,0.873685293,0.8071468128,0.308606453
0.2435969377,0.6235657639,0.8793150751,0.3917987127
0.5902711594,0.9281412953,0.6057317526,0.4158775898
0.9269695207,0.8969441284,0.5875941348,0.2764998784
0.3155099158,0.3245774735,0.8951628866,0.3959580033
0.2609362076,0.8569220916,0.6559534561,0.4090064143
0.0307727377,0.1355391456,0.6812289128,0.2448572648
0.4932484023,0.8158363269,0.8927346144,0.3620029372
0.537291864,0.5096903368,0.3889371785,0.7484688809
0.8171296908,0.9548852438,0.2046223387,0.2377421965
0.9415802566,0.2354928628,0.4819942187,0.3509706913
0.1402832662,0.892427227,0.2708303237,0.2864445228
0.5193751879,0.2108712015,0.9383615667,0.3405430319
0.0795427464,0.9951977585,0.3791774532,0.2052658333
0.6176248324,0.5187001912,0.8249672042,0.5199199543
0.1677473273,0.7299368383,0.1314358704,0.3191229392
0.62029663,0.6693051737,0.9226033295,0.3951442137
0.9429850334,0.0301803869,0.182328794,0.1463857692
0.1574578131,0.7652385918,0.7141439618,0.3827611937
0.9022531854,0.7319792568,0.5622911152,0.3975148022
0.5484219011,0.7850542005,0.5698941148,0.5685598343
0.9690821893,0.1918015403,0.4621056385,0.3034772961
0.9680029444,0.6161592897,0.485864774,0.3836152659
0.4546147305,0.945019161,0.1045665224,0.2689747262
0.2027256479,0.1298824021,0.2959831648,0.3493224468
0.6926069361,0.8676264975,0.5454309694,0.4485201386
0.1146755546,0.8939644142,0.6506296446,0.2947354794
0.0528997749,0.1493129965,0.881090304,0.1818398986
0.0052914657,0.8885298115,0.8198042133,0.1603578594
0.0202115708,0.4421242778,0.5370242392,0.3813426929
0.1849038715,0.5112594456,0.6441010017,0.5193592185
0.0805469996,0.5838084337,0.9182785681,0.2677598828
0.7693425801,0.820612936,0.442239741,0.4433265421
0.7578899088,0.7314517664,0.9861302383,0.2690331644
0.1508395098,0.6000181628,0.7830312685,0.4055654384
0.5401503961,0.0364483602,0.7337838814,0.3453075528
0.0436407762,0.9630885066,0.1376225652,0.1216920703
0.444924719,0.8353369719,0.7270109649,0.4573468633
0.1167792308,0.3903460717,0.1642017505,0.3448319596
0.9810069531,0.6506951952,0.4515428573,0.3596413346
0.8784186119,0.2383881681,0.490021029,0.4058721943
0.5645867137,0.9274879948,0.0210813162,0.2208273451
0.3946540737,0.9695610544,0.488660959,0.384658681
0.271317021,0.1212995985,0.2448700111,0.3553384055
0.786645854,0.2630994225,0.9100719727,0.3124490748
0.8299039428,0.8205378493,0.2270603696,0.3311635841
0.7050802828,0.5059673086,0.6061498964,0.6350246859
0.7437824024,0.8692702649,0.9084872927,0.2638192459
0.845273826,0.5778816518,0.1422795477,0.3627923676
0.6983100581,0.9155369166,0.8378064328,0.2949641162
0.5051642517,0.9934110959,0.5252557582,0.37194137
0.8364283272,0.3347889184,0.6477939289,0.4631336488
0.4695722678,0.8685884955,0.5668372237,0.4901922754
0.8835673289,0.7960490172,0.9573795091,0.1997184687
0.3635725794,0.6287233307,0.575452674,0.6638491367
0.6857467318,0.8007785211,0.0313382315,0.2789875682
0.9980463693,0.8996167057,0.7536597216,0.1789395636
0.8942417091,0.1993275521,0.600034287,0.3602217811
0.7709446424,0.9467620606,0.4151530892,0.3366802079
0.4111202505,0.2465459624,0.657798339,0.5545147702
0.0067004252,0.4699943093,0.7930665149,0.2914535684
0.7817791928,0.1694443643,0.4205176247,0.4244554889
0.6459198485,0.9738754274,0.8656608967,0.2499422809
0.8327427604,0.4241890884,0.136178942,0.3671959729
0.534428725,0.2622625089,0.5599898174,0.6184305129
0.9989386221,0.9057762275,0.6974975633,0.1932703347
0.1933982413,0.1050110651,0.5889336976,0.3581572125
0.9823128266,0.2797887572,0.1843159252,0.2489556434
0.4904733788,0.5546334197,0.5523404245,0.7897686854
0.7477880857,0.0203964258,0.9589280666,0.1574821841
0.9252310984,0.4871681698,0.0893520095,0.2747404344
0.0526026997,0.9218705003,0.4097528197,0.2445082143
0.9077590647,0.4944113583,0.7820557189,0.3701886198
0.8695934701,0.690935508,0.3343188402,0.4182464985
0.9608450404,0.0235156625,0.3931224881,0.1945804859
0.4544547639,0.1954265567,0.8639801924,0.389243555
0.3445517028,0.9521310535,0.0215255675,0.1896198707
0.1814975096,0.2379880835,0.4335933037,0.4482887282
0.0892784427,0.3839917327,0.1986442627,0.3435644999
0.6653460559,0.8407859359,0.8169383144,0.3721385063
0.2203435269,0.9656928381,0.3485150414,0.3020881244
0.8790159578,0.4066135207,0.6334525648,0.4534921108
0.4351909137,0.7973373982,0.0702711394,0.3394547631
0.4351811069,0.1131372598,0.3432317074,0.4436031432
0.0732657426,0.3757036198,0.50024382,0.4215574342
0.644406111,0.7858667555,0.5250004492,0.5447810276
0.756305656,0.1980193351,0.1795031028,0.3565127225
0.8996659567,0.4597209891,0.7638623497,0.3854230575
0.6825881271,0.7367330294,0.6621422887,0.5259209005
0.3012990604,0.3476373241,0.792477446,0.4810065668
0.0865565365,0.3004642099,0.8129682083,0.3104184128
0.0421286432,0.6892087005,0.385207029,0.3574749757
0.4616250802,0.9213045978,0.9162832329,0.2725088256
0.02303428,0.6399530106,0.2572940856,0.3128624042
0.8347259695,0.8056977472,0.6998366233,0.3706192438
0.138024968,0.3405246541,0.0675626993,0.2799705183
0.8304352884,0.1141640784,0.7441919012,0.3023885324
0.9077913961,0.8236495343,0.8436371752,0.2422230697
0.724509081,0.0846541386,0.091546439,0.2417251367
0.1206736149,0.0897049186,0.758703451,0.2502673054
0.3937018856,0.2676819996,0.5028267012,0.6105279817
0.4960492478,0.3324569377,0.4629601291,0.6943913798
0.7832525712,0.7736390004,0.6018076366,0.459239076
0.3967061569,0.2262678901,0.0954549723,0.3667703934
0.0428036742,0.4119245463,0.9250495513,0.2355867573
0.4063226071,0.6730445873,0.8238667281,0.4870669091
0.5567263441,0.8210499264,0.2593653657,0.4608143963
0.5592416906,0.9012447973,0.0700987189,0.2749906528
0.6384119732,0.6510454672,0.3042892856,0.5826964585
0.9798633371,0.5523820339,0.5814304271,0.376491325
0.9628448317,0.7487761635,0.5941262873,0.3321952101
0.3706260702,0.252344383,0.7096924064,0.5166805546
0.218632948,0.994277475,0.7809678472,0.2316591283
0.3168673543,0.0835500112,0.2528727206,0.348299558
0.7906319198,0.2219688163,0.723273431,0.4060044512
0.1247621915,0.1237534864,0.525949755,0.3340120188
0.9565921184,0.3952253068,0.8622134365,0.2738660735
0.505859251,0.4401271036,0.7924990443,0.5674039286
0.3055876407,0.3310139194,0.9801331168,0.3211581991
0.6631613025,0.276597142,0.5381954648,0.586759686
0.1150634772,0.9736670898,0.2515394538,0.2070342949
0.8232522632,0.4894588125,0.8950760974,0.3554489991
0.4975627763,0.5231172818,0.4102074437,0.7732727653
0.6119855439,0.1610955916,0.4975586061,0.5090899468
0.682962104,0.0776563653,0.419031434,0.3986869975
0.6726203319,0.7876597129,0.9536890857,0.3017739741
0.0913773174,0.9450365906,0.7027720889,0.2287290962
0.602766628,0.7837863102,0.8969436441,0.3673672982
0.6155271592,0.9020927012,0.2874681981,0.3967761824
0.8478364911,0.5960036262,0.5907624708,0.4939437637
0.246004391,0.3808873582,0.0403679333,0.3275430665
0.4305861098,0.0345780167,0.2477172503,0.3320942318
0.5289812609,0.0837675568,0.7474209829,0.3809413873
0.9523989413,0.4010429585,0.1831988612,0.304936944
0.114349951,0.133078384,0.5551008282,0.3308679187
产生以下结果:
original values at random points interpolated values using griddata with linear interpolation
答案 1 :(得分:0)
据我了解,您只需要将新网格转换为1D。
# generate new grid
X, Y, Z=np.mgrid[0:1:10j, 0:1:10j, 0:1:10j]
# interpolate "data.v" on new grid "inter_mesh"
V = gd((x,y,z), v, (X.flatten(),Y.flatten(),Z.flatten()), method='nearest')