Signal Processing Basics
メニューを表示するにはスワイプしてください
信号処理は科学計算における重要な分野であり、音声、電気、センサーなどの信号の解析、操作、解釈に焦点を当てています。Python では、scipy.signal サブモジュールが信号処理のための包括的なツールセットを提供しています。これらのツールには、フィルタリング、ピーク検出、畳み込みなどが含まれており、実世界の信号を効率的かつ正確に処理することが可能です。
1234567891011121314151617181920212223242526import numpy as np import matplotlib.pyplot as plt from scipy.signal import butter, filtfilt # Create a time array and a noisy signal t = np.linspace(0, 1.0, 200) clean_signal = np.sin(2 * np.pi * 5 * t) noise = np.random.normal(0, 0.5, t.shape) noisy_signal = clean_signal + noise # Design a low-pass Butterworth filter b, a = butter(N=4, Wn=0.2) # Apply the filter to the noisy signal filtered_signal = filtfilt(b, a, noisy_signal) # Plot the results plt.figure(figsize=(10, 4)) plt.plot(t, noisy_signal, label="Noisy Signal") plt.plot(t, filtered_signal, label="Filtered Signal", linewidth=2) plt.legend() plt.xlabel("Time [s]") plt.ylabel("Amplitude") plt.title("Low-pass Filtering with scipy.signal") plt.tight_layout() plt.show()
123456789101112131415161718192021import numpy as np import matplotlib.pyplot as plt from scipy.signal import find_peaks # Generate a signal with peaks x = np.linspace(0, 6 * np.pi, 200) signal = np.sin(x) + 0.5 * np.random.randn(200) # Find peaks in the signal peaks, _ = find_peaks(signal, height=0) # Plot signal and detected peaks plt.figure(figsize=(10, 4)) plt.plot(x, signal, label="Signal") plt.plot(x[peaks], signal[peaks], "x", label="Peaks", markersize=10) plt.xlabel("x") plt.ylabel("Amplitude") plt.title("Peak Detection with scipy.signal.find_peaks") plt.legend() plt.tight_layout() plt.show()
フィルタリングは、信号処理において不要な成分(ノイズなど)を信号から除去する一般的な操作。バターワースフィルタのようなフィルタを使用することで、関心のある周波数を分離し、データの解析品質を向上。ピーク検出は、信号内の局所的な最大値を特定する手法で、これらは重要なイベントや特徴に対応。科学的な応用では、フィルタリングとピーク検出は、実験測定の解析、異常検出、複雑なデータから有用な情報を抽出するために不可欠。
1. SciPyのどのサブモジュールが信号処理に使用されますか?
2. 信号をフィルタリングする目的は何ですか?
3. SciPyを使用して信号のピークを検出するにはどうすればよいですか?
すべて明確でしたか?
フィードバックありがとうございます!
セクション 4. 章 3
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 4. 章 3