Created
January 23, 2020 15:01
-
-
Save ground0state/cfcf1c17a7a94e1ab109141607fbc156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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