PyEMD安装及简单使用

0. 安装

命令pip install PyEMD存在问题,不建议使用,若用此命令安装,会报以下错误:

Looking in indexes: http://pypi.doubanio.com/simple/, http://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple/, http://pypi.mirrors.ustc.edu.cn/simple/
Collecting PyEMD
  Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/c0/c5/7fea8e7a71cd026b30ed3c40e4c5ea13a173e28f8855da17e25271e8f545/pyemd-0.5.1.tar.gz (91 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy<2.0.0,>=1.9.0 in e:\python\anaconda3\envs\python37\lib\site-packages (from PyEMD) (1.21.2)
Building wheels for collected packages: PyEMD
  Building wheel for PyEMD (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'E:\python\Anaconda3\envs\python37\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"'; __file__='"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\DELL\AppData\Local\Temp\pip-wheel-r07120sj'
       cwd: C:\Users\DELL\AppData\Local\Temp\pip-install-n2jen2us\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\
  Complete output (11 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\pyemd
  copying pyemd\__about__.py -> build\lib.win-amd64-3.7\pyemd
  copying pyemd\__init__.py -> build\lib.win-amd64-3.7\pyemd
  running build_ext
  building 'pyemd.emd' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for PyEMD
  Running setup.py clean for PyEMD
Failed to build PyEMD
Installing collected packages: PyEMD
    Running setup.py install for PyEMD ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\python\Anaconda3\envs\python37\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"'; __file__='"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\DELL\AppData\Local\Temp\pip-record-s9ggc882\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\python\Anaconda3\envs\python37\Include\PyEMD'
         cwd: C:\Users\DELL\AppData\Local\Temp\pip-install-n2jen2us\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\
    Complete output (13 lines):
    running install
    E:\python\Anaconda3\envs\python37\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      setuptools.SetuptoolsDeprecationWarning,
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pyemd
    copying pyemd\__about__.py -> build\lib.win-amd64-3.7\pyemd
    copying pyemd\__init__.py -> build\lib.win-amd64-3.7\pyemd
    running build_ext
    building 'pyemd.emd' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\python\Anaconda3\envs\python37\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"'; __file__='"'"'C:\\Users\\DELL\\AppData\\Local\\Temp\\pip-install-n2jen2us\\pyemd_cfa6b7dfdd37404b8bbdb61120975e4e\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\DELL\AppData\Local\Temp\pip-record-s9ggc882\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\python\Anaconda3\envs\python37\Include\PyEMD' Check the logs for full command output.

可以使用下面命令进行安装:

pip install EMD-signal

如果需要了解更多详细信息,请关注这个链接:PyEMD

1. 简单使用

(1). 导包
# 导入工具包
import numpy as np
from PyEMD import EEMD, EMD, Visualisation
import pylab as plt
(2). 定义信号
# Define signal
t = np.linspace(0, 1, 200)
s = np.cos(11*2*np.pi*t*t) + 6*t*t
(3). 对信号进行EMD处理
# Execute EMD on signal
IMF = EMD().emd(s,t)
N = IMF.shape[0]+1
(4). 绘图
# Plot results
plt.subplot(N,1,1)
plt.plot(t, s, 'r')
plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$")
plt.xlabel("Time [s]")
 
for n, imf in enumerate(IMF):
    plt.subplot(N,1,n+2)
    plt.plot(t, imf, 'g')
    plt.title("IMF "+str(n+1))
    plt.xlabel("Time [s]")
 
plt.tight_layout()
plt.savefig('simple_example')
plt.show()
(5). 结果展示

在这里插入图片描述

  • 15
    点赞
  • 61
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值