zsh2270365028的个人博客分享 http://blog.sciencenet.cn/u/zsh2270365028

博文

[转载]Plotting the coherence of two signals

已有 1223 次阅读 2022-1-28 14:44 |个人分类:Python|系统分类:科研笔记|文章来源:转载

Plotting the coherence of two signals

refer to: https://matplotlib.org/stable/gallery/lines_bars_and_markers/cohere.html#sphx-glr-gallery-lines-bars-and-markers-cohere-py


An example showing how to plot the coherence of two signals.

cohere

import numpy as npimport matplotlib.pyplot as plt# Fixing random state for reproducibilitynp.random.seed(19680801)dt = 0.01t = np.arange(0, 30, dt)nse1 = np.random.randn(len(t))                 # white noise 1nse2 = np.random.randn(len(t))                 # white noise 2# Two signals with a coherent part at 10Hz and a random parts1 = np.sin(2 * np.pi * 10 * t) + nse1s2 = np.sin(2 * np.pi * 10 * t) + nse2fig, axs = plt.subplots(2, 1)axs[0].plot(t, s1, t, s2)axs[0].set_xlim(0, 2)axs[0].set_xlabel('time')axs[0].set_ylabel('s1 and s2')axs[0].grid(True)cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt)axs[1].set_ylabel('coherence')fig.tight_layout()plt.show()




https://blog.sciencenet.cn/blog-587102-1323095.html

上一篇:arXiv1.28
下一篇:[转载]python Fill Between and Alpha
收藏 IP: 119.78.226.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-25 17:40

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部