Exemple #1
0
'''find estimated Xpcs:'''
nn = min(Xpos.size, Xneg.size)
Average_ref_X = np.round((Xpos[:nn] + Xneg[:nn]) / 2)  #.astype(np.int)

# Average_ref_X = np.round(savgol_filter(Average_ref_X, 51, 3)).astype(np.int) # <|<|<|<|

Average_ref_X_linear = hp.linearize_pc_approx(Average_ref_X)

nn = min(Average_ref_X_linear.size, Average_ref_X.size)
Xdev = Average_ref_X[:nn] - Average_ref_X_linear[:nn]
av = np.average(Xdev)
Xdev = Xdev - av

zeroes = find_zeroes(Xdev)

A = hp.constrained_least_squares_arbitrary_intervals(np.arange(nn), Xdev,
                                                     zeroes.tolist(), 4)
Xdev_est = hp.coefs_to_array_arbitrary_intervals(A, X, zeroes.tolist(),
                                                 Average_ref_X_linear.size)

Xpcs = np.round(np.sort(np.abs(Average_ref_X_linear + Xdev_est + av))).astype(
    np.int)
'''find average pc waveform:'''
avgpc, pos_orig_pcs, pos_norm_pcs = average_pc_waveform(
    np.round(np.abs(Average_ref_X)).astype(np.int), W)  # TODO

pcx = interpolate.interp1d(np.linspace(0, 1, avgpc.size), avgpc, "cubic")
Wp = np.zeros(n)
for i in range(Xpcs.size - 1):
    x0 = Xpcs[i]
    x1 = Xpcs[i + 1] - 1
    Wp[x0:x1] = pcx(np.linspace(0, 1, x1 - x0))
Exemple #2
0
Xpos = hp.refine_frontier_iter(Xpos, W)
Xneg = hp.refine_frontier_iter(Xneg, W)

T = []
for i in range(1, Xpos.size):
    T.append(Xpos[i] - Xpos[i - 1])
for i in range(1, Xneg.size):
    T.append(Xneg[i] - Xneg[i - 1])
T = np.array(T, dtype=np.int)
maxT = np.max(T)
modeT = mode(T)

Xf = np.sort(np.hstack([Xpos, Xneg]))

Ix = hp.split_raw_frontier(Xf, W, 2)
A = hp.constrained_least_squares_arbitrary_intervals(Xf, np.abs(W), Ix, 2)
E = hp.coefs_to_array_arbitrary_intervals(A, Xf, Ix, n)

posft, pospcs, negft, negpcs = hp.average_pc_waveform_return_pcsandfts(
    Xpos, Xneg, W)

# pospc = []
# for ft in posft:
#   pospc.append(np.fft.ifft(ft))
# pospc = np.array(pospc)

# X3d = [] # relative i
# Y3d = [] # #pc
# Z3d = [] # amp

# for i in range(pospcs.shape[0]):
Exemple #3
0
Xneg = hp.refine_frontier_iter(Xneg_orig, W)

nn = min(Xpos.size, Xneg.size)
Xpc = ((Xpos[:nn] + Xneg[:nn]) / 2).astype(np.float64)

XX = np.arange(nn, dtype=np.uint64)
b, a = poly.polyfit(XX, Xpc, 1)
Xpc_linear = a * XX + b

Xdev = Xpc_linear[:nn] - Xpc[:nn]
av = np.average(Xdev)
Xdev = Xdev - av

zeroes = find_zeroes(Xdev)

A = hp.constrained_least_squares_arbitrary_intervals(XX, Xdev, zeroes.tolist(), 3)
Xdev_est = hp.coefs_to_array_arbitrary_intervals(A, XX, zeroes.tolist(), nn) + av

print("e2", np.average(np.abs(Xdev)))

Xpcs = np.round(Xpc_linear[:nn] + Xdev[:nn] + av)#.astype(np.int)
Xdev = Xdev + av
'''============================================================================'''
'''                              PLOT LINES                                    '''
'''============================================================================'''

fig = fig = go.Figure()
fig.layout.template ="plotly_white"
# fig.update_yaxes(zeroline=True, zerolinewidth=2, zerolinecolor="black")
fig.update_layout(
  # title = name,