在python中插值值矩阵

2024-04-20 07:08:12 发布

您现在位置:Python中文网/ 问答频道 /正文

I have the following .txt file:

elevation   [1] inpol1       [2] inpol2       [3] RL(L1)       [4] RL(L2)       [5] LR(L1)       [6] LR(L2)
90.0,   -6.67107685717,   -2.44901761488,   -23.57314833,   -16.97583667,   -21.77855833,   -19.14620333,   
80.0,   -6.8610001598,   -2.55403460547,   -23.28653167,   -17.77932667,   -21.98888667,   -18.62304333,   
70.0,   -7.26186588862,   -2.9273149233,   -23.36461833,   -18.56328833,   -22.90425333,   -19.83013333,   
60.0,   -8.12320485689,   -3.92112857734,   -26.12222167,   -18.67996333,   -22.35199667,   -21.07369833,   
50.0,   -8.79551120253,   -4.78951507462,   -25.77091833,   -20.15670667,   -22.80505,   -19.24572,   
40.0,   -9.7150274851,   -5.74026771244,   -26.13789833,   -19.492935,   -24.116195,   -18.91178833,   
30.0,   -12.4733143154,   -7.38382695233,   -29.59175167,   -20.10266833,   -26.68595167,   -16.59469,   
20.0,   -15.3636359113,   -8.17039424613,   -28.16000167,   -18.59742333,   -29.06789167,   -16.16085667, 
10.0,   -18.4342503347,   -8.1905188993,   -24.938385,   -18.42761667,   -25.16124333,   -16.52676833,    
0.0,   -18.1632600571,   -9.01468419945,   -26.55651833,   -17.22991,   -24.81285167,   -14.60796,   
-10.0,   -16.7133867094,   -11.2860511308,   -23.03011,   -14.87516333,   -25.25885667,   -12.8514,   
-20.0,   -16.9661747422,   -14.9817503484,   -21.28522167,   -13.41128833,   -22.79150667,   -12.05261,   
-30.0,   -19.0849332428,   -25.0207809175,   -22.19593333,   -11.657085,       -21.78081833,   -11.15619333,   
-40.0,   -23.0413759193,   -27.6812084151,   -21.06287,   -10.79255333,   -21.43039167,   -11.43889667,   
-50.0,   -27.2608901323,   -26.008410352,   -20.72646333,   -10.53535783,   -19.86449333,   -11.257135,   
-60.0,   -32.3277829825,   -26.3760335651,   -19.491665,   -10.0824975,   -18.044145,   -9.58142683,   
-70.0,   -31.9688083301,   -24.6389964298,   -17.26466667,   -8.98763067,   -17.47626,   -8.15476567,   
-80.0,   -31.8190661767,   -22.2776308495,   -16.27771,   -7.96193283,   -16.95944667,   -7.04178467,   
-90.0,   -30.1752513951,   -21.8107054104,   -15.40699222,   -7.50867589,   -15.90784333,   -6.01267233,

我想创建一段代码来插值值[1]inpol1,[2]inpol2,[3]RL(L1),[4]RL(L2),[5]LR(L1),[6]LR(L2)。我想我必须使用interp1d函数scipy.插值,但我不知道如何对我的txt文件执行此操作。在

编辑:对不起,我应该说,对于任何给定的高程,我都需要插值。在

有人知道如何执行这项任务吗?注:数值为分贝值,即为对数。在

到目前为止

^{pr2}$

但我知道这行不通。在

谢谢。在


Tags: the代码txtl1havefilerl插值
1条回答
网友
1楼 · 发布于 2024-04-20 07:08:12

我会做出这样的事情:

import numpy as np

ncal = np.genfromtxt('H:/Uni Work/stage 3/Dissertation/Data/newcalibrations.txt', dtype = float, delimiter = ',' , names=True, skip_header=0 )
ncal = ncal.readlines()

interpolation = np.interp(...)

您可以使用np.interp来实现这一点。我在用我的手机,所以我不能启动它,但要集中精力np.interp公司numpy模块;)

相关问题 更多 >