Skip to content

Instantly share code, notes, and snippets.

@ground0state
Created January 23, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ground0state/cfcf1c17a7a94e1ab109141607fbc156 to your computer and use it in GitHub Desktop.
Save ground0state/cfcf1c17a7a94e1ab109141607fbc156 to your computer and use it in GitHub Desktop.
from scipy import fftpack, signal
import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 100)
yorg = np.sin(x)
y = yorg + np.random.randn(100)*0.5
# ピーク値のインデックスを取得
maxid = signal.argrelmax(y, order=5) # 最大値
minid = signal.argrelmin(y, order=5) # 最小値
plt.figure(figsize=(10, 5))
plt.plot(x, yorg, 'r', label='オリジナルsin')
plt.plot(x, y, 'k-', label='元系列')
plt.plot(x[maxid], y[maxid], 'ro', label='ピーク値')
plt.plot(x[minid], y[minid], 'bo', label='ピーク値(最小)')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment