I wrote a function which rounds the value of the signal after the first maximum is obtained. However, when I call this function and store the result and plot it, I do not see the expected result.
This is the function:
def avg_aft_max(signal):
ind = [i for i, value in enumerate(signal) if math.isclose(value, np.max(signal))][0]
avg = np.mean(signal[ind:])
signal_new = signal
signal_new[ind:] = [np.max(signal) if math.isclose(avg, np.max(signal), rel_tol=1e-3) else np.max(signal) - 5e-12] * len(signal[ind:])
return signal_new```
clamp_data_filtered = avg_aft_max(clamp_data.v)
fig.add_trace(
go.Scattergl(
x=pins_position_slr_takeover.v,
y=clamp_data_filtered, # This does not work
# y = avg_aft_max(clamp_data.v), # This works
name=clamp_name + '_Filtered',
mode="markers+lines",
line=dict(width=4),
),
secondary_y=False,
row=1,
col=1,
)
Below are both images when I tried to plot them as I described above.
[Expected output](https://i.sstatic.net/wP2AoNY8.png)
[Actual output](https://i.sstatic.net/fz2lXBb6.png)
New contributor
Praveen Kumar Pakkirisamy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.