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). 定义信号
t = np.linspace(0, 1, 200)
s = np.cos(11*2*np.pi*t*t) + 6*t*t
(3). 对信号进行EMD处理
IMF = EMD().emd(s,t)
N = IMF.shape[0]+1
(4). 绘图
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). 结果展示
|