1

让我详细说明:

我有一个非线性时间轴,比如说[2.0,5.8,8.18,16.0,32.1](可能是任何东西)

我在上述时间记录了一个波形,比如说[1,1,1,1,1,etc]

我需要将波形转换为线性range(start,end,x), [2,3,4,5,6,7,8,9,10,etc], 哪里x是允许我保留所有数据而不会丢失一些数据的数字

所以它最终成为[1,0,1,0,0,0,1,etc]. 无插值

waveform [1,1,1,1,1,etc]
nonlin   [2.0,5.8,8.18,16.0,32.1]
lin  [0,0.01,0.02,0.03,etc]
new_wave = ...

我最初的尝试是

(伪类):

make array of intervals between points # i.e. [3.8,2.38, etc]
find smallest interval
lin = np.arange(start,end,smallest_interval)
new_wave = np.zeros([ len(lin) ]) # empty array of same size as lin
for index, i in enumerate(lin):
    if i is in nonlin:
        find nonlin index, call it nonlin_index
        new_wave[index] = waveform[nonlin_index]

但是,如果我这样做,这将需要很长时间!

有没有更简单的技术?

4

0 回答 0